Skip to content

Commit c5b202a

Browse files
committed
test
1 parent 19001fb commit c5b202a

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

apps/web/test/unit-tests/components/views/dialogs/InviteDialog-test.tsx

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ Please see LICENSE files in the repository root for full details.
77
*/
88

99
import React from "react";
10-
import { fireEvent, render, screen, findByText } from "jest-matrix-react";
10+
import { findByText, fireEvent, render, screen } from "jest-matrix-react";
1111
import userEvent from "@testing-library/user-event";
12-
import { RoomType, type MatrixClient, MatrixError, Room } from "matrix-js-sdk/src/matrix";
12+
import { type MatrixClient, MatrixError, Room, RoomType } from "matrix-js-sdk/src/matrix";
1313
import { KnownMembership } from "matrix-js-sdk/src/types";
1414
import { sleep } from "matrix-js-sdk/src/utils";
1515
import { mocked, type Mocked } from "jest-mock";
@@ -455,4 +455,40 @@ describe("InviteDialog", () => {
455455
await flushPromises();
456456
expect(screen.queryByText("@localpart:server.tld")).not.toBeInTheDocument();
457457
});
458+
459+
describe("when inviting a user whose cryptographic identity we do not know", () => {
460+
beforeEach(() => {
461+
mocked(mockClient.getCrypto()!.getUserVerificationStatus).mockImplementation(async (u) => {
462+
// make sure we don't attempt to call getUserVerificationStatus on things that aren't user IDs
463+
if (!u.startsWith("@")) throw new Error(`Not a user id: ${u}`);
464+
return new UserVerificationStatus(false, false, false, false);
465+
});
466+
});
467+
468+
describe.each([InviteKind.Invite, InviteKind.Dm])("to a %s", (kind) => {
469+
const goButtonName = kind == InviteKind.Invite ? "Invite" : "Go";
470+
471+
beforeEach(() => {
472+
render(
473+
<InviteDialog
474+
kind={kind as InviteKind.Invite | InviteKind.Dm}
475+
roomId={roomId}
476+
onFinished={jest.fn()}
477+
/>,
478+
);
479+
});
480+
481+
it("should show a warning when inviting by user id", async () => {
482+
await enterIntoSearchField("@alice:example.org");
483+
await userEvent.click(screen.getByRole("button", { name: goButtonName }));
484+
await screen.findByText("Confirm inviting them before continuing", { exact: false });
485+
});
486+
487+
it("should show a warning when inviting by email address", async () => {
488+
await enterIntoSearchField("aaa@bbb");
489+
await userEvent.click(screen.getByRole("button", { name: goButtonName }));
490+
await screen.findByText("Confirm inviting them before continuing", { exact: false });
491+
});
492+
});
493+
});
458494
});

0 commit comments

Comments
 (0)