Allow reporting a room when rejecting an invite. (#29570)
* Add report room dialog button/dialog. * Update copy * fixup tests / lint * Fix title in test. * update snapshot * Add unit tests for dialog * lint * First pass at adding a report room on invite. * Use a single line input field for reason to avoid bumping the layout. * Fixups * Embed reason to make it clear on grouping * Revert accidental commit * lint * Add some playwright tests. * tweaks * Make ignored users list more accessible. * i18n * Fix sliding sync test. * Add unit test * Even more unit tests. * move test * Update to match designs. * remove console statements * fix css * tidy up * improve comments * fix css * updates
This commit is contained in:
@@ -19,6 +19,7 @@ import {
|
||||
MatrixEvent,
|
||||
Room,
|
||||
RoomEvent,
|
||||
RoomMember,
|
||||
RoomStateEvent,
|
||||
SearchResult,
|
||||
} from "matrix-js-sdk/src/matrix";
|
||||
@@ -78,6 +79,7 @@ import MatrixClientContext from "../../../../src/contexts/MatrixClientContext";
|
||||
import { type ViewUserPayload } from "../../../../src/dispatcher/payloads/ViewUserPayload.ts";
|
||||
import { CallStore } from "../../../../src/stores/CallStore.ts";
|
||||
import MediaDeviceHandler, { MediaDeviceKindEnum } from "../../../../src/MediaDeviceHandler.ts";
|
||||
import Modal from "../../../../src/Modal.tsx";
|
||||
|
||||
// Used by group calls
|
||||
jest.spyOn(MediaDeviceHandler, "getDevices").mockResolvedValue({
|
||||
@@ -196,7 +198,7 @@ describe("RoomView", () => {
|
||||
<RoomView
|
||||
// threepidInvite should be optional on RoomView props
|
||||
// it is treated as optional in RoomView
|
||||
threepidInvite={undefined as any}
|
||||
threepidInvite={undefined}
|
||||
resizeNotifier={new ResizeNotifier()}
|
||||
forceTimeline={false}
|
||||
onRegistered={jest.fn()}
|
||||
@@ -233,6 +235,62 @@ describe("RoomView", () => {
|
||||
expect(instance.getHiddenHighlightCount()).toBe(0);
|
||||
});
|
||||
|
||||
describe("invites", () => {
|
||||
beforeEach(() => {
|
||||
const member = new RoomMember(room.roomId, cli.getSafeUserId());
|
||||
member.membership = KnownMembership.Invite;
|
||||
member.events.member = new MatrixEvent({
|
||||
sender: "@bob:example.org",
|
||||
});
|
||||
room.getMyMembership = jest.fn().mockReturnValue(KnownMembership.Invite);
|
||||
room.getMember = jest.fn().mockReturnValue(member);
|
||||
});
|
||||
|
||||
it("renders an invite room", async () => {
|
||||
const { asFragment } = await mountRoomView();
|
||||
expect(asFragment()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("handles accepting an invite", async () => {
|
||||
const { getByRole } = await mountRoomView();
|
||||
|
||||
await fireEvent.click(getByRole("button", { name: "Accept" }));
|
||||
|
||||
await untilDispatch(Action.JoinRoomReady, defaultDispatcher);
|
||||
});
|
||||
it("handles declining an invite", async () => {
|
||||
const { getByRole } = await mountRoomView();
|
||||
jest.spyOn(Modal, "createDialog").mockReturnValue({
|
||||
finished: Promise.resolve([true, false, false]),
|
||||
close: jest.fn(),
|
||||
});
|
||||
await fireEvent.click(getByRole("button", { name: "Decline" }));
|
||||
await waitFor(() => expect(cli.leave).toHaveBeenCalledWith(room.roomId));
|
||||
expect(cli.setIgnoredUsers).not.toHaveBeenCalled();
|
||||
});
|
||||
it("handles declining an invite and ignoring the user", async () => {
|
||||
const { getByRole } = await mountRoomView();
|
||||
cli.getIgnoredUsers.mockReturnValue(["@carol:example.org"]);
|
||||
jest.spyOn(Modal, "createDialog").mockReturnValue({
|
||||
finished: Promise.resolve([true, true, false]),
|
||||
close: jest.fn(),
|
||||
});
|
||||
await fireEvent.click(getByRole("button", { name: "Decline and block" }));
|
||||
expect(cli.leave).toHaveBeenCalledWith(room.roomId);
|
||||
expect(cli.setIgnoredUsers).toHaveBeenCalledWith(["@carol:example.org", "@bob:example.org"]);
|
||||
});
|
||||
it("handles declining an invite and reporting the room", async () => {
|
||||
const { getByRole } = await mountRoomView();
|
||||
jest.spyOn(Modal, "createDialog").mockReturnValue({
|
||||
finished: Promise.resolve([true, false, "with a reason"]),
|
||||
close: jest.fn(),
|
||||
});
|
||||
await fireEvent.click(getByRole("button", { name: "Decline and block" }));
|
||||
expect(cli.leave).toHaveBeenCalledWith(room.roomId);
|
||||
expect(cli.reportRoom).toHaveBeenCalledWith(room.roomId, "with a reason");
|
||||
});
|
||||
});
|
||||
|
||||
describe("when there is an old room", () => {
|
||||
let instance: RoomView;
|
||||
let oldRoom: Room;
|
||||
|
||||
@@ -1264,6 +1264,79 @@ exports[`RoomView for a local room in state NEW that is encrypted should match t
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`RoomView invites renders an invite room 1`] = `
|
||||
<DocumentFragment>
|
||||
<div
|
||||
class="mx_RoomView"
|
||||
>
|
||||
<div
|
||||
class="mx_RoomPreviewBar mx_RoomPreviewBar_Invite mx_RoomPreviewBar_dialog"
|
||||
role="complementary"
|
||||
>
|
||||
<div
|
||||
class="mx_RoomPreviewBar_message"
|
||||
>
|
||||
<h3>
|
||||
Do you want to join !2:example.org?
|
||||
</h3>
|
||||
<p>
|
||||
<span
|
||||
class="_avatar_1qbcf_8 mx_BaseAvatar _avatar-imageless_1qbcf_52"
|
||||
data-color="4"
|
||||
data-testid="avatar-img"
|
||||
data-type="round"
|
||||
role="presentation"
|
||||
style="--cpd-avatar-size: 36px;"
|
||||
>
|
||||
!
|
||||
</span>
|
||||
</p>
|
||||
<p>
|
||||
<span>
|
||||
Invited by
|
||||
<span
|
||||
class="mx_RoomPreviewBar_inviter"
|
||||
>
|
||||
@bob:example.org
|
||||
</span>
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
<div
|
||||
class="mx_RoomPreviewBar_actions"
|
||||
>
|
||||
<div
|
||||
class="mx_AccessibleButton mx_AccessibleButton_hasKind mx_AccessibleButton_kind_primary"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
Accept
|
||||
</div>
|
||||
<div
|
||||
class="mx_AccessibleButton mx_AccessibleButton_hasKind mx_AccessibleButton_kind_secondary"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
Decline
|
||||
</div>
|
||||
<button
|
||||
class="_button_vczzf_8 _destructive_vczzf_107"
|
||||
data-kind="tertiary"
|
||||
data-size="lg"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
Decline and block
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
class="mx_RoomPreviewBar_footer"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</DocumentFragment>
|
||||
`;
|
||||
|
||||
exports[`RoomView should not display the timeline when the room encryption is loading 1`] = `
|
||||
<DocumentFragment>
|
||||
<div
|
||||
@@ -1290,7 +1363,7 @@ exports[`RoomView should not display the timeline when the room encryption is lo
|
||||
aria-label="Open room settings"
|
||||
aria-live="off"
|
||||
class="_avatar_1qbcf_8 mx_BaseAvatar _avatar-imageless_1qbcf_52"
|
||||
data-color="2"
|
||||
data-color="4"
|
||||
data-testid="avatar-img"
|
||||
data-type="round"
|
||||
role="button"
|
||||
@@ -1317,7 +1390,7 @@ exports[`RoomView should not display the timeline when the room encryption is lo
|
||||
<span
|
||||
class="mx_RoomHeader_truncated mx_lineClamp"
|
||||
>
|
||||
!6:example.org
|
||||
!11:example.org
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1498,7 +1571,7 @@ exports[`RoomView should not display the timeline when the room encryption is lo
|
||||
aria-label="Open room settings"
|
||||
aria-live="off"
|
||||
class="_avatar_1qbcf_8 mx_BaseAvatar _avatar-imageless_1qbcf_52"
|
||||
data-color="2"
|
||||
data-color="4"
|
||||
data-testid="avatar-img"
|
||||
data-type="round"
|
||||
role="button"
|
||||
@@ -1525,7 +1598,7 @@ exports[`RoomView should not display the timeline when the room encryption is lo
|
||||
<span
|
||||
class="mx_RoomHeader_truncated mx_lineClamp"
|
||||
>
|
||||
!6:example.org
|
||||
!11:example.org
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1879,7 +1952,7 @@ exports[`RoomView video rooms should render joined video room view 1`] = `
|
||||
aria-label="Open room settings"
|
||||
aria-live="off"
|
||||
class="_avatar_1qbcf_8 mx_BaseAvatar _avatar-imageless_1qbcf_52"
|
||||
data-color="6"
|
||||
data-color="5"
|
||||
data-testid="avatar-img"
|
||||
data-type="round"
|
||||
role="button"
|
||||
@@ -1906,7 +1979,7 @@ exports[`RoomView video rooms should render joined video room view 1`] = `
|
||||
<span
|
||||
class="mx_RoomHeader_truncated mx_lineClamp"
|
||||
>
|
||||
!13:example.org
|
||||
!18:example.org
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user