Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit a8ead86

Browse files
committed
Add, update and remove tests/screenshots/snapshots
1 parent 384723a commit a8ead86

File tree

20 files changed

+259
-196
lines changed

20 files changed

+259
-196
lines changed

playwright/e2e/crypto/crypto.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ const verify = async (page: Page, bob: Bot) => {
103103
const bobsVerificationRequestPromise = waitForVerificationRequest(bob);
104104

105105
const roomInfo = await openRoomInfo(page);
106-
await roomInfo.getByRole("menuitem", { name: "People" }).click();
106+
await page.locator(".mx_RightPanelTabs").getByText("People").click();
107107
await roomInfo.getByText("Bob").click();
108108
await roomInfo.getByRole("button", { name: "Verify" }).click();
109109
await roomInfo.getByRole("button", { name: "Start Verification" }).click();
@@ -279,7 +279,7 @@ test.describe("Cryptography", function () {
279279

280280
// Assert that verified icon is rendered
281281
await page.getByRole("button", { name: "Room members" }).click();
282-
await page.getByRole("button", { name: "Room information" }).click();
282+
await page.locator(".mx_RightPanelTabs").getByText("Info").click();
283283
await expect(page.locator('.mx_RoomSummaryCard_badges [data-kind="success"]')).toContainText("Encrypted");
284284

285285
// Take a snapshot of RoomSummaryCard with a verified E2EE icon

playwright/e2e/crypto/dehydration.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ test.describe("Dehydration", () => {
102102

103103
await viewRoomSummaryByName(page, app, ROOM_NAME);
104104

105-
await page.getByRole("menuitem", { name: "People" }).click();
105+
await page.locator(".mx_RightPanelTabs").getByText("People").click();
106106
await expect(page.locator(".mx_MemberList")).toBeVisible();
107107

108108
await getMemberTileByName(page, NAME).click();

playwright/e2e/lazy-loading/lazy-loading.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ test.describe("Lazy Loading", () => {
8080

8181
async function openMemberlist(page: Page): Promise<void> {
8282
await page.locator(".mx_LegacyRoomHeader").getByRole("button", { name: "Room info" }).click();
83-
await page.locator(".mx_RoomSummaryCard").getByRole("menuitem", { name: "People" }).click(); // \d represents the number of the room members
83+
await page.locator(".mx_RightPanelTabs").getByText("People").click();
8484
}
8585

8686
function getMemberInMemberlist(page: Page, name: string): Locator {

playwright/e2e/read-receipts/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,19 +399,18 @@ class Helpers {
399399
}
400400

401401
/**
402-
* Close the threads panel. (Actually, close any right panel, but for these
403-
* tests we only open the threads panel.)
402+
* Close the threads panel.
404403
*/
405404
async closeThreadsPanel() {
406-
await this.page.locator(".mx_RightPanel").getByLabel("Close").click();
405+
await this.page.locator(".mx_LegacyRoomHeader").getByLabel("Threads").click();
407406
await expect(this.page.locator(".mx_RightPanel")).not.toBeVisible();
408407
}
409408

410409
/**
411410
* Return to the list of threads, given we are viewing a single thread.
412411
*/
413412
async backToThreadsList() {
414-
await this.page.locator(".mx_RightPanel").getByLabel("Threads").click();
413+
await this.page.locator(".mx_LegacyRoomHeader").getByLabel("Threads").click();
415414
}
416415

417416
/**

playwright/e2e/right-panel/right-panel.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ test.describe("RightPanel", () => {
113113
test("should handle viewing room member", async ({ page, app }) => {
114114
await viewRoomSummaryByName(page, app, ROOM_NAME);
115115

116-
await page.getByRole("menuitem", { name: "People" }).click();
116+
await page.locator(".mx_RightPanelTabs").getByText("People").click();
117117
await expect(page.locator(".mx_MemberList")).toBeVisible();
118118

119119
await getMemberTileByName(page, NAME).click();
@@ -123,7 +123,7 @@ test.describe("RightPanel", () => {
123123
await page.getByRole("button", { name: "Room members" }).click();
124124
await expect(page.locator(".mx_MemberList")).toBeVisible();
125125

126-
await page.getByRole("button", { name: "Room information" }).click();
126+
await page.locator(".mx_RightPanelTabs").getByText("Info").click();
127127
await checkRoomSummaryCard(page, ROOM_NAME);
128128
});
129129
});

playwright/e2e/spaces/threads-activity-centre/index.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,10 @@ export class Helpers {
337337
}
338338

339339
/**
340-
* Assert that the thread panel is focused (actually the 'close' button, specifically)
340+
* Assert that the thread tab is focused
341341
*/
342-
assertThreadPanelFocused() {
343-
return expect(
344-
this.page.locator(".mx_ThreadPanel").locator(".mx_BaseCard_header").getByLabel("Close"),
345-
).toBeFocused();
342+
assertThreadTabFocused() {
343+
return expect(this.page.locator("#thread-panel-tab")).toBeFocused();
346344
}
347345

348346
/**

playwright/e2e/spaces/threads-activity-centre/threadsActivityCentre.spec.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,17 +161,12 @@ test.describe("Threads Activity Centre", () => {
161161
await util.assertNoTacIndicator();
162162
});
163163

164-
test("should focus the thread panel close button when clicking an item in the TAC", async ({
165-
room1,
166-
room2,
167-
util,
168-
msg,
169-
}) => {
164+
test("should focus the thread tab when clicking an item in the TAC", async ({ room1, room2, util, msg }) => {
170165
await util.receiveMessages(room1, ["Msg1", msg.threadedOff("Msg1", "Resp1")]);
171166

172167
await util.openTac();
173168
await util.clickRoomInTac(room1.name);
174169

175-
await util.assertThreadPanelFocused();
170+
await util.assertThreadTabFocused();
176171
});
177172
});
Loading
Loading
Loading
Loading

test/components/structures/ThreadPanel-test.tsx

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ import ResizeNotifier from "../../../src/utils/ResizeNotifier";
3636
import { createTestClient, getRoomContext, mkRoom, mockPlatformPeg, stubClient } from "../../test-utils";
3737
import { mkThread } from "../../test-utils/threads";
3838
import { IRoomState } from "../../../src/components/structures/RoomView";
39-
import defaultDispatcher from "../../../src/dispatcher/dispatcher";
40-
import { Action } from "../../../src/dispatcher/actions";
4139

4240
jest.mock("../../../src/utils/Feedback");
4341

@@ -148,43 +146,6 @@ describe("ThreadPanel", () => {
148146
fireEvent.click(getByRole(container, "button", { name: "Mark all as read" }));
149147
await waitFor(() => expect(mockClient.sendReadReceipt).not.toHaveBeenCalled());
150148
});
151-
152-
it("focuses the close button on FocusThreadsPanel dispatch", () => {
153-
const ROOM_ID = "!roomId:example.org";
154-
155-
stubClient();
156-
mockPlatformPeg();
157-
const mockClient = mocked(MatrixClientPeg.safeGet());
158-
159-
const room = new Room(ROOM_ID, mockClient, mockClient.getUserId() ?? "", {
160-
pendingEventOrdering: PendingEventOrdering.Detached,
161-
});
162-
163-
render(
164-
<MatrixClientContext.Provider value={mockClient}>
165-
<RoomContext.Provider
166-
value={getRoomContext(room, {
167-
canSendMessages: true,
168-
})}
169-
>
170-
<ThreadPanel
171-
roomId={ROOM_ID}
172-
onClose={jest.fn()}
173-
resizeNotifier={new ResizeNotifier()}
174-
permalinkCreator={new RoomPermalinkCreator(room)}
175-
/>
176-
</RoomContext.Provider>
177-
</MatrixClientContext.Provider>,
178-
);
179-
180-
// Unfocus it first so we know it's not just focused by coincidence
181-
screen.getByTestId("base-card-close-button").blur();
182-
expect(screen.getByTestId("base-card-close-button")).not.toHaveFocus();
183-
184-
defaultDispatcher.dispatch({ action: Action.FocusThreadsPanel }, true);
185-
186-
expect(screen.getByTestId("base-card-close-button")).toHaveFocus();
187-
});
188149
});
189150

190151
describe("Filtering", () => {
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
Copyright 2024 The Matrix.org Foundation C.I.C.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
import React from "react";
18+
import { render, fireEvent } from "@testing-library/react";
19+
20+
import dis from "../../../../src/dispatcher/dispatcher";
21+
import RightPanelStore from "../../../../src/stores/right-panel/RightPanelStore";
22+
import { RightPanelPhases } from "../../../../src/stores/right-panel/RightPanelStorePhases";
23+
import { RightPanelTabs } from "../../../../src/components/views/right_panel/RightPanelTabs";
24+
import { Action } from "../../../../src/dispatcher/actions";
25+
26+
describe("<RightPanelTabs />", () => {
27+
it("Component renders the correct tabs", () => {
28+
const { container, getByRole } = render(<RightPanelTabs phase={RightPanelPhases.RoomSummary} />);
29+
expect(container).toMatchSnapshot();
30+
31+
// We expect Info, People and Threads as tabs
32+
expect(getByRole("tab", { name: "Info" })).toBeDefined();
33+
expect(getByRole("tab", { name: "People" })).toBeDefined();
34+
expect(getByRole("tab", { name: "Threads" })).toBeDefined();
35+
});
36+
37+
it("Correct tab is active", () => {
38+
const { container } = render(<RightPanelTabs phase={RightPanelPhases.RoomMemberList} />);
39+
expect(container).toMatchSnapshot();
40+
// Assert that the active tab is Info
41+
expect(container.querySelectorAll("[aria-selected='true'").length).toEqual(1);
42+
expect(container.querySelector("[aria-selected='true'")).toHaveAccessibleName("People");
43+
});
44+
45+
it("Renders nothing for some phases, eg: FilePanel", () => {
46+
const { container } = render(<RightPanelTabs phase={RightPanelPhases.FilePanel} />);
47+
expect(container).toBeEmptyDOMElement();
48+
});
49+
50+
it("onClick behaviors work as expected", () => {
51+
const spy = jest.spyOn(RightPanelStore.instance, "pushCard");
52+
const { getByRole } = render(<RightPanelTabs phase={RightPanelPhases.RoomSummary} />);
53+
54+
// Info -> People
55+
fireEvent.click(getByRole("tab", { name: "People" }));
56+
expect(spy).toHaveBeenLastCalledWith({ phase: RightPanelPhases.RoomMemberList }, true);
57+
58+
// People -> Threads
59+
fireEvent.click(getByRole("tab", { name: "Threads" }));
60+
expect(spy).toHaveBeenLastCalledWith({ phase: RightPanelPhases.ThreadPanel }, true);
61+
62+
// Threads -> Info
63+
fireEvent.click(getByRole("tab", { name: "Info" }));
64+
expect(spy).toHaveBeenLastCalledWith({ phase: RightPanelPhases.RoomSummary }, true);
65+
});
66+
67+
it("Threads tab is focused on action", () => {
68+
const { getByRole } = render(<RightPanelTabs phase={RightPanelPhases.ThreadPanel} />);
69+
dis.dispatch({ action: Action.FocusThreadsPanel }, true);
70+
expect(getByRole("tab", { name: "Threads" })).toHaveFocus();
71+
});
72+
});

test/components/views/right_panel/RoomSummaryCard-test.tsx

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import { flushPromises, getMockClientWithEventEmitter, mockClientMethodsUser } f
3535
import { PollHistoryDialog } from "../../../../src/components/views/dialogs/PollHistoryDialog";
3636
import { RoomPermalinkCreator } from "../../../../src/utils/permalinks/Permalinks";
3737
import { _t } from "../../../../src/languageHandler";
38-
import SettingsStore from "../../../../src/settings/SettingsStore";
3938
import { tagRoom } from "../../../../src/utils/room/tagRoom";
4039
import { DefaultTagID } from "../../../../src/stores/room-list/models";
4140
import { Action } from "../../../../src/dispatcher/actions";
@@ -195,7 +194,6 @@ describe("<RoomSummaryCard />", () => {
195194
<RoomSummaryCard
196195
room={room}
197196
permalinkCreator={new RoomPermalinkCreator(room)}
198-
onClose={jest.fn()}
199197
onSearchChange={onSearchChange}
200198
focusRoomSearch={true}
201199
/>
@@ -212,7 +210,6 @@ describe("<RoomSummaryCard />", () => {
212210
<RoomSummaryCard
213211
room={room}
214212
permalinkCreator={new RoomPermalinkCreator(room)}
215-
onClose={jest.fn()}
216213
onSearchChange={onSearchChange}
217214
/>
218215
</RoomContext.Provider>
@@ -270,18 +267,6 @@ describe("<RoomSummaryCard />", () => {
270267
expect(defaultDispatcher.dispatch).toHaveBeenCalledWith({ action: "open_room_settings" });
271268
});
272269

273-
it("renders room members options when new room UI is not enabled", () => {
274-
jest.spyOn(SettingsStore, "getValue").mockReturnValue(false);
275-
const { getByText } = getComponent();
276-
277-
fireEvent.click(getByText(_t("common|people")));
278-
279-
expect(RightPanelStore.instance.pushCard).toHaveBeenCalledWith(
280-
{ phase: RightPanelPhases.RoomMemberList },
281-
true,
282-
);
283-
});
284-
285270
describe("pinning", () => {
286271
it("renders pins options when pinning feature is enabled", () => {
287272
mocked(settingsHooks.useFeatureEnabled).mockImplementation((feature) => feature === "feature_pinning");

0 commit comments

Comments
 (0)