From 18a3e720aae3248bbab554a71d1439cd59240257 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 7 Jan 2025 15:08:12 +0000 Subject: [PATCH] Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- .../e2e/create-room/create-room.spec.ts | 9 +-- playwright/e2e/crypto/crypto.spec.ts | 2 +- .../e2e/lazy-loading/lazy-loading.spec.ts | 25 ++++++-- playwright/e2e/permalinks/permalinks.spec.ts | 2 +- .../e2e/right-panel/right-panel.spec.ts | 40 +++++++------ .../e2e/room-directory/room-directory.spec.ts | 6 +- .../general-room-settings-tab.spec.ts | 4 +- playwright/e2e/spaces/spaces.spec.ts | 6 +- .../spaces/threads-activity-centre/index.ts | 7 ++- .../threadsActivityCentre.spec.ts | 57 +++++++++++-------- playwright/e2e/widgets/stickers.spec.ts | 9 ++- playwright/element-web-test.ts | 2 +- 12 files changed, 96 insertions(+), 73 deletions(-) diff --git a/playwright/e2e/create-room/create-room.spec.ts b/playwright/e2e/create-room/create-room.spec.ts index 654352d3b8..087a89e68d 100644 --- a/playwright/e2e/create-room/create-room.spec.ts +++ b/playwright/e2e/create-room/create-room.spec.ts @@ -11,12 +11,7 @@ import { test, expect } from "../../element-web-test"; test.describe("Create Room", () => { test.use({ displayName: "Jim" }); - test("should allow us to create a public room with name, topic & address set", async ({ - credentials, - page, - user, - app, - }) => { + test("should allow us to create a public room with name, topic & address set", async ({ page, user, app }) => { const name = "Test room 1"; const topic = "This room is dedicated to this test and this test only!"; @@ -32,7 +27,7 @@ test.describe("Create Room", () => { // Submit await dialog.getByRole("button", { name: "Create room" }).click(); - await expect(page).toHaveURL(new RegExp(`/#/room/#test-room-1:${credentials.homeServer}`)); + await expect(page).toHaveURL(new RegExp(`/#/room/#test-room-1:${user.homeServer}`)); const header = page.locator(".mx_RoomHeader"); await expect(header).toContainText(name); }); diff --git a/playwright/e2e/crypto/crypto.spec.ts b/playwright/e2e/crypto/crypto.spec.ts index 15453a408e..f99a7a6458 100644 --- a/playwright/e2e/crypto/crypto.spec.ts +++ b/playwright/e2e/crypto/crypto.spec.ts @@ -68,6 +68,7 @@ const bobJoin = async (page: Page, bob: Bot) => { }; test.describe("Cryptography", function () { + test.skip(isDendrite, "Dendrite lacks support for MSC3967 so requires additional auth here"); test.use({ displayName: "Alice", botCreateOpts: { @@ -78,7 +79,6 @@ test.describe("Cryptography", function () { for (const isDeviceVerified of [true, false]) { test.describe(`setting up secure key backup should work isDeviceVerified=${isDeviceVerified}`, () => { - test.skip(isDendrite, "Dendrite lacks support for MSC3967 so requires additional auth here"); /** * Verify that the `m.cross_signing.${keyType}` key is available on the account data on the server * @param keyType diff --git a/playwright/e2e/lazy-loading/lazy-loading.spec.ts b/playwright/e2e/lazy-loading/lazy-loading.spec.ts index 6c9457dfaf..23ccaf8085 100644 --- a/playwright/e2e/lazy-loading/lazy-loading.spec.ts +++ b/playwright/e2e/lazy-loading/lazy-loading.spec.ts @@ -10,6 +10,7 @@ import { Bot } from "../../pages/bot"; import type { Locator, Page } from "@playwright/test"; import type { ElementAppPage } from "../../pages/ElementAppPage"; import { test, expect } from "../../element-web-test"; +import { Credentials } from "../../plugins/homeserver"; test.describe("Lazy Loading", () => { const charlies: Bot[] = []; @@ -35,12 +36,18 @@ test.describe("Lazy Loading", () => { }); const name = "Lazy Loading Test"; - const alias = "#lltest:localhost"; const charlyMsg1 = "hi bob!"; const charlyMsg2 = "how's it going??"; let roomId: string; - async function setupRoomWithBobAliceAndCharlies(page: Page, app: ElementAppPage, bob: Bot, charlies: Bot[]) { + async function setupRoomWithBobAliceAndCharlies( + page: Page, + app: ElementAppPage, + user: Credentials, + bob: Bot, + charlies: Bot[], + ) { + const alias = `#lltest:${user.homeServer}`; const visibility = await page.evaluate(() => (window as any).matrixcs.Visibility.Public); roomId = await bob.createRoom({ name, @@ -95,7 +102,13 @@ test.describe("Lazy Loading", () => { } } - async function joinCharliesWhileAliceIsOffline(page: Page, app: ElementAppPage, charlies: Bot[]) { + async function joinCharliesWhileAliceIsOffline( + page: Page, + app: ElementAppPage, + user: Credentials, + charlies: Bot[], + ) { + const alias = `#lltest:${user.homeServer}`; await app.client.network.goOffline(); for (const charly of charlies) { await charly.joinRoom(alias); @@ -107,19 +120,19 @@ test.describe("Lazy Loading", () => { await app.client.waitForNextSync(); } - test("should handle lazy loading properly even when offline", async ({ page, app, bot }) => { + test("should handle lazy loading properly even when offline", async ({ page, app, bot, user }) => { test.slow(); const charly1to5 = charlies.slice(0, 5); const charly6to10 = charlies.slice(5); // Set up room with alice, bob & charlies 1-5 - await setupRoomWithBobAliceAndCharlies(page, app, bot, charly1to5); + await setupRoomWithBobAliceAndCharlies(page, app, user, bot, charly1to5); // Alice should see 2 messages from every charly with the correct display name await checkPaginatedDisplayNames(app, charly1to5); await openMemberlist(app); await checkMemberList(page, charly1to5); - await joinCharliesWhileAliceIsOffline(page, app, charly6to10); + await joinCharliesWhileAliceIsOffline(page, app, user, charly6to10); await checkMemberList(page, charly6to10); for (const charly of charlies) { diff --git a/playwright/e2e/permalinks/permalinks.spec.ts b/playwright/e2e/permalinks/permalinks.spec.ts index 9b448455ec..e7657b1394 100644 --- a/playwright/e2e/permalinks/permalinks.spec.ts +++ b/playwright/e2e/permalinks/permalinks.spec.ts @@ -31,7 +31,7 @@ test.describe("permalinks", () => { await charlotte.prepareClient(); // We don't use a bot for danielle as we want a stable MXID. - const danielleId = "@danielle:localhost"; + const danielleId = `@danielle:${user.homeServer}`; const room1Id = await app.client.createRoom({ name: room1Name }); const room2Id = await app.client.createRoom({ name: room2Name }); diff --git a/playwright/e2e/right-panel/right-panel.spec.ts b/playwright/e2e/right-panel/right-panel.spec.ts index 2f51f92587..23af4c37b4 100644 --- a/playwright/e2e/right-panel/right-panel.spec.ts +++ b/playwright/e2e/right-panel/right-panel.spec.ts @@ -38,29 +38,33 @@ test.describe("RightPanel", () => { }); test.describe("in rooms", () => { - test("should handle long room address and long room name", { tag: "@screenshot" }, async ({ page, app }) => { - await app.client.createRoom({ name: ROOM_NAME_LONG }); - await viewRoomSummaryByName(page, app, ROOM_NAME_LONG); + test( + "should handle long room address and long room name", + { tag: "@screenshot" }, + async ({ page, app, user }) => { + await app.client.createRoom({ name: ROOM_NAME_LONG }); + await viewRoomSummaryByName(page, app, ROOM_NAME_LONG); - await app.settings.openRoomSettings(); + await app.settings.openRoomSettings(); - // Set a local room address - const localAddresses = page.locator(".mx_SettingsFieldset", { hasText: "Local Addresses" }); - await localAddresses.getByRole("textbox").fill(ROOM_ADDRESS_LONG); - await localAddresses.getByRole("button", { name: "Add" }).click(); - await expect(localAddresses.getByText(`#${ROOM_ADDRESS_LONG}:localhost`)).toHaveClass( - "mx_EditableItem_item", - ); + // Set a local room address + const localAddresses = page.locator(".mx_SettingsFieldset", { hasText: "Local Addresses" }); + await localAddresses.getByRole("textbox").fill(ROOM_ADDRESS_LONG); + await localAddresses.getByRole("button", { name: "Add" }).click(); + await expect(localAddresses.getByText(`#${ROOM_ADDRESS_LONG}:${user.homeServer}`)).toHaveClass( + "mx_EditableItem_item", + ); - await app.closeDialog(); + await app.closeDialog(); - // Close and reopen the right panel to render the room address - await app.toggleRoomInfoPanel(); - await expect(page.locator(".mx_RightPanel")).not.toBeVisible(); - await app.toggleRoomInfoPanel(); + // Close and reopen the right panel to render the room address + await app.toggleRoomInfoPanel(); + await expect(page.locator(".mx_RightPanel")).not.toBeVisible(); + await app.toggleRoomInfoPanel(); - await expect(page.locator(".mx_RightPanel")).toMatchScreenshot("with-name-and-address.png"); - }); + await expect(page.locator(".mx_RightPanel")).toMatchScreenshot("with-name-and-address.png"); + }, + ); test("should handle clicking add widgets", async ({ page, app }) => { await viewRoomSummaryByName(page, app, ROOM_NAME); diff --git a/playwright/e2e/room-directory/room-directory.spec.ts b/playwright/e2e/room-directory/room-directory.spec.ts index 34004c90d2..9006328cce 100644 --- a/playwright/e2e/room-directory/room-directory.spec.ts +++ b/playwright/e2e/room-directory/room-directory.spec.ts @@ -31,11 +31,11 @@ test.describe("Room Directory", () => { const localAddresses = page.locator(".mx_SettingsFieldset", { hasText: "Local Addresses" }); await localAddresses.getByRole("textbox").fill("gaming"); await localAddresses.getByRole("button", { name: "Add" }).click(); - await expect(localAddresses.getByText("#gaming:localhost")).toHaveClass("mx_EditableItem_item"); + await expect(localAddresses.getByText(`#gaming:${user.homeServer}`)).toHaveClass("mx_EditableItem_item"); // Publish into the public rooms directory const publishedAddresses = page.locator(".mx_SettingsFieldset", { hasText: "Published Addresses" }); - await expect(publishedAddresses.locator("#canonicalAlias")).toHaveValue("#gaming:localhost"); + await expect(publishedAddresses.locator("#canonicalAlias")).toHaveValue(`#gaming:${user.homeServer}`); const checkbox = publishedAddresses .locator(".mx_SettingsFlag", { hasText: "Publish this room to the public in localhost's room directory?", @@ -86,7 +86,7 @@ test.describe("Room Directory", () => { .getByRole("button", { name: "Join" }) .click(); - await expect(page).toHaveURL("/#/room/#test1234:localhost"); + await expect(page).toHaveURL(`/#/room/#test1234:${user.homeServer}`); }, ); }); diff --git a/playwright/e2e/settings/general-room-settings-tab.spec.ts b/playwright/e2e/settings/general-room-settings-tab.spec.ts index eec32f7af5..4216deca22 100644 --- a/playwright/e2e/settings/general-room-settings-tab.spec.ts +++ b/playwright/e2e/settings/general-room-settings-tab.spec.ts @@ -36,7 +36,7 @@ test.describe("General room settings tab", () => { await expect(settings.getByText("Show more")).toBeVisible(); }); - test("long address should not cause dialog to overflow", { tag: "@no-webkit" }, async ({ page, app }) => { + test("long address should not cause dialog to overflow", { tag: "@no-webkit" }, async ({ page, app, user }) => { const settings = await app.settings.openRoomSettings("General"); // 1. Set the room-address to be a really long string const longString = "abcasdhjasjhdaj1jh1asdhasjdhajsdhjavhjksd".repeat(4); @@ -44,7 +44,7 @@ test.describe("General room settings tab", () => { await settings.locator("#roomAliases").getByText("Add", { exact: true }).click(); // 2. wait for the new setting to apply ... - await expect(settings.locator("#canonicalAlias")).toHaveValue(`#${longString}:localhost`); + await expect(settings.locator("#canonicalAlias")).toHaveValue(`#${longString}:${user.homeServer}`); // 3. Check if the dialog overflows const dialogBoundingBox = await page.locator(".mx_Dialog").boundingBox(); diff --git a/playwright/e2e/spaces/spaces.spec.ts b/playwright/e2e/spaces/spaces.spec.ts index 48bcc13c53..14df58fa8e 100644 --- a/playwright/e2e/spaces/spaces.spec.ts +++ b/playwright/e2e/spaces/spaces.spec.ts @@ -82,7 +82,7 @@ test.describe("Spaces", () => { // Copy matrix.to link await page.getByRole("button", { name: "Share invite link" }).click(); - expect(await app.getClipboardText()).toEqual("https://matrix.to/#/#lets-have-a-riot:localhost"); + expect(await app.getClipboardText()).toEqual(`https://matrix.to/#/#lets-have-a-riot:${user.homeServer}`); // Go to space home await page.getByRole("button", { name: "Go to my first room" }).click(); @@ -169,13 +169,13 @@ test.describe("Spaces", () => { room_alias_name: "space", }); - const menu = await openSpaceContextMenu(page, app, "#space:localhost"); + const menu = await openSpaceContextMenu(page, app, `#space:${user.homeServer}`); await menu.getByRole("menuitem", { name: "Invite" }).click(); const shareDialog = page.locator(".mx_SpacePublicShare"); // Copy link first await shareDialog.getByRole("button", { name: "Share invite link" }).click(); - expect(await app.getClipboardText()).toEqual("https://matrix.to/#/#space:localhost"); + expect(await app.getClipboardText()).toEqual(`https://matrix.to/#/#space:${user.homeServer}`); // Start Matrix invite flow await shareDialog.getByRole("button", { name: "Invite people" }).click(); diff --git a/playwright/e2e/spaces/threads-activity-centre/index.ts b/playwright/e2e/spaces/threads-activity-centre/index.ts index 2555e5a835..c4c69440b5 100644 --- a/playwright/e2e/spaces/threads-activity-centre/index.ts +++ b/playwright/e2e/spaces/threads-activity-centre/index.ts @@ -13,6 +13,7 @@ import { test as base, expect } from "../../../element-web-test"; import { Bot } from "../../../pages/bot"; import { Client } from "../../../pages/client"; import { ElementAppPage } from "../../../pages/ElementAppPage"; +import { Credentials } from "../../../plugins/homeserver"; type RoomRef = { name: string; roomId: string }; @@ -333,12 +334,14 @@ export class Helpers { /** * Populate the rooms with messages and threads + * @param user the user sending the messages * @param room1 * @param room2 * @param msg - MessageBuilder * @param hasMention - whether to include a mention in the first message */ async populateThreads( + user: Credentials, room1: { name: string; roomId: string }, room2: { name: string; roomId: string }, msg: MessageBuilder, @@ -350,9 +353,9 @@ export class Helpers { msg.threadedOff("Msg1", { "body": "User", "format": "org.matrix.custom.html", - "formatted_body": "User", + "formatted_body": `User`, "m.mentions": { - user_ids: ["@user:localhost"], + user_ids: [user.userId], }, }), ]); diff --git a/playwright/e2e/spaces/threads-activity-centre/threadsActivityCentre.spec.ts b/playwright/e2e/spaces/threads-activity-centre/threadsActivityCentre.spec.ts index 16276c5b9d..dcdcf1a21a 100644 --- a/playwright/e2e/spaces/threads-activity-centre/threadsActivityCentre.spec.ts +++ b/playwright/e2e/spaces/threads-activity-centre/threadsActivityCentre.spec.ts @@ -46,16 +46,21 @@ test.describe("Threads Activity Centre", { tag: "@no-firefox" }, () => { await util.assertNotificationTac(); }); - test("should show a highlight indicator when there is a mention in a thread", async ({ room1, util, msg }) => { + test("should show a highlight indicator when there is a mention in a thread", async ({ + room1, + util, + msg, + user, + }) => { await util.goTo(room1); await util.receiveMessages(room1, [ "Msg1", msg.threadedOff("Msg1", { "body": "User", "format": "org.matrix.custom.html", - "formatted_body": "User", + "formatted_body": `User`, "m.mentions": { - user_ids: ["@user:localhost"], + user_ids: [user.userId], }, }), ]); @@ -64,26 +69,30 @@ test.describe("Threads Activity Centre", { tag: "@no-firefox" }, () => { await util.assertHighlightIndicator(); }); - test("should show the rooms with unread threads", { tag: "@screenshot" }, async ({ room1, room2, util, msg }) => { + test( + "should show the rooms with unread threads", + { tag: "@screenshot" }, + async ({ room1, room2, util, msg, user }) => { + await util.goTo(room2); + await util.populateThreads(user, room1, room2, msg); + // The indicator should be shown + await util.assertHighlightIndicator(); + + // Verify that we have the expected rooms in the TAC + await util.openTac(); + await util.assertRoomsInTac([ + { room: room2.name, notificationLevel: "highlight" }, + { room: room1.name, notificationLevel: "notification" }, + ]); + + // Verify that we don't have a visual regression + await expect(util.getTacPanel()).toMatchScreenshot("tac-panel-mix-unread.png"); + }, + ); + + test("should update with a thread is read", { tag: "@screenshot" }, async ({ room1, room2, util, msg, user }) => { await util.goTo(room2); - await util.populateThreads(room1, room2, msg); - // The indicator should be shown - await util.assertHighlightIndicator(); - - // Verify that we have the expected rooms in the TAC - await util.openTac(); - await util.assertRoomsInTac([ - { room: room2.name, notificationLevel: "highlight" }, - { room: room1.name, notificationLevel: "notification" }, - ]); - - // Verify that we don't have a visual regression - await expect(util.getTacPanel()).toMatchScreenshot("tac-panel-mix-unread.png"); - }); - - test("should update with a thread is read", { tag: "@screenshot" }, async ({ room1, room2, util, msg }) => { - await util.goTo(room2); - await util.populateThreads(room1, room2, msg); + await util.populateThreads(user, room1, room2, msg); // Click on the first room in TAC await util.openTac(); @@ -104,9 +113,9 @@ test.describe("Threads Activity Centre", { tag: "@no-firefox" }, () => { await expect(util.getTacPanel()).toMatchScreenshot("tac-panel-notification-unread.png"); }); - test("should order by recency after notification level", async ({ room1, room2, util, msg }) => { + test("should order by recency after notification level", async ({ room1, room2, util, msg, user }) => { await util.goTo(room2); - await util.populateThreads(room1, room2, msg, false); + await util.populateThreads(user, room1, room2, msg, false); await util.openTac(); await util.assertRoomsInTac([ diff --git a/playwright/e2e/widgets/stickers.spec.ts b/playwright/e2e/widgets/stickers.spec.ts index 5820f2c169..2b7b2709f7 100644 --- a/playwright/e2e/widgets/stickers.spec.ts +++ b/playwright/e2e/widgets/stickers.spec.ts @@ -145,7 +145,7 @@ test.describe("Stickers", { tag: ["@no-firefox", "@no-webkit"] }, () => { // See sendStickerFromPicker() for more detail on iframe comms. let stickerPickerUrl: string; - test("should send a sticker to multiple rooms", async ({ credentials, webserver, page, app, user, room }) => { + test("should send a sticker to multiple rooms", async ({ webserver, page, app, user, room }) => { const roomId2 = await app.client.createRoom({ name: ROOM_NAME_2 }); const { content_uri: contentUri } = await app.client.uploadContent(STICKER_IMAGE, { type: "image/png" }); const widgetHtml = getWidgetHtml(contentUri, "image/png"); @@ -156,7 +156,7 @@ test.describe("Stickers", { tag: ["@no-firefox", "@no-webkit"] }, () => { await expect(page).toHaveURL(`/#/room/${room.roomId}`); await openStickerPicker(app); await sendStickerFromPicker(page); - await expectTimelineSticker(page, credentials.homeServer, room.roomId, contentUri); + await expectTimelineSticker(page, user.homeServer, room.roomId, contentUri); // Ensure that when we switch to a different room that the sticker // goes to the right place @@ -164,7 +164,7 @@ test.describe("Stickers", { tag: ["@no-firefox", "@no-webkit"] }, () => { await expect(page).toHaveURL(`/#/room/${roomId2}`); await openStickerPicker(app); await sendStickerFromPicker(page); - await expectTimelineSticker(page, credentials.homeServer, roomId2, contentUri); + await expectTimelineSticker(page, user.homeServer, roomId2, contentUri); }); test("should handle a sticker picker widget missing creatorUserId", async ({ @@ -173,7 +173,6 @@ test.describe("Stickers", { tag: ["@no-firefox", "@no-webkit"] }, () => { app, user, room, - credentials, }) => { const { content_uri: contentUri } = await app.client.uploadContent(STICKER_IMAGE, { type: "image/png" }); const widgetHtml = getWidgetHtml(contentUri, "image/png"); @@ -184,7 +183,7 @@ test.describe("Stickers", { tag: ["@no-firefox", "@no-webkit"] }, () => { await expect(page).toHaveURL(`/#/room/${room.roomId}`); await openStickerPicker(app); await sendStickerFromPicker(page); - await expectTimelineSticker(page, credentials.homeServer, room.roomId, contentUri); + await expectTimelineSticker(page, user.homeServer, room.roomId, contentUri); }); test("should render invalid mimetype as a file", async ({ webserver, page, app, user, room }) => { diff --git a/playwright/element-web-test.ts b/playwright/element-web-test.ts index f2f2afd3b9..da0ad64eee 100644 --- a/playwright/element-web-test.ts +++ b/playwright/element-web-test.ts @@ -143,7 +143,7 @@ export const test = base.extend({ const displayName = testDisplayName ?? _.sample(names)!; const credentials = await homeserver.registerUser("user", password, displayName); - console.log(`Registered test user @user:localhost with displayname ${displayName}`); + console.log(`Registered test user ${credentials.userId} with displayname ${displayName}`); await use({ ...credentials,