Live location share - forward latest location (PSF-1044) (#8860)

* handle beacon location events in ForwardDialog

* add transformer for forwarded events in MessageContextMenu

* remove canForward

* update snapshots for beacon model change

* add comments

* fix bad copy pasted test

* add test for beacon locations
This commit is contained in:
Kerry 2022-06-17 15:27:08 +02:00 committed by GitHub
parent 0a90674e89
commit b51ef246ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 292 additions and 81 deletions

View file

@ -28,6 +28,7 @@ import DMRoomMap from "../../../../src/utils/DMRoomMap";
import { RoomPermalinkCreator } from "../../../../src/utils/permalinks/Permalinks";
import {
getMockClientWithEventEmitter,
makeBeaconEvent,
makeLegacyLocationEvent,
makeLocationEvent,
mkEvent,
@ -285,6 +286,33 @@ describe("ForwardDialog", () => {
);
});
it('forwards beacon location as a pin drop event', async () => {
const timestamp = 123456;
const beaconEvent = makeBeaconEvent('@alice:server.org', { geoUri, timestamp });
const text = `Location ${geoUri} at ${new Date(timestamp).toISOString()}`;
const expectedContent = {
msgtype: "m.location",
body: text,
[TEXT_NODE_TYPE.name]: text,
[M_ASSET.name]: { type: LocationAssetType.Pin },
[M_LOCATION.name]: {
uri: geoUri,
description: undefined,
},
geo_uri: geoUri,
[M_TIMESTAMP.name]: timestamp,
};
const wrapper = await mountForwardDialog(beaconEvent);
expect(wrapper.find('MLocationBody').length).toBeTruthy();
sendToFirstRoom(wrapper);
expect(mockClient.sendEvent).toHaveBeenCalledWith(
roomId, EventType.RoomMessage, expectedContent,
);
});
it('forwards pin drop event', async () => {
const wrapper = await mountForwardDialog(pinDropLocationEvent);