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

Commit bb1b7f1

Browse files
Default the room header to on (#12803)
* Default the room header to on * Refactor code into helper method Add a method to open/close the room info panel and use it everywhere. * Fix broken tests, update snapshots and screenshots * Update room header tests to make sense with the new header
1 parent 25fcd6a commit bb1b7f1

File tree

59 files changed

+591
-393
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+591
-393
lines changed

playwright/e2e/app-loading/stored-credentials.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ test("Shows the last known page on reload", async ({ pageWithCredentials: page }
4848

4949
// Check that the room reloaded
5050
await expect(page).toHaveURL(/\/#\/room\//);
51-
await expect(page.locator(".mx_LegacyRoomHeader")).toContainText("Test Room");
51+
await expect(page.locator(".mx_RoomHeader")).toContainText("Test Room");
5252
});
5353

5454
test("Room link correctly loads a room view", async ({ pageWithCredentials: page }) => {

playwright/e2e/chat-export/html-export.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ test.describe("HTML Export", () => {
108108
page.locator(".mx_EventTile_last .mx_MTextBody .mx_EventTile_body").getByText("Testing 9"),
109109
).toBeVisible();
110110

111-
await page.getByRole("button", { name: "Room info" }).click();
111+
await app.toggleRoomInfoPanel();
112112
await page.getByRole("menuitem", { name: "Export Chat" }).click();
113113

114114
const downloadPromise = page.waitForEvent("download");

playwright/e2e/create-room/create-room.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ test.describe("Create Room", () => {
3636
await dialog.getByRole("button", { name: "Create room" }).click();
3737

3838
await expect(page).toHaveURL(/\/#\/room\/#test-room-1:localhost/);
39-
const header = page.locator(".mx_LegacyRoomHeader");
39+
const header = page.locator(".mx_RoomHeader");
4040
await expect(header).toContainText(name);
4141
await expect(header).toContainText(topic);
4242
});

playwright/e2e/crypto/crypto.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ test.describe("Cryptography", function () {
224224
await checkDMRoom(page);
225225
const bobRoomId = await bobJoin(page, bob);
226226
await testMessages(page, bob, bobRoomId);
227-
await verify(page, bob);
227+
await verify(app, bob);
228228

229229
// Assert that verified icon is rendered
230230
await page.getByTestId("base-card-back-button").click();
@@ -246,6 +246,6 @@ test.describe("Cryptography", function () {
246246

247247
// we need to have a room with the other user present, so we can open the verification panel
248248
await createSharedRoomWithUser(app, bob.credentials.userId);
249-
await verify(page, bob);
249+
await verify(app, bob);
250250
});
251251
});

playwright/e2e/crypto/event-shields.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ test.describe("Cryptography", function () {
104104
await expect(lastTileE2eIcon).not.toBeVisible();
105105

106106
/* Now verify Bob */
107-
await verify(page, bob);
107+
await verify(app, bob);
108108

109109
/* Existing message should be updated when user is verified. */
110110
await expect(last).toContainText("test encrypted 1");
@@ -222,7 +222,7 @@ test.describe("Cryptography", function () {
222222
await bobSecondDevice.prepareClient();
223223

224224
// verify Bob
225-
await verify(page, bob);
225+
await verify(app, bob);
226226

227227
// bob sends a valid event
228228
const testEvent = await bob.sendMessage(testRoomId, "Hoo!");

playwright/e2e/crypto/utils.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -329,15 +329,6 @@ export async function createRoom(page: Page, roomName: string, isEncrypted: bool
329329
}
330330
}
331331

332-
/**
333-
* Open the room info panel and return the panel element
334-
* @param page - the page to use
335-
*/
336-
export const openRoomInfo = async (page: Page) => {
337-
await page.getByRole("button", { name: "Room info" }).click();
338-
return page.locator(".mx_RightPanel");
339-
};
340-
341332
/**
342333
* Configure the given MatrixClient to auto-accept any invites
343334
* @param client - the client to configure
@@ -357,10 +348,11 @@ export async function autoJoin(client: Client) {
357348
* @param page - the page to use
358349
* @param bob - the user to verify
359350
*/
360-
export const verify = async (page: Page, bob: Bot) => {
351+
export const verify = async (app: ElementAppPage, bob: Bot) => {
352+
const page = app.page;
361353
const bobsVerificationRequestPromise = waitForVerificationRequest(bob);
362354

363-
const roomInfo = await openRoomInfo(page);
355+
const roomInfo = await app.toggleRoomInfoPanel();
364356
await page.locator(".mx_RightPanelTabs").getByText("People").click();
365357
await roomInfo.getByText("Bob").click();
366358
await roomInfo.getByRole("button", { name: "Verify" }).click();

playwright/e2e/file-upload/image-upload.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ test.describe("Image Upload", () => {
3838
.locator(".mx_MessageComposer_actions input[type='file']")
3939
.setInputFiles("playwright/sample-files/riot.png");
4040

41-
expect(page.getByRole("button", { name: "Upload" })).toBeEnabled();
42-
expect(page.getByRole("button", { name: "Close dialog" })).toBeEnabled();
43-
expect(page).toMatchScreenshot("image-upload-preview.png");
41+
await expect(page.getByRole("button", { name: "Upload" })).toBeEnabled();
42+
await expect(page.getByRole("button", { name: "Close dialog" })).toBeEnabled();
43+
await expect(page).toMatchScreenshot("image-upload-preview.png");
4444
});
4545
});

playwright/e2e/integration-manager/get-openid-token.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ test.describe("Integration Manager: Get OpenID Token", () => {
118118
await app.viewRoomByName(ROOM_NAME);
119119
});
120120

121-
test("should successfully obtain an openID token", async ({ page }) => {
122-
await openIntegrationManager(page);
121+
test("should successfully obtain an openID token", async ({ page, app }) => {
122+
await openIntegrationManager(app);
123123
await sendActionFromIntegrationManager(page, integrationManagerUrl);
124124

125125
const iframe = page.frameLocator(`iframe[src*="${integrationManagerUrl}"]`);

playwright/e2e/integration-manager/kick.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ test.describe("Integration Manager: Kick", () => {
167167
await app.client.inviteUser(room.roomId, targetUser.credentials.userId);
168168
await expect(page.getByText(`${BOT_DISPLAY_NAME} joined the room`)).toBeVisible();
169169

170-
await openIntegrationManager(page);
170+
await openIntegrationManager(app);
171171
await sendActionFromIntegrationManager(page, integrationManagerUrl, room.roomId, targetUser.credentials.userId);
172172
await closeIntegrationManager(page, integrationManagerUrl);
173173
await expectKickedMessage(page, true);
@@ -185,7 +185,7 @@ test.describe("Integration Manager: Kick", () => {
185185
},
186186
});
187187

188-
await openIntegrationManager(page);
188+
await openIntegrationManager(app);
189189
await sendActionFromIntegrationManager(page, integrationManagerUrl, room.roomId, targetUser.credentials.userId);
190190
await closeIntegrationManager(page, integrationManagerUrl);
191191
await expectKickedMessage(page, false);
@@ -197,7 +197,7 @@ test.describe("Integration Manager: Kick", () => {
197197
await expect(page.getByText(`${BOT_DISPLAY_NAME} joined the room`)).toBeVisible();
198198
await targetUser.leave(room.roomId);
199199

200-
await openIntegrationManager(page);
200+
await openIntegrationManager(app);
201201
await sendActionFromIntegrationManager(page, integrationManagerUrl, room.roomId, targetUser.credentials.userId);
202202
await closeIntegrationManager(page, integrationManagerUrl);
203203
await expectKickedMessage(page, false);
@@ -209,7 +209,7 @@ test.describe("Integration Manager: Kick", () => {
209209
await expect(page.getByText(`${BOT_DISPLAY_NAME} joined the room`)).toBeVisible();
210210
await app.client.ban(room.roomId, targetUser.credentials.userId);
211211

212-
await openIntegrationManager(page);
212+
await openIntegrationManager(app);
213213
await sendActionFromIntegrationManager(page, integrationManagerUrl, room.roomId, targetUser.credentials.userId);
214214
await closeIntegrationManager(page, integrationManagerUrl);
215215
await expectKickedMessage(page, false);
@@ -218,7 +218,7 @@ test.describe("Integration Manager: Kick", () => {
218218
test("should no-op if the target was never a room member", async ({ page, app, bot: targetUser, room }) => {
219219
await app.viewRoomByName(ROOM_NAME);
220220

221-
await openIntegrationManager(page);
221+
await openIntegrationManager(app);
222222
await sendActionFromIntegrationManager(page, integrationManagerUrl, room.roomId, targetUser.credentials.userId);
223223
await closeIntegrationManager(page, integrationManagerUrl);
224224
await expectKickedMessage(page, false);

playwright/e2e/integration-manager/read_events.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ test.describe("Integration Manager: Read Events", () => {
142142

143143
// Send a state event
144144
const sendEventResponse = await app.client.sendStateEvent(room.roomId, eventType, eventContent, stateKey);
145-
await openIntegrationManager(page);
145+
await openIntegrationManager(app);
146146

147147
// Read state events
148148
await sendActionFromIntegrationManager(page, integrationManagerUrl, room.roomId, eventType, stateKey);
@@ -162,7 +162,7 @@ test.describe("Integration Manager: Read Events", () => {
162162

163163
// Send a state event
164164
const sendEventResponse = await app.client.sendStateEvent(room.roomId, eventType, eventContent, stateKey);
165-
await openIntegrationManager(page);
165+
await openIntegrationManager(app);
166166

167167
// Read state events
168168
await sendActionFromIntegrationManager(page, integrationManagerUrl, room.roomId, eventType, stateKey);
@@ -196,7 +196,7 @@ test.describe("Integration Manager: Read Events", () => {
196196
app.client.sendStateEvent(room.roomId, eventType, eventContent3, stateKey3),
197197
]);
198198

199-
await openIntegrationManager(page);
199+
await openIntegrationManager(app);
200200

201201
// Read state events
202202
await sendActionFromIntegrationManager(
@@ -217,11 +217,11 @@ test.describe("Integration Manager: Read Events", () => {
217217
await expect(iframe.locator("#message-response")).toContainText(`"content":${JSON.stringify(eventContent3)}`);
218218
});
219219

220-
test("should fail to read an event type which is not allowed", async ({ page, room }) => {
220+
test("should fail to read an event type which is not allowed", async ({ page, app, room }) => {
221221
const eventType = "com.example.event";
222222
const stateKey = "";
223223

224-
await openIntegrationManager(page);
224+
await openIntegrationManager(app);
225225

226226
// Read state events
227227
await sendActionFromIntegrationManager(page, integrationManagerUrl, room.roomId, eventType, stateKey);

playwright/e2e/integration-manager/send_event.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ test.describe("Integration Manager: Send Event", () => {
137137
);
138138

139139
await app.viewRoomByName(ROOM_NAME);
140-
await openIntegrationManager(page);
140+
await openIntegrationManager(app);
141141
});
142142

143143
test("should send a state event", async ({ page, app, room }) => {

playwright/e2e/integration-manager/utils.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import type { Page } from "@playwright/test";
17+
import type { ElementAppPage } from "../../pages/ElementAppPage";
1818

19-
export async function openIntegrationManager(page: Page) {
20-
await page.getByRole("button", { name: "Room info" }).click();
19+
export async function openIntegrationManager(app: ElementAppPage) {
20+
const { page } = app;
21+
await app.toggleRoomInfoPanel();
2122
await page
2223
.locator(".mx_RoomSummaryCard_appsGroup")
2324
.getByRole("button", { name: "Add widgets, bridges & bots" })

playwright/e2e/invite/invite-dialog.spec.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ test.describe("Invite dialog", function () {
3636
await expect(page.getByText("Hanako created and configured the room.")).toBeVisible();
3737

3838
// Open the room info panel
39-
await page.getByRole("button", { name: "Room info" }).click();
39+
await app.toggleRoomInfoPanel();
4040

4141
await page.locator(".mx_BaseCard").getByRole("menuitem", { name: "Invite" }).click();
4242

@@ -114,12 +114,9 @@ test.describe("Invite dialog", function () {
114114

115115
// Assert that the hovered user name on invitation UI does not have background color
116116
// TODO: implement the test on room-header.spec.ts
117-
const roomHeader = page.locator(".mx_LegacyRoomHeader");
118-
await roomHeader.locator(".mx_LegacyRoomHeader_name--textonly").hover();
119-
await expect(roomHeader.locator(".mx_LegacyRoomHeader_name--textonly")).toHaveCSS(
120-
"background-color",
121-
"rgba(0, 0, 0, 0)",
122-
);
117+
const roomHeader = page.locator(".mx_RoomHeader");
118+
await roomHeader.locator(".mx_RoomHeader_heading").hover();
119+
await expect(roomHeader.locator(".mx_RoomHeader_heading")).toHaveCSS("background-color", "rgba(0, 0, 0, 0)");
123120

124121
// Send a message to invite the bots
125122
const composer = app.getComposer().locator("[contenteditable]");

playwright/e2e/knock/create-knock-room.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ test.describe("Create Knock Room", () => {
3131
await dialog.getByRole("option", { name: "Ask to join" }).click();
3232
await dialog.getByRole("button", { name: "Create room" }).click();
3333

34-
await expect(page.locator(".mx_LegacyRoomHeader").getByText("Cybersecurity")).toBeVisible();
34+
await expect(page.locator(".mx_RoomHeader").getByText("Cybersecurity")).toBeVisible();
3535

3636
const urlHash = await page.evaluate(() => window.location.hash);
3737
const roomId = urlHash.replace("#/room/", "");
@@ -48,7 +48,7 @@ test.describe("Create Knock Room", () => {
4848
await dialog.getByRole("textbox", { name: "Name" }).fill("Cybersecurity");
4949
await dialog.getByRole("button", { name: "Create room" }).click();
5050

51-
await expect(page.locator(".mx_LegacyRoomHeader").getByText("Cybersecurity")).toBeVisible();
51+
await expect(page.locator(".mx_RoomHeader").getByText("Cybersecurity")).toBeVisible();
5252

5353
const urlHash = await page.evaluate(() => window.location.hash);
5454
const roomId = urlHash.replace("#/room/", "");
@@ -74,7 +74,7 @@ test.describe("Create Knock Room", () => {
7474
await dialog.getByText("Make this room visible in the public room directory.").click();
7575
await dialog.getByRole("button", { name: "Create room" }).click();
7676

77-
await expect(page.locator(".mx_LegacyRoomHeader").getByText("Cybersecurity")).toBeVisible();
77+
await expect(page.locator(".mx_RoomHeader").getByText("Cybersecurity")).toBeVisible();
7878

7979
const urlHash = await page.evaluate(() => window.location.hash);
8080
const roomId = urlHash.replace("#/room/", "");

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ test.describe("Lazy Loading", () => {
7878
}
7979
}
8080

81-
async function openMemberlist(page: Page): Promise<void> {
82-
await page.locator(".mx_LegacyRoomHeader").getByRole("button", { name: "Room info" }).click();
81+
async function openMemberlist(app: ElementAppPage): Promise<void> {
82+
await app.toggleRoomInfoPanel();
83+
const { page } = app;
8384
await page.locator(".mx_RightPanelTabs").getByText("People").click();
8485
}
8586

@@ -123,7 +124,7 @@ test.describe("Lazy Loading", () => {
123124
// Alice should see 2 messages from every charly with the correct display name
124125
await checkPaginatedDisplayNames(app, charly1to5);
125126

126-
await openMemberlist(page);
127+
await openMemberlist(app);
127128
await checkMemberList(page, charly1to5);
128129
await joinCharliesWhileAliceIsOffline(page, app, charly6to10);
129130
await checkMemberList(page, charly6to10);

playwright/e2e/one-to-one-chat/one-to-one-chat.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ test.describe("1:1 chat room", () => {
3535
await page.goto(`/#/user/${user2.userId}?action=chat`);
3636
});
3737

38-
test("should open new 1:1 chat room after leaving the old one", async ({ page, user2 }) => {
38+
test("should open new 1:1 chat room after leaving the old one", async ({ page, app, user2 }) => {
3939
// leave 1:1 chat room
40-
await page.locator(".mx_LegacyRoomHeader_nametext").getByText(user2.displayName).click();
41-
await page.getByRole("menuitem", { name: "Leave" }).click();
40+
await app.toggleRoomInfoPanel();
41+
await page.getByRole("menuitem", { name: "Leave room" }).click();
4242
await page.getByRole("button", { name: "Leave" }).click();
4343

4444
// wait till the room was left
@@ -49,6 +49,6 @@ test.describe("1:1 chat room", () => {
4949

5050
// open new 1:1 chat room
5151
await page.goto(`/#/user/${user2.userId}?action=chat`);
52-
await expect(page.locator(".mx_LegacyRoomHeader_nametext").getByText(user2.displayName)).toBeVisible();
52+
await expect(page.locator(".mx_RoomHeader_heading").getByText(user2.displayName)).toBeVisible();
5353
});
5454
});

playwright/e2e/polls/pollHistory.spec.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616
import { test, expect } from "../../element-web-test";
17-
import type { Page } from "@playwright/test";
1817
import type { Bot } from "../../pages/bot";
1918
import type { Client } from "../../pages/client";
19+
import { ElementAppPage } from "../../pages/ElementAppPage";
2020

2121
test.describe("Poll history", () => {
2222
type CreatePollOptions = {
@@ -66,8 +66,9 @@ test.describe("Poll history", () => {
6666
});
6767
};
6868

69-
async function openPollHistory(page: Page): Promise<void> {
70-
await page.getByRole("button", { name: "Room info" }).click();
69+
async function openPollHistory(app: ElementAppPage): Promise<void> {
70+
const { page } = app;
71+
await app.toggleRoomInfoPanel();
7172
await page.locator(".mx_RoomSummaryCard").getByRole("menuitem", { name: "Poll history" }).click();
7273
}
7374

@@ -116,7 +117,7 @@ test.describe("Poll history", () => {
116117
await botVoteForOption(bot, roomId, pollId2, pollParams1.options[1].id);
117118
await endPoll(bot, roomId, pollId2);
118119

119-
await openPollHistory(page);
120+
await openPollHistory(app);
120121

121122
// these polls are also in the timeline
122123
// focus on the poll history dialog

playwright/e2e/presence/presence.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ test.describe("Presence tests", () => {
5959
);
6060
await app.client.createRoom({}); // trigger sync
6161

62-
await page.getByRole("button", { name: "Room info" }).click();
62+
await app.toggleRoomInfoPanel();
6363
await page.locator(".mx_RightPanel").getByText("People").click();
6464
await expect(page.locator(".mx_EntityTile_unreachable")).toContainText("Bob");
6565
await expect(page.locator(".mx_EntityTile_unreachable")).toContainText("User's server unreachable");

playwright/e2e/read-receipts/index.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -402,15 +402,15 @@ class Helpers {
402402
* Close the threads panel.
403403
*/
404404
async closeThreadsPanel() {
405-
await this.page.locator(".mx_LegacyRoomHeader").getByLabel("Threads").click();
405+
await this.page.locator(".mx_RoomHeader").getByLabel("Threads").click();
406406
await expect(this.page.locator(".mx_RightPanel")).not.toBeVisible();
407407
}
408408

409409
/**
410410
* Return to the list of threads, given we are viewing a single thread.
411411
*/
412412
async backToThreadsList() {
413-
await this.page.locator(".mx_LegacyRoomHeader").getByLabel("Threads").click();
413+
await this.page.locator(".mx_RoomHeader").getByLabel("Threads").click();
414414
}
415415

416416
/**
@@ -530,12 +530,11 @@ class Helpers {
530530
// whether it's open or not - wait here to give it a chance to settle.
531531
await this.page.waitForTimeout(200);
532532

533-
const ariaCurrent = await this.page.getByTestId("threadsButton").getAttribute("aria-current");
534-
if (ariaCurrent !== "true") {
535-
await this.page.getByTestId("threadsButton").click();
536-
}
537-
538533
const threadPanel = this.page.locator(".mx_ThreadPanel");
534+
const isThreadPanelOpen = (await threadPanel.count()) !== 0;
535+
if (!isThreadPanelOpen) {
536+
await this.page.locator(".mx_RoomHeader").getByLabel("Threads").click();
537+
}
539538
await expect(threadPanel).toBeVisible();
540539
await threadPanel.evaluate(($panel) => {
541540
const $button = $panel.querySelector<HTMLElement>('[data-testid="base-card-back-button"]');

0 commit comments

Comments
 (0)