2021-05-09 02:51:51 +03:00
|
|
|
/*
|
2024-09-09 16:57:16 +03:00
|
|
|
Copyright 2024 New Vector Ltd.
|
2021-06-06 04:41:28 +03:00
|
|
|
Copyright 2021 Robin Townsend <robin@robin.town>
|
2021-05-09 02:51:51 +03:00
|
|
|
|
2024-09-09 16:57:16 +03:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
|
|
|
Please see LICENSE files in the repository root for full details.
|
2021-05-09 02:51:51 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
import React from "react";
|
2023-08-23 12:04:25 +03:00
|
|
|
import {
|
|
|
|
MatrixEvent,
|
|
|
|
EventType,
|
|
|
|
LocationAssetType,
|
|
|
|
M_ASSET,
|
|
|
|
M_LOCATION,
|
|
|
|
M_TIMESTAMP,
|
|
|
|
M_TEXT,
|
|
|
|
} from "matrix-js-sdk/src/matrix";
|
2024-10-14 19:11:58 +03:00
|
|
|
import { act, fireEvent, getByTestId, render, RenderResult, screen, waitFor } from "jest-matrix-react";
|
2022-11-18 12:16:11 +03:00
|
|
|
import userEvent from "@testing-library/user-event";
|
2024-06-13 17:15:59 +03:00
|
|
|
import { sleep } from "matrix-js-sdk/src/utils";
|
2021-05-09 02:51:51 +03:00
|
|
|
|
2024-10-15 16:57:26 +03:00
|
|
|
import { MatrixClientPeg } from "../../../../../src/MatrixClientPeg";
|
|
|
|
import ForwardDialog from "../../../../../src/components/views/dialogs/ForwardDialog";
|
|
|
|
import DMRoomMap from "../../../../../src/utils/DMRoomMap";
|
|
|
|
import { RoomPermalinkCreator } from "../../../../../src/utils/permalinks/Permalinks";
|
2022-05-03 11:22:38 +03:00
|
|
|
import {
|
|
|
|
getMockClientWithEventEmitter,
|
2022-06-17 16:27:08 +03:00
|
|
|
makeBeaconEvent,
|
2022-05-10 19:21:20 +03:00
|
|
|
makeLegacyLocationEvent,
|
|
|
|
makeLocationEvent,
|
2022-05-03 11:22:38 +03:00
|
|
|
mkEvent,
|
|
|
|
mkMessage,
|
|
|
|
mkStubRoom,
|
2022-11-18 12:16:11 +03:00
|
|
|
mockPlatformPeg,
|
2024-10-15 16:57:26 +03:00
|
|
|
} from "../../../../test-utils";
|
|
|
|
import { TILE_SERVER_WK_KEY } from "../../../../../src/utils/WellKnownUtils";
|
|
|
|
import SettingsStore from "../../../../../src/settings/SettingsStore";
|
2021-05-09 02:51:51 +03:00
|
|
|
|
2024-03-08 17:45:15 +03:00
|
|
|
// mock offsetParent
|
|
|
|
Object.defineProperty(HTMLElement.prototype, "offsetParent", {
|
|
|
|
get() {
|
|
|
|
return this.parentNode;
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2021-05-09 02:51:51 +03:00
|
|
|
describe("ForwardDialog", () => {
|
2021-05-10 07:54:00 +03:00
|
|
|
const sourceRoom = "!111111111111111111:example.org";
|
2022-05-03 11:22:38 +03:00
|
|
|
const aliceId = "@alice:example.org";
|
|
|
|
const defaultMessage = mkMessage({
|
2021-05-10 07:54:00 +03:00
|
|
|
room: sourceRoom,
|
2022-05-03 11:22:38 +03:00
|
|
|
user: aliceId,
|
2021-05-09 02:51:51 +03:00
|
|
|
msg: "Hello world!",
|
|
|
|
event: true,
|
|
|
|
});
|
2022-05-03 11:22:38 +03:00
|
|
|
const accountDataEvent = new MatrixEvent({
|
|
|
|
type: EventType.Direct,
|
|
|
|
sender: aliceId,
|
|
|
|
content: {},
|
|
|
|
});
|
|
|
|
const mockClient = getMockClientWithEventEmitter({
|
|
|
|
getUserId: jest.fn().mockReturnValue(aliceId),
|
2023-03-27 10:01:09 +03:00
|
|
|
getSafeUserId: jest.fn().mockReturnValue(aliceId),
|
2022-05-03 11:22:38 +03:00
|
|
|
isGuest: jest.fn().mockReturnValue(false),
|
|
|
|
getVisibleRooms: jest.fn().mockReturnValue([]),
|
|
|
|
getRoom: jest.fn(),
|
|
|
|
getAccountData: jest.fn().mockReturnValue(accountDataEvent),
|
|
|
|
getPushActionsForEvent: jest.fn(),
|
|
|
|
mxcUrlToHttp: jest.fn().mockReturnValue(""),
|
|
|
|
isRoomEncrypted: jest.fn().mockReturnValue(false),
|
|
|
|
getProfileInfo: jest.fn().mockResolvedValue({
|
|
|
|
displayname: "Alice",
|
|
|
|
}),
|
|
|
|
decryptEventIfNeeded: jest.fn(),
|
|
|
|
sendEvent: jest.fn(),
|
2022-05-10 19:21:20 +03:00
|
|
|
getClientWellKnown: jest.fn().mockReturnValue({
|
|
|
|
[TILE_SERVER_WK_KEY.name]: { map_style_url: "maps.com" },
|
|
|
|
}),
|
2022-05-03 11:22:38 +03:00
|
|
|
});
|
|
|
|
const defaultRooms = ["a", "A", "b"].map((name) => mkStubRoom(name, name, mockClient));
|
2021-05-09 02:51:51 +03:00
|
|
|
|
2022-11-18 12:16:11 +03:00
|
|
|
const mountForwardDialog = (message = defaultMessage, rooms = defaultRooms) => {
|
2022-05-03 11:22:38 +03:00
|
|
|
mockClient.getVisibleRooms.mockReturnValue(rooms);
|
2023-02-15 16:36:22 +03:00
|
|
|
mockClient.getRoom.mockImplementation((roomId) => rooms.find((room) => room.roomId === roomId) || null);
|
2021-05-09 02:51:51 +03:00
|
|
|
|
2022-11-18 12:16:11 +03:00
|
|
|
const wrapper: RenderResult = render(
|
|
|
|
<ForwardDialog
|
|
|
|
matrixClient={mockClient}
|
|
|
|
event={message}
|
2023-02-15 16:36:22 +03:00
|
|
|
permalinkCreator={new RoomPermalinkCreator(undefined!, sourceRoom)}
|
2022-11-18 12:16:11 +03:00
|
|
|
onFinished={jest.fn()}
|
|
|
|
/>,
|
|
|
|
);
|
2021-05-10 07:54:00 +03:00
|
|
|
|
|
|
|
return wrapper;
|
|
|
|
};
|
|
|
|
|
|
|
|
beforeEach(() => {
|
2023-05-23 18:24:12 +03:00
|
|
|
DMRoomMap.makeShared(mockClient);
|
2022-05-03 11:22:38 +03:00
|
|
|
jest.clearAllMocks();
|
|
|
|
mockClient.getUserId.mockReturnValue("@bob:example.org");
|
2023-03-27 10:01:09 +03:00
|
|
|
mockClient.getSafeUserId.mockReturnValue("@bob:example.org");
|
2022-05-03 11:22:38 +03:00
|
|
|
mockClient.sendEvent.mockReset();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(() => {
|
|
|
|
jest.spyOn(MatrixClientPeg, "get").mockRestore();
|
2021-05-09 02:51:51 +03:00
|
|
|
});
|
|
|
|
|
2021-05-10 07:54:00 +03:00
|
|
|
it("shows a preview with us as the sender", async () => {
|
2022-11-18 12:16:11 +03:00
|
|
|
const { container } = mountForwardDialog();
|
2021-05-10 07:54:00 +03:00
|
|
|
|
2022-11-18 12:16:11 +03:00
|
|
|
expect(screen.queryByText("Hello world!")).toBeInTheDocument();
|
2021-05-09 02:51:51 +03:00
|
|
|
|
|
|
|
// We would just test SenderProfile for the user ID, but it's stubbed
|
2023-08-24 06:48:35 +03:00
|
|
|
const previewAvatar = container.querySelector(".mx_EventTile_avatar .mx_BaseAvatar");
|
2022-11-18 12:16:11 +03:00
|
|
|
expect(previewAvatar?.getAttribute("title")).toBe("@bob:example.org");
|
2021-05-09 02:51:51 +03:00
|
|
|
});
|
|
|
|
|
2021-05-10 07:54:00 +03:00
|
|
|
it("filters the rooms", async () => {
|
2022-11-18 12:16:11 +03:00
|
|
|
const { container } = mountForwardDialog();
|
2021-05-10 07:54:00 +03:00
|
|
|
|
2022-11-18 12:16:11 +03:00
|
|
|
expect(container.querySelectorAll(".mx_ForwardList_entry")).toHaveLength(3);
|
2021-05-09 02:51:51 +03:00
|
|
|
|
2022-11-18 12:16:11 +03:00
|
|
|
const searchInput = getByTestId(container, "searchbox-input");
|
2024-05-02 17:53:35 +03:00
|
|
|
await userEvent.type(searchInput, "a");
|
2021-05-09 02:51:51 +03:00
|
|
|
|
2024-05-02 17:53:35 +03:00
|
|
|
expect(container.querySelectorAll(".mx_ForwardList_entry")).toHaveLength(2);
|
2021-05-09 02:51:51 +03:00
|
|
|
});
|
|
|
|
|
2024-03-08 17:45:15 +03:00
|
|
|
it("should be navigable using arrow keys", async () => {
|
|
|
|
const { container } = mountForwardDialog();
|
|
|
|
|
|
|
|
const searchBox = getByTestId(container, "searchbox-input");
|
|
|
|
searchBox.focus();
|
|
|
|
await waitFor(() =>
|
|
|
|
expect(container.querySelectorAll(".mx_ForwardList_entry")[0]).toHaveClass("mx_ForwardList_entry_active"),
|
|
|
|
);
|
|
|
|
|
|
|
|
await userEvent.keyboard("[ArrowDown]");
|
|
|
|
await waitFor(() =>
|
|
|
|
expect(container.querySelectorAll(".mx_ForwardList_entry")[1]).toHaveClass("mx_ForwardList_entry_active"),
|
|
|
|
);
|
|
|
|
|
|
|
|
await userEvent.keyboard("[ArrowDown]");
|
|
|
|
await waitFor(() =>
|
|
|
|
expect(container.querySelectorAll(".mx_ForwardList_entry")[2]).toHaveClass("mx_ForwardList_entry_active"),
|
|
|
|
);
|
|
|
|
|
|
|
|
await userEvent.keyboard("[ArrowUp]");
|
|
|
|
await waitFor(() =>
|
|
|
|
expect(container.querySelectorAll(".mx_ForwardList_entry")[1]).toHaveClass("mx_ForwardList_entry_active"),
|
|
|
|
);
|
|
|
|
|
|
|
|
await userEvent.keyboard("[Enter]");
|
|
|
|
expect(mockClient.sendEvent).toHaveBeenCalledWith("A", "m.room.message", {
|
|
|
|
body: "Hello world!",
|
|
|
|
msgtype: "m.text",
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-05-09 02:51:51 +03:00
|
|
|
it("tracks message sending progress across multiple rooms", async () => {
|
2022-11-18 12:16:11 +03:00
|
|
|
mockPlatformPeg();
|
|
|
|
const { container } = mountForwardDialog();
|
2021-05-10 07:54:00 +03:00
|
|
|
|
2021-05-09 02:51:51 +03:00
|
|
|
// Make sendEvent require manual resolution so we can see the sending state
|
2023-02-13 14:39:16 +03:00
|
|
|
let finishSend: (arg?: any) => void;
|
|
|
|
let cancelSend: () => void;
|
2022-11-04 13:48:08 +03:00
|
|
|
mockClient.sendEvent.mockImplementation(
|
|
|
|
<T extends {}>() =>
|
|
|
|
new Promise<T>((resolve, reject) => {
|
2021-05-09 02:51:51 +03:00
|
|
|
finishSend = resolve;
|
|
|
|
cancelSend = reject;
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
|
2023-02-15 16:36:22 +03:00
|
|
|
let firstButton!: Element;
|
|
|
|
let secondButton!: Element;
|
2022-03-03 15:54:20 +03:00
|
|
|
const update = () => {
|
2022-11-18 12:16:11 +03:00
|
|
|
[firstButton, secondButton] = container.querySelectorAll(".mx_ForwardList_sendButton");
|
2022-03-03 15:54:20 +03:00
|
|
|
};
|
|
|
|
update();
|
|
|
|
|
2022-11-18 12:16:11 +03:00
|
|
|
expect(firstButton.className).toContain("mx_ForwardList_canSend");
|
2021-05-09 02:51:51 +03:00
|
|
|
|
2022-11-18 12:16:11 +03:00
|
|
|
act(() => {
|
|
|
|
fireEvent.click(firstButton);
|
|
|
|
});
|
2022-03-03 15:54:20 +03:00
|
|
|
update();
|
2022-11-18 12:16:11 +03:00
|
|
|
expect(firstButton.className).toContain("mx_ForwardList_sending");
|
2021-05-09 02:51:51 +03:00
|
|
|
|
|
|
|
await act(async () => {
|
|
|
|
cancelSend();
|
|
|
|
// Wait one tick for the button to realize the send failed
|
2024-06-13 17:15:59 +03:00
|
|
|
await sleep(0);
|
2021-05-09 02:51:51 +03:00
|
|
|
});
|
2022-03-03 15:54:20 +03:00
|
|
|
update();
|
2022-11-18 12:16:11 +03:00
|
|
|
expect(firstButton.className).toContain("mx_ForwardList_sendFailed");
|
2021-05-09 02:51:51 +03:00
|
|
|
|
2022-11-18 12:16:11 +03:00
|
|
|
expect(secondButton.className).toContain("mx_ForwardList_canSend");
|
2021-05-09 02:51:51 +03:00
|
|
|
|
2022-11-18 12:16:11 +03:00
|
|
|
act(() => {
|
|
|
|
fireEvent.click(secondButton);
|
|
|
|
});
|
2022-03-03 15:54:20 +03:00
|
|
|
update();
|
2022-11-18 12:16:11 +03:00
|
|
|
expect(secondButton.className).toContain("mx_ForwardList_sending");
|
2021-05-09 02:51:51 +03:00
|
|
|
|
|
|
|
await act(async () => {
|
|
|
|
finishSend();
|
|
|
|
// Wait one tick for the button to realize the send succeeded
|
2024-06-13 17:15:59 +03:00
|
|
|
await sleep(0);
|
2021-05-09 02:51:51 +03:00
|
|
|
});
|
2022-03-03 15:54:20 +03:00
|
|
|
update();
|
2022-11-18 12:16:11 +03:00
|
|
|
expect(secondButton.className).toContain("mx_ForwardList_sent");
|
2021-05-09 02:51:51 +03:00
|
|
|
});
|
2021-05-10 07:54:00 +03:00
|
|
|
|
|
|
|
it("can render replies", async () => {
|
2022-05-03 11:22:38 +03:00
|
|
|
const replyMessage = mkEvent({
|
2021-05-10 07:54:00 +03:00
|
|
|
type: "m.room.message",
|
|
|
|
room: "!111111111111111111:example.org",
|
|
|
|
user: "@alice:example.org",
|
|
|
|
content: {
|
2021-05-10 08:16:37 +03:00
|
|
|
"msgtype": "m.text",
|
|
|
|
"body": "> <@bob:example.org> Hi Alice!\n\nHi Bob!",
|
2021-05-10 07:54:00 +03:00
|
|
|
"m.relates_to": {
|
|
|
|
"m.in_reply_to": {
|
|
|
|
event_id: "$2222222222222222222222222222222222222222222",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
event: true,
|
|
|
|
});
|
|
|
|
|
2022-11-18 12:16:11 +03:00
|
|
|
mountForwardDialog(replyMessage);
|
|
|
|
|
|
|
|
expect(screen.queryByText("Hi Alice!", { exact: false })).toBeInTheDocument();
|
2021-05-10 07:54:00 +03:00
|
|
|
});
|
2021-05-10 08:07:42 +03:00
|
|
|
|
|
|
|
it("disables buttons for rooms without send permissions", async () => {
|
2022-05-03 11:22:38 +03:00
|
|
|
const readOnlyRoom = mkStubRoom("a", "a", mockClient);
|
2021-05-10 08:07:42 +03:00
|
|
|
readOnlyRoom.maySendMessage = jest.fn().mockReturnValue(false);
|
2022-05-03 11:22:38 +03:00
|
|
|
const rooms = [readOnlyRoom, mkStubRoom("b", "b", mockClient)];
|
2021-05-10 08:07:42 +03:00
|
|
|
|
2022-11-18 12:16:11 +03:00
|
|
|
const { container } = mountForwardDialog(undefined, rooms);
|
|
|
|
|
|
|
|
const [firstButton, secondButton] = container.querySelectorAll<HTMLButtonElement>(".mx_ForwardList_sendButton");
|
2021-05-10 08:07:42 +03:00
|
|
|
|
2022-11-18 12:16:11 +03:00
|
|
|
expect(firstButton.getAttribute("aria-disabled")).toBeTruthy();
|
|
|
|
expect(secondButton.getAttribute("aria-disabled")).toBeFalsy();
|
2021-05-10 08:07:42 +03:00
|
|
|
});
|
2022-05-10 19:21:20 +03:00
|
|
|
|
|
|
|
describe("Location events", () => {
|
|
|
|
// 14.03.2022 16:15
|
|
|
|
const now = 1647270879403;
|
|
|
|
const roomId = "a";
|
|
|
|
const geoUri = "geo:51.5076,-0.1276";
|
|
|
|
const legacyLocationEvent = makeLegacyLocationEvent(geoUri);
|
|
|
|
const modernLocationEvent = makeLocationEvent(geoUri);
|
|
|
|
const pinDropLocationEvent = makeLocationEvent(geoUri, LocationAssetType.Pin);
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
// legacy events will default timestamp to Date.now()
|
|
|
|
// mock a stable now for easy assertion
|
|
|
|
jest.spyOn(Date, "now").mockReturnValue(now);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(() => {
|
|
|
|
jest.spyOn(Date, "now").mockRestore();
|
|
|
|
});
|
|
|
|
|
2022-11-18 12:16:11 +03:00
|
|
|
const sendToFirstRoom = (container: HTMLElement): void =>
|
2022-05-10 19:21:20 +03:00
|
|
|
act(() => {
|
2022-11-18 12:16:11 +03:00
|
|
|
const sendToFirstRoomButton = container.querySelector(".mx_ForwardList_sendButton");
|
|
|
|
fireEvent.click(sendToFirstRoomButton!);
|
2022-05-10 19:21:20 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it("converts legacy location events to pin drop shares", async () => {
|
2022-11-18 12:16:11 +03:00
|
|
|
const { container } = mountForwardDialog(legacyLocationEvent);
|
2022-05-10 19:21:20 +03:00
|
|
|
|
2022-11-18 12:16:11 +03:00
|
|
|
expect(container.querySelector(".mx_MLocationBody")).toBeTruthy();
|
|
|
|
sendToFirstRoom(container);
|
2022-05-10 19:21:20 +03:00
|
|
|
|
|
|
|
// text and description from original event are removed
|
|
|
|
// text gets new default message from event values
|
|
|
|
// timestamp is defaulted to now
|
|
|
|
const text = `Location ${geoUri} at ${new Date(now).toISOString()}`;
|
|
|
|
const expectedStrippedContent = {
|
|
|
|
...modernLocationEvent.getContent(),
|
|
|
|
body: text,
|
2023-01-13 20:02:33 +03:00
|
|
|
[M_TEXT.name]: text,
|
2022-05-10 19:21:20 +03:00
|
|
|
[M_TIMESTAMP.name]: now,
|
|
|
|
[M_ASSET.name]: { type: LocationAssetType.Pin },
|
|
|
|
[M_LOCATION.name]: {
|
|
|
|
uri: geoUri,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
expect(mockClient.sendEvent).toHaveBeenCalledWith(
|
|
|
|
roomId,
|
|
|
|
legacyLocationEvent.getType(),
|
|
|
|
expectedStrippedContent,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("removes personal information from static self location shares", async () => {
|
2022-11-18 12:16:11 +03:00
|
|
|
const { container } = mountForwardDialog(modernLocationEvent);
|
2022-05-10 19:21:20 +03:00
|
|
|
|
2022-11-18 12:16:11 +03:00
|
|
|
expect(container.querySelector(".mx_MLocationBody")).toBeTruthy();
|
|
|
|
sendToFirstRoom(container);
|
2022-05-10 19:21:20 +03:00
|
|
|
|
2023-02-15 16:36:22 +03:00
|
|
|
const timestamp = M_TIMESTAMP.findIn<number>(modernLocationEvent.getContent())!;
|
2022-05-10 19:21:20 +03:00
|
|
|
// text and description from original event are removed
|
|
|
|
// text gets new default message from event values
|
|
|
|
const text = `Location ${geoUri} at ${new Date(timestamp).toISOString()}`;
|
|
|
|
const expectedStrippedContent = {
|
|
|
|
...modernLocationEvent.getContent(),
|
|
|
|
body: text,
|
2023-01-13 20:02:33 +03:00
|
|
|
[M_TEXT.name]: text,
|
2022-05-10 19:21:20 +03:00
|
|
|
[M_ASSET.name]: { type: LocationAssetType.Pin },
|
|
|
|
[M_LOCATION.name]: {
|
|
|
|
uri: geoUri,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
expect(mockClient.sendEvent).toHaveBeenCalledWith(
|
|
|
|
roomId,
|
|
|
|
modernLocationEvent.getType(),
|
|
|
|
expectedStrippedContent,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2022-06-17 16:27:08 +03:00
|
|
|
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,
|
2023-01-13 20:02:33 +03:00
|
|
|
[M_TEXT.name]: text,
|
2022-06-17 16:27:08 +03:00
|
|
|
[M_ASSET.name]: { type: LocationAssetType.Pin },
|
|
|
|
[M_LOCATION.name]: {
|
|
|
|
uri: geoUri,
|
|
|
|
},
|
|
|
|
geo_uri: geoUri,
|
|
|
|
[M_TIMESTAMP.name]: timestamp,
|
|
|
|
};
|
2022-11-18 12:16:11 +03:00
|
|
|
const { container } = mountForwardDialog(beaconEvent);
|
2022-06-17 16:27:08 +03:00
|
|
|
|
2022-11-18 12:16:11 +03:00
|
|
|
expect(container.querySelector(".mx_MLocationBody")).toBeTruthy();
|
2022-06-17 16:27:08 +03:00
|
|
|
|
2022-11-18 12:16:11 +03:00
|
|
|
sendToFirstRoom(container);
|
2022-06-17 16:27:08 +03:00
|
|
|
|
|
|
|
expect(mockClient.sendEvent).toHaveBeenCalledWith(roomId, EventType.RoomMessage, expectedContent);
|
|
|
|
});
|
|
|
|
|
2022-05-10 19:21:20 +03:00
|
|
|
it("forwards pin drop event", async () => {
|
2022-11-18 12:16:11 +03:00
|
|
|
const { container } = mountForwardDialog(pinDropLocationEvent);
|
2022-05-10 19:21:20 +03:00
|
|
|
|
2022-11-18 12:16:11 +03:00
|
|
|
expect(container.querySelector(".mx_MLocationBody")).toBeTruthy();
|
2022-05-10 19:21:20 +03:00
|
|
|
|
2022-11-18 12:16:11 +03:00
|
|
|
sendToFirstRoom(container);
|
2022-05-10 19:21:20 +03:00
|
|
|
|
|
|
|
expect(mockClient.sendEvent).toHaveBeenCalledWith(
|
|
|
|
roomId,
|
|
|
|
pinDropLocationEvent.getType(),
|
|
|
|
pinDropLocationEvent.getContent(),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2023-03-10 12:41:30 +03:00
|
|
|
|
|
|
|
describe("If the feature_dynamic_room_predecessors is not enabled", () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
jest.spyOn(SettingsStore, "getValue").mockReturnValue(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Passes through the dynamic predecessor setting", async () => {
|
|
|
|
mockClient.getVisibleRooms.mockClear();
|
|
|
|
mountForwardDialog();
|
|
|
|
expect(mockClient.getVisibleRooms).toHaveBeenCalledWith(false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("If the feature_dynamic_room_predecessors is enabled", () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
// Turn on feature_dynamic_room_predecessors setting
|
|
|
|
jest.spyOn(SettingsStore, "getValue").mockImplementation(
|
|
|
|
(settingName) => settingName === "feature_dynamic_room_predecessors",
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Passes through the dynamic predecessor setting", async () => {
|
|
|
|
mockClient.getVisibleRooms.mockClear();
|
|
|
|
mountForwardDialog();
|
|
|
|
expect(mockClient.getVisibleRooms).toHaveBeenCalledWith(true);
|
|
|
|
});
|
|
|
|
});
|
2021-05-09 02:51:51 +03:00
|
|
|
});
|