From 34e85dc03cf21afecb1f8e881343b1d7382165ee Mon Sep 17 00:00:00 2001 From: Peter Scheu Date: Thu, 20 Jul 2023 13:20:17 +0200 Subject: [PATCH] Search for users on paste 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 fa81a28bee0..05fe712bfa7 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 645492cd3d4..ab17540cff0 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();