Skip to content

Commit 59df028

Browse files
committed
Cleanup tests
prettier Updates some more playwright tests Update more snapshots Update switch more fixes drop .only last screenshot round fix video room flake Remove console.logs Remove roomId from devtools view. lint final screenshot
1 parent 79ab399 commit 59df028

File tree

34 files changed

+128
-132
lines changed

34 files changed

+128
-132
lines changed

playwright/e2e/crypto/toasts.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ test.describe("'Turn on key storage' toast", () => {
126126
await toast.getByRole("button", { name: "Continue" }).click();
127127

128128
// Then we see the Encryption settings dialog with an option to turn on key storage
129-
await expect(page.getByRole("checkbox", { name: "Allow key storage" })).toBeVisible();
129+
await expect(page.getByRole("switch", { name: "Allow key storage" })).toBeVisible();
130130

131131
// And when we close that
132132
await page.getByRole("button", { name: "Close dialog" }).click();
@@ -153,7 +153,7 @@ test.describe("'Turn on key storage' toast", () => {
153153
await page.getByRole("button", { name: "Go to Settings" }).click();
154154

155155
// Then we see Encryption settings again
156-
await expect(page.getByRole("checkbox", { name: "Allow key storage" })).toBeVisible();
156+
await expect(page.getByRole("switch", { name: "Allow key storage" })).toBeVisible();
157157

158158
// And when we close that, see the toast, click Dismiss, and Yes, Dismiss
159159
await page.getByRole("button", { name: "Close dialog" }).click();

playwright/e2e/crypto/utils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,9 @@ export async function doTwoWaySasVerification(page: Page, verifier: JSHandle<Ver
300300
export async function enableKeyBackup(app: ElementAppPage): Promise<string> {
301301
const encryptionTab = await app.settings.openUserSettings("Encryption");
302302

303-
const keyStorageToggle = encryptionTab.getByRole("checkbox", { name: "Allow key storage" });
303+
const keyStorageToggle = encryptionTab.getByRole("switch", { name: "Allow key storage" });
304304
if (!(await keyStorageToggle.isChecked())) {
305-
await encryptionTab.getByRole("checkbox", { name: "Allow key storage" }).click();
305+
await encryptionTab.getByRole("switch", { name: "Allow key storage" }).click();
306306
}
307307

308308
await encryptionTab.getByRole("button", { name: "Set up recovery" }).click();
@@ -323,11 +323,11 @@ export async function enableKeyBackup(app: ElementAppPage): Promise<string> {
323323
export async function disableKeyBackup(app: ElementAppPage): Promise<void> {
324324
const encryptionTab = await app.settings.openUserSettings("Encryption");
325325

326-
const keyStorageToggle = encryptionTab.getByRole("checkbox", { name: "Allow key storage" });
326+
const keyStorageToggle = encryptionTab.getByRole("switch", { name: "Allow key storage" });
327327
if (await keyStorageToggle.isChecked()) {
328-
await encryptionTab.getByRole("checkbox", { name: "Allow key storage" }).click();
328+
await encryptionTab.getByRole("switch", { name: "Allow key storage" }).click();
329329
await encryptionTab.getByRole("button", { name: "Delete key storage" }).click();
330-
await encryptionTab.getByRole("checkbox", { name: "Allow key storage" }).isVisible();
330+
await encryptionTab.getByRole("switch", { name: "Allow key storage" }).isVisible();
331331

332332
// Wait for the update to account data to stick
333333
await new Promise((resolve) => setTimeout(resolve, 2000));

playwright/e2e/devtools/devtools.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ test.describe("Devtools", () => {
2222
const dialog = page.locator(".mx_Dialog");
2323
await dialog.getByLabel("Developer mode").check();
2424

25-
await expect(dialog).toMatchScreenshot("devtools-dialog.png");
25+
await expect(dialog).toMatchScreenshot("devtools-dialog.png", {
26+
css: `.mx_CopyableText {
27+
display: none;
28+
}`,
29+
});
2630
});
2731
});

playwright/e2e/left-panel/room-list-panel/room-list.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,9 @@ test.describe("Room list", () => {
402402
await app.settings.closeDialog();
403403

404404
await app.settings.openUserSettings("Notifications");
405-
await page.getByText("Show all activity in the room list (dots or number of unread messages)").click();
405+
await page
406+
.getByRole("switch", { name: "Show all activity in the room list (dots or number of unread messages)" })
407+
.check();
406408
await app.settings.closeDialog();
407409

408410
// Switch to the other room to avoid the notification to be cleared

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,11 @@ test.describe("Room Directory", () => {
3838
// Publish into the public rooms directory
3939
const publishedAddresses = page.locator(".mx_SettingsFieldset", { hasText: "Published Addresses" });
4040
await expect(publishedAddresses.locator("#canonicalAlias")).toHaveValue(`#gaming:${user.homeServer}`);
41-
const checkbox = publishedAddresses
42-
.locator(".mx_SettingsFlag", {
43-
hasText: `Publish this room to the public in ${user.homeServer}'s room directory?`,
44-
})
45-
.getByRole("switch");
46-
await checkbox.check();
41+
const checkbox = publishedAddresses.getByRole("switch", {
42+
name: `Publish this room to the public in ${user.homeServer}'s room directory?`,
43+
});
44+
// .click() rather than .check() as checking happens after publish
45+
await checkbox.click();
4746
await expect(checkbox).toBeChecked();
4847

4948
await app.closeDialog();

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ test.describe("Create Room", () => {
2626
await dialog.getByRole("button", { name: "Room visibility" }).click();
2727
await dialog.getByRole("option", { name: "Public room" }).click();
2828
// Fill room address
29-
await dialog.getByRole("textbox", { name: "Room address" }).fill("test-room-1");
29+
await dialog.getByRole("textbox", { name: "Room address" }).fill("test-create-room-standard");
3030
// Snapshot it
3131
await expect(dialog).toMatchScreenshot("create-room.png");
3232

3333
// Submit
3434
await dialog.getByRole("button", { name: "Create room" }).click();
3535

36-
await expect(page).toHaveURL(new RegExp(`/#/room/#test-room-1:${user.homeServer}`));
36+
await expect(page).toHaveURL(new RegExp(`/#/room/#test-create-room-standard:${user.homeServer}`));
3737
const header = page.locator(".mx_RoomHeader");
3838
await expect(header).toContainText(name);
3939
},
@@ -50,14 +50,14 @@ test.describe("Create Room", () => {
5050
await dialog.getByRole("button", { name: "Room visibility" }).click();
5151
await dialog.getByRole("option", { name: "Public room" }).click();
5252
// Fill room address
53-
await dialog.getByRole("textbox", { name: "Room address" }).fill("test-room-1");
53+
await dialog.getByRole("textbox", { name: "Room address" }).fill("test-create-room-video");
5454
// Snapshot it
5555
await expect(dialog).toMatchScreenshot("create-video-room.png");
5656

5757
// Submit
5858
await dialog.getByRole("button", { name: "Create video room" }).click();
5959

60-
await expect(page).toHaveURL(new RegExp(`/#/room/#test-room-1:${user.homeServer}`));
60+
await expect(page).toHaveURL(new RegExp(`/#/room/#test-create-room-video:${user.homeServer}`));
6161
const header = page.locator(".mx_RoomHeader");
6262
await expect(header).toContainText(name);
6363
});

playwright/e2e/settings/appearance-user-settings-tab/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ class Helpers {
8484
/**
8585
* Return the system theme toggle
8686
*/
87-
getMatchSystemThemeCheckbox() {
88-
return this.getThemePanel().getByRole("checkbox", { name: "Match system theme" });
87+
getMatchSystemThemeSwitch() {
88+
return this.getThemePanel().getByRole("switch", { name: "Match system theme" });
8989
}
9090

9191
/**
@@ -216,10 +216,10 @@ class Helpers {
216216
}
217217

218218
/**
219-
* Return the compact layout checkbox
219+
* Return the compact layout switch
220220
*/
221-
getCompactLayoutCheckbox() {
222-
return this.getMessageLayoutPanel().getByRole("checkbox", { name: "Show compact text and messages" });
221+
getCompactLayoutSwitch() {
222+
return this.getMessageLayoutPanel().getByRole("switch", { name: "Show compact text and messages" });
223223
}
224224

225225
/**

playwright/e2e/settings/appearance-user-settings-tab/message-layout-panel.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ test.describe("Appearance user settings tab", () => {
4040
);
4141

4242
test("should enable compact layout when the modern layout is selected", async ({ page, app, user, util }) => {
43-
await expect(util.getCompactLayoutCheckbox()).not.toBeChecked();
43+
await expect(util.getCompactLayoutSwitch()).not.toBeChecked();
4444

45-
await util.getCompactLayoutCheckbox().click();
45+
await util.getCompactLayoutSwitch().click();
4646
await util.assertCompactLayout();
4747
});
4848

@@ -52,11 +52,11 @@ test.describe("Appearance user settings tab", () => {
5252
user,
5353
util,
5454
}) => {
55-
await expect(util.getCompactLayoutCheckbox()).not.toBeDisabled();
55+
await expect(util.getCompactLayoutSwitch()).not.toBeDisabled();
5656

5757
// Select the bubble layout, which should disable the compact layout checkbox
5858
await util.getBubbleLayout().click();
59-
await expect(util.getCompactLayoutCheckbox()).toBeDisabled();
59+
await expect(util.getCompactLayoutSwitch()).toBeDisabled();
6060
});
6161
});
6262
});

playwright/e2e/settings/appearance-user-settings-tab/theme-choice-panel.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ test.describe("Appearance user settings tab", () => {
2525
{ tag: "@screenshot" },
2626
async ({ page, app, util }) => {
2727
// Assert that 'Match system theme' is not checked
28-
await expect(util.getMatchSystemThemeCheckbox()).not.toBeChecked();
28+
await expect(util.getMatchSystemThemeSwitch()).not.toBeChecked();
2929

3030
// Assert that the light theme is selected
3131
await expect(util.getLightTheme()).toBeChecked();
@@ -41,7 +41,7 @@ test.describe("Appearance user settings tab", () => {
4141
"should disable the themes when the system theme is clicked",
4242
{ tag: "@screenshot" },
4343
async ({ page, app, util }) => {
44-
await util.getMatchSystemThemeCheckbox().click();
44+
await util.getMatchSystemThemeSwitch().click();
4545

4646
// Assert that the themes are disabled
4747
await expect(util.getLightTheme()).toBeDisabled();

playwright/e2e/settings/encryption-user-tab/encryption-tab.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ test.describe("Encryption tab", () => {
117117
await verifySession(app, recoveryKey.encodedPrivateKey);
118118
await util.openEncryptionTab();
119119

120-
await page.getByRole("checkbox", { name: "Allow key storage" }).click();
120+
await page.getByRole("switch", { name: "Allow key storage" }).click();
121121

122122
await expect(
123123
page.getByRole("heading", { name: "Are you sure you want to turn off key storage and delete it?" }),
@@ -136,7 +136,7 @@ test.describe("Encryption tab", () => {
136136

137137
await page.getByRole("button", { name: "Delete key storage" }).click();
138138

139-
await expect(page.getByRole("checkbox", { name: "Allow key storage" })).not.toBeChecked();
139+
await expect(page.getByRole("switch", { name: "Allow key storage" })).not.toBeChecked();
140140

141141
for (const prom of deleteRequestPromises) {
142142
const request = await prom;

0 commit comments

Comments
 (0)