Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
2ea80e0
Default to new room list and enforce in config for app and develop
langleyd Aug 28, 2025
0ea795a
Update jest tests
langleyd Aug 28, 2025
7dff721
Update LandmarkNavigation and e2e test
langleyd Aug 28, 2025
256f82f
Update viewRoomByName helper
langleyd Aug 28, 2025
06bf4ad
lint
langleyd Aug 28, 2025
d0d9ec1
Update Add -> New Room flow
langleyd Aug 28, 2025
73e9371
Update e2e test to use Add -> Start Chat
langleyd Aug 28, 2025
09ce507
Update screenshots
langleyd Aug 28, 2025
5256f9c
Fix viewRoomByName, can't use option as it contains more that just th…
langleyd Aug 28, 2025
fbb0ca1
Fix knocking tests
langleyd Aug 28, 2025
1c1a052
fix layout.spec.ts and pstn.spec
langleyd Aug 28, 2025
1f9a664
timeline snapshots
langleyd Aug 28, 2025
76279d8
Fix spotlight.spec
langleyd Aug 28, 2025
379f6fc
TAC spaces and media preview settings
langleyd Aug 28, 2025
5e92470
Fix more screenshots and mark as unread tests
langleyd Sep 2, 2025
5019c77
Fix leftpanel test
langleyd Sep 2, 2025
a0aaec1
Bugfix for knocking use case. We should check EffectiveMembership whe…
langleyd Sep 2, 2025
4fa9a1a
Fix openCreateRoomDialog to new room list specifics to fix create-kno…
langleyd Sep 2, 2025
75cf1e3
lint
langleyd Sep 2, 2025
bfc41c7
Merge branch 'develop' of github.com:vector-im/element-web into langl…
langleyd Sep 5, 2025
5586e0a
Fix Landmark navigation from left panel search to the next landmark
langleyd Sep 5, 2025
44162af
lint
langleyd Sep 5, 2025
e1863c7
Update window-12px-linux.png
langleyd Sep 5, 2025
2f622f6
Update apps-drawer-linux.png
langleyd Sep 5, 2025
36a6789
Update sliding sync e2e tests
langleyd Sep 5, 2025
c3e0e11
Merge branch 'develop' into langleyd/enable_new_room_list
dbkr Sep 9, 2025
3797b34
Update some screenshots
dbkr Sep 10, 2025
e5f5095
Revert change to the space create screenshot
dbkr Sep 10, 2025
3d56a54
Use actual screenshot
dbkr Sep 10, 2025
66e2e5d
Fix test selectors
dbkr Sep 10, 2025
56e3ae1
Morfe test screenshot selector / update
dbkr Sep 10, 2025
d046bb0
Add test for landmark navigation
dbkr Sep 10, 2025
b8141ea
Replace screenshots
dbkr Sep 10, 2025
4b5b49b
Merge branch 'develop' into langleyd/enable_new_room_list
dbkr Sep 10, 2025
3dfba4d
Fix another test that just got added an hour ago
dbkr Sep 10, 2025
4ed8745
Not sure why this was changed, doesn't seem necessary
dbkr Sep 11, 2025
daaa25a
Merge branch 'develop' into langleyd/enable_new_room_list
dbkr Sep 12, 2025
4ff2f0f
Disambiguate selector
dbkr Sep 12, 2025
e5a58a4
Another screenshot that's now changed in width by 1px
dbkr Sep 12, 2025
48277ec
Revert changes to config files
dbkr Sep 12, 2025
9b4ecaa
Convert read.unread assertions to new room list
dbkr Sep 15, 2025
f4e7e50
Update room list order tests
dbkr Sep 15, 2025
5db439b
Fix room titles in read receipts test
dbkr Sep 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions playwright/e2e/accessibility/keyboard-navigation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ test.describe("Landmark navigation tests", () => {

// Pressing Control+F6 again will focus room search
await page.keyboard.press("ControlOrMeta+F6");
await expect(page.locator(".mx_RoomSearch")).toBeFocused();
await expect(page.locator(".mx_RoomListSearch_search")).toBeFocused();

// Pressing Control+F6 again will focus the message composer
await page.keyboard.press("ControlOrMeta+F6");
Expand All @@ -44,7 +44,7 @@ test.describe("Landmark navigation tests", () => {
await expect(page.locator(".mx_HomePage")).toBeFocused();

await page.keyboard.press("ControlOrMeta+Shift+F6");
await expect(page.locator(".mx_RoomSearch")).toBeFocused();
await expect(page.locator(".mx_RoomListSearch_search")).toBeFocused();

await page.keyboard.press("ControlOrMeta+Shift+F6");
await expect(page.locator(".mx_SpaceButton_active")).toBeFocused();
Expand Down Expand Up @@ -75,11 +75,11 @@ test.describe("Landmark navigation tests", () => {

// Pressing Control+F6 again will focus room search
await page.keyboard.press("ControlOrMeta+F6");
await expect(page.locator(".mx_RoomSearch")).toBeFocused();
await expect(page.locator(".mx_RoomListSearch_search")).toBeFocused();

// Pressing Control+F6 again will focus the room tile in the room list
await page.keyboard.press("ControlOrMeta+F6");
await expect(page.locator(".mx_RoomTile_selected")).toBeFocused();
await expect(page.locator(".mx_RoomListItemView_selected")).toBeFocused();

// Pressing Control+F6 again will focus the message composer
await page.keyboard.press("ControlOrMeta+F6");
Expand All @@ -94,10 +94,10 @@ test.describe("Landmark navigation tests", () => {
await expect(page.locator(".mx_BasicMessageComposer_input")).toBeFocused();

await page.keyboard.press("ControlOrMeta+Shift+F6");
await expect(page.locator(".mx_RoomTile_selected")).toBeFocused();
await expect(page.locator(".mx_RoomListItemView_selected")).toBeFocused();

await page.keyboard.press("ControlOrMeta+Shift+F6");
await expect(page.locator(".mx_RoomSearch")).toBeFocused();
await expect(page.locator(".mx_RoomListSearch_search")).toBeFocused();

await page.keyboard.press("ControlOrMeta+Shift+F6");
await expect(page.locator(".mx_SpaceButton_active")).toBeFocused();
Expand Down Expand Up @@ -131,11 +131,11 @@ test.describe("Landmark navigation tests", () => {

// Pressing Control+F6 again will focus room search
await page.keyboard.press("ControlOrMeta+F6");
await expect(page.locator(".mx_RoomSearch")).toBeFocused();
await expect(page.locator(".mx_RoomListSearch_search")).toBeFocused();

// Pressing Control+F6 again will focus the room tile in the room list
await page.keyboard.press("ControlOrMeta+F6");
await expect(page.locator(".mx_RoomTile")).toBeFocused();
await expect(page.locator(".mx_RoomListItemView")).toBeFocused();

// Pressing Control+F6 again will focus the home section
await page.keyboard.press("ControlOrMeta+F6");
Expand All @@ -150,10 +150,10 @@ test.describe("Landmark navigation tests", () => {
await expect(page.locator(".mx_HomePage")).toBeFocused();

await page.keyboard.press("ControlOrMeta+Shift+F6");
await expect(page.locator(".mx_RoomTile")).toBeFocused();
await expect(page.locator(".mx_RoomListItemView")).toBeFocused();

await page.keyboard.press("ControlOrMeta+Shift+F6");
await expect(page.locator(".mx_RoomSearch")).toBeFocused();
await expect(page.locator(".mx_RoomListSearch_search")).toBeFocused();

await page.keyboard.press("ControlOrMeta+Shift+F6");
await expect(page.locator(".mx_SpaceButton_active")).toBeFocused();
Expand Down
5 changes: 4 additions & 1 deletion playwright/e2e/composer/CIDER.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,12 @@

const composer = page.getByRole("textbox", { name: "Send an unencrypted message…" });
await composer.pressSequentially("@bob");
await page.getByRole("option", { name: "Bob" }).click();

// Note that we include the user ID here as the room tile is also an 'option' role
// with text 'Bob'
await page.getByRole("option", { name: `Bob ${bot.credentials.userId}` }).click();
await expect(composer.getByText("Bob")).toBeVisible();
await expect(composer).toMatchScreenshot("mention.png");

Check failure on line 116 in playwright/e2e/composer/CIDER.spec.ts

View workflow job for this annotation

GitHub Actions / Run Tests [Chrome] 1/6

[Chrome] › playwright/e2e/composer/CIDER.spec.ts:101:13 › Composer › CIDER › can send mention @screenshot

1) [Chrome] › playwright/e2e/composer/CIDER.spec.ts:101:13 › Composer › CIDER › can send mention @screenshot Error: expect(locator).toHaveScreenshot(expected) 13 pixels (ratio 0.01 of all image pixels) are different. Snapshot: mention.png Call log: - Expect "toHaveScreenshot(mention.png)" with timeout 5000ms - verifying given screenshot expectation - waiting for getByRole('textbox', { name: 'Send an unencrypted message…' }) - locator resolved to <div dir="auto" tabindex="0" role="textbox" translate="no" aria-multiline="true" aria-disabled="false" contenteditable="true" aria-haspopup="listbox" aria-autocomplete="list" data-testid="basicmessagecomposer" aria-label="Send an unencrypted message…" class="mx_BasicMessageComposer_input mx_BasicMessageComposer_input_shouldShowPillAvatar">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - attempting scroll into view action - waiting for element to be stable - 13 pixels (ratio 0.01 of all image pixels) are different. - waiting 100ms before taking screenshot - waiting for getByRole('textbox', { name: 'Send an unencrypted message…' }) - locator resolved to <div dir="auto" tabindex="0" role="textbox" translate="no" aria-multiline="true" aria-disabled="false" contenteditable="true" aria-haspopup="listbox" aria-autocomplete="list" data-testid="basicmessagecomposer" aria-label="Send an unencrypted message…" class="mx_BasicMessageComposer_input mx_BasicMessageComposer_input_shouldShowPillAvatar">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - attempting scroll into view action - waiting for element to be stable - captured a stable screenshot - 13 pixels (ratio 0.01 of all image pixels) are different. 114 | await page.getByRole("option", { name: `Bob ${bot.credentials.userId}` }).click(); 115 | await expect(composer.getByText("Bob")).toBeVisible(); > 116 | await expect(composer).toMatchScreenshot("mention.png"); | ^ 117 | await composer.press("Enter"); 118 | await expect(page.locator(".mx_EventTile_body", { hasText: "Bob" })).toBeVisible(); 119 | }); at /home/runner/work/element-web/element-web/playwright/e2e/composer/CIDER.spec.ts:116:36
await composer.press("Enter");
await expect(page.locator(".mx_EventTile_body", { hasText: "Bob" })).toBeVisible();
});
Expand Down
4 changes: 2 additions & 2 deletions playwright/e2e/crypto/backups-mas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ test.describe("Encryption state after registration", () => {
"Pa$sW0rD!",
);

await page.getByRole("button", { name: "Add room" }).click();
await page.getByRole("navigation", { name: "Room list" }).getByRole("button", { name: "Add" }).click();
await page.getByRole("menuitem", { name: "New room" }).click();
await page.getByRole("textbox", { name: "Name" }).fill("test room");
await page.getByRole("button", { name: "Create room" }).click();
Expand Down Expand Up @@ -78,7 +78,7 @@ test.describe("Key backup reset from elsewhere", () => {
await page.getByRole("button", { name: "Continue" }).click();
await registerAccountMas(page, mailpitClient, testUsername, `${testUsername}@email.com`, testPassword);

await page.getByRole("button", { name: "Add room" }).click();
await page.getByRole("navigation", { name: "Room list" }).getByRole("button", { name: "Add" }).click();
await page.getByRole("menuitem", { name: "New room" }).click();
await page.getByRole("textbox", { name: "Name" }).fill("test room");
await page.getByRole("button", { name: "Create room" }).click();
Expand Down
3 changes: 2 additions & 1 deletion playwright/e2e/crypto/crypto.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const checkDMRoom = async (page: Page) => {
};

const startDMWithBob = async (page: Page, bob: Bot) => {
await page.locator(".mx_LegacyRoomList").getByRole("button", { name: "Start chat" }).click();
await page.getByRole("navigation", { name: "Room list" }).getByRole("button", { name: "Add" }).click();
await page.getByRole("menuitem", { name: "Start chat" }).click();
await page.getByTestId("invite-dialog-input").fill(bob.credentials.userId);
await page.locator(".mx_InviteDialog_tile_nameStack_name").getByText("Bob").click();
await expect(
Expand Down
10 changes: 2 additions & 8 deletions playwright/e2e/crypto/decryption-failure-messages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,7 @@ test.describe("Cryptography", function () {
);

// Alice accepts the invite
await expect(
page.getByRole("group", { name: "Invites" }).locator(".mx_RoomSublist_tiles").getByRole("treeitem"),
).toHaveCount(1);
await page.getByRole("treeitem", { name: "Test room" }).click();
await page.getByRole("option", { name: "Test room" }).click();
await page.locator(".mx_RoomView").getByRole("button", { name: "Accept" }).click();

// Bob sends an encrypted event and an undecryptable event
Expand Down Expand Up @@ -280,10 +277,7 @@ test.describe("Cryptography", function () {
);

// Alice accepts the invite
await expect(
page.getByRole("group", { name: "Invites" }).locator(".mx_RoomSublist_tiles").getByRole("treeitem"),
).toHaveCount(1);
await page.getByRole("treeitem", { name: "Test room" }).click();
await page.getByRole("option", { name: "Test room" }).click();
await page.locator(".mx_RoomView").getByRole("button", { name: "Accept" }).click();

// wait until we're joined and see the timeline
Expand Down
4 changes: 2 additions & 2 deletions playwright/e2e/crypto/toasts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test.describe("Key storage out of sync toast", () => {
await deleteCachedSecrets(page);

// We won't be prompted for crypto setup unless we have an e2e room, so make one
await page.getByRole("button", { name: "Add room" }).click();
await page.getByRole("navigation", { name: "Room list" }).getByRole("button", { name: "Add" }).click();
await page.getByRole("menuitem", { name: "New room" }).click();
await page.getByRole("textbox", { name: "Name" }).fill("Test room");
await page.getByRole("button", { name: "Create room" }).click();
Expand Down Expand Up @@ -68,7 +68,7 @@ test.describe("'Turn on key storage' toast", () => {
await logIntoElementAndVerify(page, credentials, recoveryKey.encodedPrivateKey);

// We won't be prompted for crypto setup unless we have an e2e room, so make one
await page.getByRole("button", { name: "Add room" }).click();
await page.getByRole("navigation", { name: "Room list" }).getByRole("button", { name: "Add" }).click();
await page.getByRole("menuitem", { name: "New room" }).click();
await page.getByRole("textbox", { name: "Name" }).fill("Test room");
await page.getByRole("button", { name: "Create room" }).click();
Expand Down
4 changes: 2 additions & 2 deletions playwright/e2e/crypto/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,8 @@ export async function sendMessageInCurrentRoom(page: Page, message: string): Pro
* @param isEncrypted - Whether the room should be encrypted
*/
export async function createRoom(page: Page, roomName: string, isEncrypted: boolean): Promise<void> {
await page.getByRole("button", { name: "Add room" }).click();
await page.locator(".mx_IconizedContextMenu").getByRole("menuitem", { name: "New room" }).click();
await page.getByRole("navigation", { name: "Room list" }).getByRole("button", { name: "Add" }).click();
await page.getByRole("menuitem", { name: "New room" }).click();

const dialog = page.locator(".mx_Dialog");

Expand Down
3 changes: 2 additions & 1 deletion playwright/e2e/invite/invite-dialog.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ test.describe("Invite dialog", function () {
"should support inviting a user to Direct Messages",
{ tag: "@screenshot" },
async ({ page, app, user, bot }) => {
await page.locator(".mx_LegacyRoomList").getByRole("button", { name: "Start chat" }).click();
await page.getByRole("navigation", { name: "Room list" }).getByRole("button", { name: "Add" }).click();
await page.getByRole("menuitem", { name: "Start chat" }).click();

const other = page.locator(".mx_InviteDialog_other");
// Assert that the header is rendered
Expand Down
25 changes: 11 additions & 14 deletions playwright/e2e/knock/knock-into-room.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ test.describe("Knock Into Room", () => {

// Knocked room should appear in Rooms
await expect(
page.getByRole("group", { name: "Rooms" }).getByRole("treeitem", { name: "Cybersecurity" }),
page.getByTestId("room-list").getByRole("option", { name: "Open room Cybersecurity" }),
).toBeVisible();

// bot waits for knock request from Alice
Expand All @@ -77,15 +77,15 @@ test.describe("Knock Into Room", () => {
await bot.inviteUser(room.roomId, user.userId);

await expect(
page.getByRole("group", { name: "Invites" }).getByRole("treeitem", { name: "Cybersecurity" }),
page.getByTestId("room-list").getByRole("option", { name: "Open room Cybersecurity" }),
).toBeVisible();

// Alice have to accept invitation in order to join the room.
// It will be not needed when homeserver implements auto accept knock requests.
await page.locator(".mx_RoomView").getByRole("button", { name: "Accept" }).click();

await expect(
page.getByRole("group", { name: "Rooms" }).getByRole("treeitem", { name: "Cybersecurity" }),
page.getByTestId("room-list").getByRole("option", { name: "Open room Cybersecurity" }),
).toBeVisible();

await expect(page.getByText("Alice joined the room")).toBeVisible();
Expand Down Expand Up @@ -136,7 +136,7 @@ test.describe("Knock Into Room", () => {

// Knocked room should appear in Rooms
await expect(
page.getByRole("group", { name: "Rooms" }).getByRole("treeitem", { name: "Cybersecurity" }),
page.getByTestId("room-list").getByRole("option", { name: "Open room Cybersecurity" }),
).toBeVisible();

// bot waits for knock request from Alice
Expand All @@ -154,15 +154,15 @@ test.describe("Knock Into Room", () => {
await bot.inviteUser(room.roomId, user.userId);

await expect(
page.getByRole("group", { name: "Invites" }).getByRole("treeitem", { name: "Cybersecurity" }),
page.getByTestId("room-list").getByRole("option", { name: "Open room Cybersecurity" }),
).toBeVisible();

// Alice have to accept invitation in order to join the room.
// It will be not needed when homeserver implements auto accept knock requests.
await page.locator(".mx_RoomView").getByRole("button", { name: "Accept" }).click();

await expect(
page.getByRole("group", { name: "Rooms" }).getByRole("treeitem", { name: "Cybersecurity" }),
page.getByTestId("room-list").getByRole("option", { name: "Open room Cybersecurity" }),
).toBeVisible();

await expect(page.getByText("Alice joined the room")).toBeVisible();
Expand Down Expand Up @@ -215,14 +215,14 @@ test.describe("Knock Into Room", () => {
await expect(roomPreviewBar.getByRole("heading", { name: "Request to join sent" })).toBeVisible();

// Knocked room should appear in Rooms
page.getByRole("group", { name: "Rooms" }).getByRole("treeitem", { name: "Cybersecurity" });
page.getByTestId("room-list").getByRole("option", { name: "Open room Cybersecurity" });

await roomPreviewBar.getByRole("button", { name: "Cancel request" }).click();
await expect(roomPreviewBar.getByRole("heading", { name: "Ask to join Cybersecurity?" })).toBeVisible();
await expect(roomPreviewBar.getByRole("button", { name: "Request access" })).toBeVisible();

await expect(
page.getByRole("group", { name: "Rooms" }).getByRole("treeitem", { name: "Cybersecurity" }),
page.getByTestId("room-list").getByRole("option", { name: "Open room Cybersecurity" }),
).not.toBeVisible();
});

Expand All @@ -244,7 +244,7 @@ test.describe("Knock Into Room", () => {

// Knocked room should appear in Rooms
await expect(
page.getByRole("group", { name: "Rooms" }).getByRole("treeitem", { name: "Cybersecurity" }),
page.getByTestId("room-list").getByRole("option", { name: "Open room Cybersecurity" }),
).toBeVisible();

// bot waits for knock request from Alice
Expand All @@ -262,13 +262,10 @@ test.describe("Knock Into Room", () => {
await bot.kick(room.roomId, user.userId);

// Room should stay in Rooms and have red badge when knock is denied
await expect(
page.getByRole("group", { name: "Rooms" }).getByRole("treeitem", { name: "Cybersecurity", exact: true }),
).not.toBeVisible();
await expect(
page
.getByRole("group", { name: "Rooms" })
.getByRole("treeitem", { name: "Cybersecurity 1 unread mention." }),
.getByTestId("room-list")
.getByRole("option", { name: "Open room Cybersecurity with 1 unread mention." }),
).toBeVisible();

await expect(roomPreviewBar.getByRole("heading", { name: "You have been denied access" })).toBeVisible();
Expand Down
2 changes: 1 addition & 1 deletion playwright/e2e/left-panel/left-panel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test.describe("LeftPanel", () => {
// create rooms and check room names are correct
for (const name of ["Apple", "Pineapple", "Orange"]) {
await app.client.createRoom({ name });
await expect(page.getByRole("treeitem", { name })).toBeVisible();
await expect(page.getByRole("option", { name: `Open room ${name}` })).toBeVisible();
}
});
});
44 changes: 19 additions & 25 deletions playwright/e2e/read-receipts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com
Please see LICENSE files in the repository root for full details.
*/

import type { JSHandle, Page } from "@playwright/test";
import type { JSHandle, Locator, Page } from "@playwright/test";
import type { MatrixEvent, Room, IndexedDBStore, ReceiptType } from "matrix-js-sdk/src/matrix";
import { test as base, expect } from "../../element-web-test";
import { type Bot } from "../../pages/bot";
Expand Down Expand Up @@ -428,7 +428,7 @@ class Helpers {
}

getRoomListTile(label: string) {
return this.page.getByRole("treeitem", { name: new RegExp("^" + label) });
return this.page.getByRole("option", { name: new RegExp("^Open room " + label) });
}

/**
Expand All @@ -446,8 +446,8 @@ class Helpers {
*/
async assertRead(room: RoomRef) {
const tile = this.getRoomListTile(room.name);
await expect(tile.locator(".mx_NotificationBadge_dot")).not.toBeVisible();
await expect(tile.locator(".mx_NotificationBadge_count")).not.toBeVisible();
await expect(tile.getByTestId("notification-decoration")).not.toBeVisible();
await expect(tile).not.toHaveAccessibleName(/with \d* unread message/);
}

/**
Expand All @@ -463,15 +463,18 @@ class Helpers {
/**
* Assert a given room is marked as unread (via the room list tile)
* @param room - the name of the room to check
* @param count - the numeric count to assert, or if "." specified then a bold/dot (no count) state is asserted
* @param count - the numeric count to assert
*/
async assertUnread(room: RoomRef, count: number | ".") {
async assertUnread(room: RoomRef, count: number) {
const tile = this.getRoomListTile(room.name);
if (count === ".") {
await expect(tile.locator(".mx_NotificationBadge_dot")).toBeVisible();
} else {
await expect(tile.locator(".mx_NotificationBadge_count")).toHaveText(count.toString());
}
await expect(tile).toBeVisible();
await expect(tile).toHaveAccessibleName(/with \d* unread message/);
}

async unreadCountForRoomTile(tile: Locator): Promise<number> {
const accessibleName = await tile.getAttribute("aria-label");
const match = accessibleName?.match(/(\d+)\s+unread message/);
return match ? parseInt(match[1], 10) : 0;
}

/**
Expand All @@ -487,7 +490,7 @@ class Helpers {
// .toBeLessThan doesn't have a retry mechanism, so we use .poll
await expect
.poll(async () => {
return parseInt(await tile.locator(".mx_NotificationBadge_count").textContent(), 10);
return this.unreadCountForRoomTile(tile);
})
.toBeLessThan(lessThan);
}
Expand All @@ -505,7 +508,7 @@ class Helpers {
// .toBeGreaterThan doesn't have a retry mechanism, so we use .poll
await expect
.poll(async () => {
return parseInt(await tile.locator(".mx_NotificationBadge_count").textContent(), 10);
return this.unreadCountForRoomTile(tile);
})
.toBeGreaterThan(greaterThan);
}
Expand Down Expand Up @@ -596,24 +599,15 @@ class Helpers {
await button.click();
}

/**
* Toggle the `Show rooms with unread messages first` option for the room list
*/
async toggleRoomUnreadOrder() {
await this.toggleRoomListMenu();
await this.page.getByText("Show rooms with unread messages first").click();
// Close contextual menu
await this.page.locator(".mx_ContextualMenu_background").click();
}

/**
* Assert that the room list is ordered as expected
* @param rooms
*/
async assertRoomListOrder(rooms: Array<{ name: string }>) {
const roomList = this.page.locator(".mx_RoomTile_title");
const roomListContainer = this.page.getByTestId("room-list");
const roomTiles = roomListContainer.getByRole("option");
for (const [i, room] of rooms.entries()) {
await expect(roomList.nth(i)).toHaveText(room.name);
await expect(roomTiles.nth(i)).toHaveAccessibleName(new RegExp(`${room.name}`));
}
}
}
Expand Down
Loading
Loading