Fix error shown if accepting a 3pid invite (#31735)

* Fix error shown if accepting a 3pid invite

If no matrix ID was bound to the email address, the code would
just throw an exception and display a very generic error.

* Unused import

* I hate you too, yarn.

* i18n

* Add test
This commit is contained in:
David Baker
2026-01-15 09:43:19 +00:00
committed by GitHub
parent 6f0cd7621b
commit 82b270616f
4 changed files with 32 additions and 8 deletions

View File

@@ -423,6 +423,20 @@ describe("<RoomPreviewBar />", () => {
await testJoinButton({ inviterName, invitedEmail })();
});
it("renders email mismatch message when no email bound", async () => {
MatrixClientPeg.safeGet().lookupThreePid = jest.fn().mockReturnValue({});
const component = getComponent({ inviterName, invitedEmail });
await waitForElementToBeRemoved(() => component.queryByRole("progressbar"));
expect(getMessage(component)).toMatchSnapshot();
expect(MatrixClientPeg.safeGet().lookupThreePid).toHaveBeenCalledWith(
"email",
invitedEmail,
"mock-token",
);
await testJoinButton({ inviterName, invitedEmail })();
});
it("renders invite message when invite email mxid match", async () => {
MatrixClientPeg.safeGet().lookupThreePid = jest.fn().mockReturnValue({ mxid: userId });
const component = getComponent({ inviterName, invitedEmail });

View File

@@ -252,6 +252,19 @@ exports[`<RoomPreviewBar /> with an invite with an invited email when client has
</div>
`;
exports[`<RoomPreviewBar /> with an invite with an invited email when client has an identity server connected renders email mismatch message when no email bound 1`] = `
<div
class="mx_RoomPreviewBar_message"
>
<h3>
This invite to RoomPreviewBar-test-room was sent to test@test.com
</h3>
<p>
Share this email in Settings to receive invites directly in Element.
</p>
</div>
`;
exports[`<RoomPreviewBar /> with an invite with an invited email when client has an identity server connected renders invite message when invite email mxid match 1`] = `
<div
class="mx_RoomPreviewBar_message"