From 5ee8e61bf5f7e36e7dae2ee1abb563f0ce1133ee Mon Sep 17 00:00:00 2001 From: Peter Scheu <32014443+peterscheu-aceart@users.noreply.github.com> Date: Fri, 4 Aug 2023 09:19:56 +0200 Subject: [PATCH] Search for users on paste (#11304) Signed-off-by: Peter Scheu --- src/components/views/dialogs/InviteDialog.tsx | 10 +++++++--- .../components/views/dialogs/InviteDialog-test.tsx | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/components/views/dialogs/InviteDialog.tsx b/src/components/views/dialogs/InviteDialog.tsx index fa81a28bee..05fe712bfa 100644 --- a/src/components/views/dialogs/InviteDialog.tsx +++ b/src/components/views/dialogs/InviteDialog.tsx @@ -870,11 +870,17 @@ export default class InviteDialog extends React.PureComponent m.userId === address); if (member) { diff --git a/test/components/views/dialogs/InviteDialog-test.tsx b/test/components/views/dialogs/InviteDialog-test.tsx index 645492cd3d..ab17540cff 100644 --- a/test/components/views/dialogs/InviteDialog-test.tsx +++ b/test/components/views/dialogs/InviteDialog-test.tsx @@ -86,6 +86,7 @@ const aliceEmail = "foobar@email.com"; const bobId = "@bob:example.org"; const bobEmail = "bobbob@example.com"; // bob@example.com is already used as an example in the invite dialog const carolId = "@carol:example.com"; +const bobbob = "bobbob"; const aliceProfileInfo: IProfileInfo = { user_id: aliceId, @@ -290,6 +291,19 @@ describe("InviteDialog", () => { await screen.findByText(aliceEmail); expect(input).toHaveValue(""); }); + it("should support pasting one username that is not a mx id or email", async () => { + mockClient.getIdentityServerUrl.mockReturnValue("https://identity-server"); + mockClient.lookupThreePid.mockResolvedValue({}); + + render(); + + const input = screen.getByTestId("invite-dialog-input"); + input.focus(); + await userEvent.paste(`${bobbob}`); + + await screen.findAllByText(bobId); + expect(input).toHaveValue(`${bobbob}`); + }); it("should allow to invite multiple emails to a room", async () => { render();