diff --git a/apps/web/playwright/e2e/composer/CIDER.spec.ts b/apps/web/playwright/e2e/composer/CIDER.spec.ts index 0a8489be7d..885f63f7f7 100644 --- a/apps/web/playwright/e2e/composer/CIDER.spec.ts +++ b/apps/web/playwright/e2e/composer/CIDER.spec.ts @@ -6,6 +6,8 @@ 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 { rejectToastIfExists } from "@element-hq/element-web-playwright-common"; + import { test, expect } from "../../element-web-test"; import { SettingLevel } from "../../../src/settings/SettingLevel"; import { getSampleFilePath } from "../../sample-files"; @@ -28,7 +30,9 @@ test.describe("Composer", () => { }, }); - test.beforeEach(async ({ room }) => {}); // trigger room fixture + test.beforeEach(async ({ app, room /* trigger room fixture */ }) => { + await rejectToastIfExists(app.page, "Notifications"); + }); test.describe("CIDER", () => { test("sends a message when you click send or press Enter", async ({ page }) => { diff --git a/apps/web/playwright/e2e/crypto/decryption-failure-messages.spec.ts b/apps/web/playwright/e2e/crypto/decryption-failure-messages.spec.ts index 1dc04ee905..50e655f462 100644 --- a/apps/web/playwright/e2e/crypto/decryption-failure-messages.spec.ts +++ b/apps/web/playwright/e2e/crypto/decryption-failure-messages.spec.ts @@ -6,6 +6,8 @@ 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 { rejectToastIfExists } from "@element-hq/element-web-playwright-common"; + import type { Preset, RoomMemberEvent, RoomStateEvent } from "matrix-js-sdk/src/matrix"; import { expect, test } from "../../element-web-test"; import { @@ -118,6 +120,9 @@ test.describe("Cryptography", function () { user: alice, bot: bob, }) => { + await rejectToastIfExists(page, "Verify this device"); + await rejectToastIfExists(page, "Notifications"); + // Bob creates an encrypted room and sends a message to it. He then invites Alice const roomId = await bob.evaluate( async (client, { alice }) => { @@ -224,6 +229,9 @@ test.describe("Cryptography", function () { user: alice, bot: bob, }) => { + await rejectToastIfExists(page, "Verify this device"); + await rejectToastIfExists(page, "Notifications"); + // Bob: // - creates an encrypted room, // - invites Alice, diff --git a/apps/web/playwright/e2e/room_options/marked_unread.spec.ts b/apps/web/playwright/e2e/room_options/marked_unread.spec.ts index ce3e170072..cad26f6286 100644 --- a/apps/web/playwright/e2e/room_options/marked_unread.spec.ts +++ b/apps/web/playwright/e2e/room_options/marked_unread.spec.ts @@ -6,6 +6,8 @@ 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 { rejectToastIfExists } from "@element-hq/element-web-playwright-common"; + import { test, expect } from "../../element-web-test"; import { isDendrite } from "../../plugins/homeserver/dendrite"; @@ -46,6 +48,8 @@ test.describe("Mark as Unread", () => { // navigate away from the room again await page.goto("/#/room/" + dummyRoomId); + await rejectToastIfExists(page, "Verify this device"); + const roomTile = page.getByLabel(TEST_ROOM_NAME); await roomTile.click({ button: "right" }); await page.getByRole("menuitem", { name: "Mark as unread" }).click(); diff --git a/apps/web/playwright/e2e/settings/appearance-user-settings-tab/appearance-user-settings-tab.spec.ts b/apps/web/playwright/e2e/settings/appearance-user-settings-tab/appearance-user-settings-tab.spec.ts index 70ba195631..4012db089e 100644 --- a/apps/web/playwright/e2e/settings/appearance-user-settings-tab/appearance-user-settings-tab.spec.ts +++ b/apps/web/playwright/e2e/settings/appearance-user-settings-tab/appearance-user-settings-tab.spec.ts @@ -69,6 +69,7 @@ test.describe("Appearance user settings tab", () => { { tag: "@screenshot" }, async ({ page, app, user, util }) => { await rejectToast(page, "Verify this device"); + await rejectToast(page, "Notifications"); const roomId = await util.createAndDisplayRoom(); diff --git a/apps/web/playwright/e2e/spaces/threads-activity-centre/threadsActivityCentre.spec.ts b/apps/web/playwright/e2e/spaces/threads-activity-centre/threadsActivityCentre.spec.ts index 9bd0042096..c7fc97f5e0 100644 --- a/apps/web/playwright/e2e/spaces/threads-activity-centre/threadsActivityCentre.spec.ts +++ b/apps/web/playwright/e2e/spaces/threads-activity-centre/threadsActivityCentre.spec.ts @@ -28,6 +28,7 @@ test.describe("Threads Activity Centre", { tag: "@no-firefox" }, () => { { tag: "@screenshot" }, async ({ util, page }) => { await rejectToast(page, "Verify this device"); + await rejectToast(page, "Notifications"); // Open the space panel await util.expandSpacePanel(); @@ -41,6 +42,7 @@ test.describe("Threads Activity Centre", { tag: "@no-firefox" }, () => { { tag: "@screenshot" }, async ({ room1, util, app, page }) => { await rejectToast(page, "Verify this device"); + await rejectToast(page, "Notifications"); // No indicator should be shown await util.assertNoTacIndicator(); @@ -61,6 +63,7 @@ test.describe("Threads Activity Centre", { tag: "@no-firefox" }, () => { page, }) => { await rejectToast(page, "Verify this device"); + await rejectToast(page, "Notifications"); await util.goTo(room1); await util.receiveMessages(room1, ["Msg1", msg.threadedOff("Msg1", "Resp1")]); @@ -78,6 +81,7 @@ test.describe("Threads Activity Centre", { tag: "@no-firefox" }, () => { page, }) => { await rejectToast(page, "Verify this device"); + await rejectToast(page, "Notifications"); await util.goTo(room1); await util.receiveMessages(room1, [ @@ -101,6 +105,7 @@ test.describe("Threads Activity Centre", { tag: "@no-firefox" }, () => { { tag: "@screenshot" }, async ({ room1, room2, util, msg, user, app, page }) => { await rejectToast(page, "Verify this device"); + await rejectToast(page, "Notifications"); await util.goTo(room2); await util.populateThreads(room1, room2, msg, user); @@ -124,6 +129,7 @@ test.describe("Threads Activity Centre", { tag: "@no-firefox" }, () => { { tag: "@screenshot" }, async ({ room1, room2, util, msg, user, app, page }) => { await rejectToast(page, "Verify this device"); + await rejectToast(page, "Notifications"); await util.goTo(room2); await util.populateThreads(room1, room2, msg, user); @@ -150,6 +156,7 @@ test.describe("Threads Activity Centre", { tag: "@no-firefox" }, () => { test("should order by recency after notification level", async ({ room1, room2, util, msg, user, app, page }) => { await rejectToast(page, "Verify this device"); + await rejectToast(page, "Notifications"); await util.goTo(room2); await util.populateThreads(room1, room2, msg, user, false); @@ -163,6 +170,7 @@ test.describe("Threads Activity Centre", { tag: "@no-firefox" }, () => { test("should block the Spotlight to open when the TAC is opened", async ({ util, page, app }) => { await rejectToast(page, "Verify this device"); + await rejectToast(page, "Notifications"); const toggleSpotlight = () => page.keyboard.press(`${CommandOrControl}+k`); @@ -180,6 +188,7 @@ test.describe("Threads Activity Centre", { tag: "@no-firefox" }, () => { test("should have the correct hover state", { tag: "@screenshot" }, async ({ util, page, app }) => { await rejectToast(page, "Verify this device"); + await rejectToast(page, "Notifications"); await util.hoverTacButton(); await expect(util.getSpacePanel()).toMatchScreenshot("tac-hovered.png"); @@ -192,6 +201,7 @@ test.describe("Threads Activity Centre", { tag: "@no-firefox" }, () => { test("should mark all threads as read", { tag: "@screenshot" }, async ({ room1, room2, util, msg, page, app }) => { await rejectToast(page, "Verify this device"); + await rejectToast(page, "Notifications"); await util.receiveMessages(room1, ["Msg1", msg.threadedOff("Msg1", "Resp1")]); @@ -214,6 +224,7 @@ test.describe("Threads Activity Centre", { tag: "@no-firefox" }, () => { page, }) => { await rejectToast(page, "Verify this device"); + await rejectToast(page, "Notifications"); await util.receiveMessages(room1, ["Msg1", msg.threadedOff("Msg1", "Resp1")]); diff --git a/apps/web/playwright/pages/ElementAppPage.ts b/apps/web/playwright/pages/ElementAppPage.ts index 3477289b59..62e9df90c9 100644 --- a/apps/web/playwright/pages/ElementAppPage.ts +++ b/apps/web/playwright/pages/ElementAppPage.ts @@ -9,7 +9,7 @@ Please see LICENSE files in the repository root for full details. import { type Locator, type Page, expect } from "@playwright/test"; import { readFile } from "node:fs/promises"; import { basename } from "node:path"; -import { rejectToast } from "@element-hq/element-web-playwright-common"; +import { rejectToastIfExists } from "@element-hq/element-web-playwright-common"; import { Settings } from "./settings"; import { Client } from "./client"; @@ -96,6 +96,17 @@ export class ElementAppPage { * @param name The exact room name to find and click on/open. */ public async viewRoomByName(name: string): Promise { + // Make sure the room list is actually present before we try closing toasts, + // otherwise we may race with page loading + await this.page.getByTestId("room-list").waitFor(); + + await rejectToastIfExists(this.page, "Verify this device", { timeout: 50 }); + const keyStorageToastRejected = await rejectToastIfExists(this.page, "Turn on key storage", { timeout: 50 }); + if (keyStorageToastRejected) { + await this.page.getByRole("button", { name: "Yes, dismiss" }).click(); + } + await rejectToastIfExists(this.page, "Notifications", { timeout: 50 }); + // We get the room list by test-id which is a listbox and matching title=name return this.page.getByTestId("room-list").locator(`[title="${name}"]`).first().click(); } @@ -363,7 +374,7 @@ export class ElementAppPage { * Dismiss the "Turn on key storage" toast. */ public async closeKeyStorageToast() { - await rejectToast(this.page, "Turn on key storage"); + await this.closeToast("Turn on key storage", "Dismiss"); await this.page.getByRole("button", { name: "Yes, dismiss" }).click(); } diff --git a/apps/web/playwright/snapshots/app-loading/guest-registration.spec.ts/guest-menu-linux.png b/apps/web/playwright/snapshots/app-loading/guest-registration.spec.ts/guest-menu-linux.png index 441dfefba3..03bb5ddf0e 100644 Binary files a/apps/web/playwright/snapshots/app-loading/guest-registration.spec.ts/guest-menu-linux.png and b/apps/web/playwright/snapshots/app-loading/guest-registration.spec.ts/guest-menu-linux.png differ diff --git a/apps/web/playwright/snapshots/crypto/toasts.spec.ts/key-storage-out-of-sync-toast-linux.png b/apps/web/playwright/snapshots/crypto/toasts.spec.ts/key-storage-out-of-sync-toast-linux.png index 559de9ab32..f2b0d4c12f 100644 Binary files a/apps/web/playwright/snapshots/crypto/toasts.spec.ts/key-storage-out-of-sync-toast-linux.png and b/apps/web/playwright/snapshots/crypto/toasts.spec.ts/key-storage-out-of-sync-toast-linux.png differ diff --git a/apps/web/playwright/snapshots/crypto/toasts.spec.ts/verify-this-device-linux.png b/apps/web/playwright/snapshots/crypto/toasts.spec.ts/verify-this-device-linux.png index 8838386ac3..476df6add3 100644 Binary files a/apps/web/playwright/snapshots/crypto/toasts.spec.ts/verify-this-device-linux.png and b/apps/web/playwright/snapshots/crypto/toasts.spec.ts/verify-this-device-linux.png differ diff --git a/apps/web/playwright/snapshots/left-panel/room-list-panel/room-list-collapse.spec.ts/room-list-collapse-default-linux.png b/apps/web/playwright/snapshots/left-panel/room-list-panel/room-list-collapse.spec.ts/room-list-collapse-default-linux.png index 0c96750a50..7a57fef52f 100644 Binary files a/apps/web/playwright/snapshots/left-panel/room-list-panel/room-list-collapse.spec.ts/room-list-collapse-default-linux.png and b/apps/web/playwright/snapshots/left-panel/room-list-panel/room-list-collapse.spec.ts/room-list-collapse-default-linux.png differ diff --git a/apps/web/playwright/snapshots/left-panel/room-list-panel/room-list-collapse.spec.ts/room-list-collapse-fully-collapsed-linux.png b/apps/web/playwright/snapshots/left-panel/room-list-panel/room-list-collapse.spec.ts/room-list-collapse-fully-collapsed-linux.png index 288db67450..ed983e2061 100644 Binary files a/apps/web/playwright/snapshots/left-panel/room-list-panel/room-list-collapse.spec.ts/room-list-collapse-fully-collapsed-linux.png and b/apps/web/playwright/snapshots/left-panel/room-list-panel/room-list-collapse.spec.ts/room-list-collapse-fully-collapsed-linux.png differ diff --git a/apps/web/playwright/snapshots/left-panel/room-list-panel/room-list.spec.ts/room-list-item-open-more-options-linux.png b/apps/web/playwright/snapshots/left-panel/room-list-panel/room-list.spec.ts/room-list-item-open-more-options-linux.png index ed06bfd54a..bdc992a23a 100644 Binary files a/apps/web/playwright/snapshots/left-panel/room-list-panel/room-list.spec.ts/room-list-item-open-more-options-linux.png and b/apps/web/playwright/snapshots/left-panel/room-list-panel/room-list.spec.ts/room-list-item-open-more-options-linux.png differ diff --git a/apps/web/playwright/snapshots/left-panel/room-list-panel/room-list.spec.ts/room-list-item-open-notification-options-linux.png b/apps/web/playwright/snapshots/left-panel/room-list-panel/room-list.spec.ts/room-list-item-open-notification-options-linux.png index 3a3d125e36..d553b80195 100644 Binary files a/apps/web/playwright/snapshots/left-panel/room-list-panel/room-list.spec.ts/room-list-item-open-notification-options-linux.png and b/apps/web/playwright/snapshots/left-panel/room-list-panel/room-list.spec.ts/room-list-item-open-notification-options-linux.png differ diff --git a/apps/web/playwright/snapshots/left-panel/room-list-panel/room-list.spec.ts/room-list-item-open-notification-options-selection-linux.png b/apps/web/playwright/snapshots/left-panel/room-list-panel/room-list.spec.ts/room-list-item-open-notification-options-selection-linux.png index 8333dc76e7..cc6d638807 100644 Binary files a/apps/web/playwright/snapshots/left-panel/room-list-panel/room-list.spec.ts/room-list-item-open-notification-options-selection-linux.png and b/apps/web/playwright/snapshots/left-panel/room-list-panel/room-list.spec.ts/room-list-item-open-notification-options-selection-linux.png differ diff --git a/apps/web/playwright/snapshots/settings/appearance-user-settings-tab/appearance-user-settings-tab.spec.ts/window-12px-linux.png b/apps/web/playwright/snapshots/settings/appearance-user-settings-tab/appearance-user-settings-tab.spec.ts/window-12px-linux.png index 47048b97b1..62c9b95d5f 100644 Binary files a/apps/web/playwright/snapshots/settings/appearance-user-settings-tab/appearance-user-settings-tab.spec.ts/window-12px-linux.png and b/apps/web/playwright/snapshots/settings/appearance-user-settings-tab/appearance-user-settings-tab.spec.ts/window-12px-linux.png differ diff --git a/apps/web/playwright/snapshots/settings/appearance-user-settings-tab/appearance-user-settings-tab.spec.ts/window-after-switch-linux.png b/apps/web/playwright/snapshots/settings/appearance-user-settings-tab/appearance-user-settings-tab.spec.ts/window-after-switch-linux.png index c1607c9a8f..539366793e 100644 Binary files a/apps/web/playwright/snapshots/settings/appearance-user-settings-tab/appearance-user-settings-tab.spec.ts/window-after-switch-linux.png and b/apps/web/playwright/snapshots/settings/appearance-user-settings-tab/appearance-user-settings-tab.spec.ts/window-after-switch-linux.png differ diff --git a/apps/web/playwright/snapshots/settings/appearance-user-settings-tab/appearance-user-settings-tab.spec.ts/window-before-switch-linux.png b/apps/web/playwright/snapshots/settings/appearance-user-settings-tab/appearance-user-settings-tab.spec.ts/window-before-switch-linux.png index 2412bd9963..165064ec2e 100644 Binary files a/apps/web/playwright/snapshots/settings/appearance-user-settings-tab/appearance-user-settings-tab.spec.ts/window-before-switch-linux.png and b/apps/web/playwright/snapshots/settings/appearance-user-settings-tab/appearance-user-settings-tab.spec.ts/window-before-switch-linux.png differ diff --git a/apps/web/playwright/snapshots/settings/appearance-user-settings-tab/theme-choice-panel.spec.ts/window-custom-theme-linux.png b/apps/web/playwright/snapshots/settings/appearance-user-settings-tab/theme-choice-panel.spec.ts/window-custom-theme-linux.png index 19e7689a64..28043b7da7 100644 Binary files a/apps/web/playwright/snapshots/settings/appearance-user-settings-tab/theme-choice-panel.spec.ts/window-custom-theme-linux.png and b/apps/web/playwright/snapshots/settings/appearance-user-settings-tab/theme-choice-panel.spec.ts/window-custom-theme-linux.png differ diff --git a/apps/web/playwright/snapshots/spaces/spaces.spec.ts/space-panel-collapsed-linux.png b/apps/web/playwright/snapshots/spaces/spaces.spec.ts/space-panel-collapsed-linux.png index 7b3063a2df..8b1375480b 100644 Binary files a/apps/web/playwright/snapshots/spaces/spaces.spec.ts/space-panel-collapsed-linux.png and b/apps/web/playwright/snapshots/spaces/spaces.spec.ts/space-panel-collapsed-linux.png differ diff --git a/apps/web/playwright/snapshots/spaces/spaces.spec.ts/space-panel-expanded-linux.png b/apps/web/playwright/snapshots/spaces/spaces.spec.ts/space-panel-expanded-linux.png index f187b3cab3..a55f268719 100644 Binary files a/apps/web/playwright/snapshots/spaces/spaces.spec.ts/space-panel-expanded-linux.png and b/apps/web/playwright/snapshots/spaces/spaces.spec.ts/space-panel-expanded-linux.png differ diff --git a/apps/web/playwright/snapshots/spaces/threads-activity-centre/threadsActivityCentre.spec.ts/tac-button-expanded-linux.png b/apps/web/playwright/snapshots/spaces/threads-activity-centre/threadsActivityCentre.spec.ts/tac-button-expanded-linux.png index f3e182ae4d..fc087b9482 100644 Binary files a/apps/web/playwright/snapshots/spaces/threads-activity-centre/threadsActivityCentre.spec.ts/tac-button-expanded-linux.png and b/apps/web/playwright/snapshots/spaces/threads-activity-centre/threadsActivityCentre.spec.ts/tac-button-expanded-linux.png differ diff --git a/apps/web/playwright/snapshots/spaces/threads-activity-centre/threadsActivityCentre.spec.ts/tac-hovered-expanded-linux.png b/apps/web/playwright/snapshots/spaces/threads-activity-centre/threadsActivityCentre.spec.ts/tac-hovered-expanded-linux.png index 596a9c30b1..f97de99cd9 100644 Binary files a/apps/web/playwright/snapshots/spaces/threads-activity-centre/threadsActivityCentre.spec.ts/tac-hovered-expanded-linux.png and b/apps/web/playwright/snapshots/spaces/threads-activity-centre/threadsActivityCentre.spec.ts/tac-hovered-expanded-linux.png differ diff --git a/apps/web/playwright/snapshots/spaces/threads-activity-centre/threadsActivityCentre.spec.ts/tac-hovered-linux.png b/apps/web/playwright/snapshots/spaces/threads-activity-centre/threadsActivityCentre.spec.ts/tac-hovered-linux.png index 4952185cd1..7d24702725 100644 Binary files a/apps/web/playwright/snapshots/spaces/threads-activity-centre/threadsActivityCentre.spec.ts/tac-hovered-linux.png and b/apps/web/playwright/snapshots/spaces/threads-activity-centre/threadsActivityCentre.spec.ts/tac-hovered-linux.png differ diff --git a/apps/web/playwright/snapshots/user-menu/user-menu.spec.ts/user-menu-linux.png b/apps/web/playwright/snapshots/user-menu/user-menu.spec.ts/user-menu-linux.png index 64fc5585ec..b6b6418888 100644 Binary files a/apps/web/playwright/snapshots/user-menu/user-menu.spec.ts/user-menu-linux.png and b/apps/web/playwright/snapshots/user-menu/user-menu.spec.ts/user-menu-linux.png differ diff --git a/apps/web/playwright/snapshots/voip/element-call.spec.ts/incoming-call-dm-video-toast-checked-linux.png b/apps/web/playwright/snapshots/voip/element-call.spec.ts/incoming-call-dm-video-toast-checked-linux.png index 1faf65f023..d533dceeac 100644 Binary files a/apps/web/playwright/snapshots/voip/element-call.spec.ts/incoming-call-dm-video-toast-checked-linux.png and b/apps/web/playwright/snapshots/voip/element-call.spec.ts/incoming-call-dm-video-toast-checked-linux.png differ diff --git a/apps/web/playwright/snapshots/voip/element-call.spec.ts/incoming-call-dm-video-toast-unchecked-linux.png b/apps/web/playwright/snapshots/voip/element-call.spec.ts/incoming-call-dm-video-toast-unchecked-linux.png index fda6c35a6a..5995b7a928 100644 Binary files a/apps/web/playwright/snapshots/voip/element-call.spec.ts/incoming-call-dm-video-toast-unchecked-linux.png and b/apps/web/playwright/snapshots/voip/element-call.spec.ts/incoming-call-dm-video-toast-unchecked-linux.png differ diff --git a/apps/web/playwright/snapshots/voip/element-call.spec.ts/incoming-call-dm-voice-toast-linux.png b/apps/web/playwright/snapshots/voip/element-call.spec.ts/incoming-call-dm-voice-toast-linux.png index 96b096905d..afc58fd22e 100644 Binary files a/apps/web/playwright/snapshots/voip/element-call.spec.ts/incoming-call-dm-voice-toast-linux.png and b/apps/web/playwright/snapshots/voip/element-call.spec.ts/incoming-call-dm-voice-toast-linux.png differ diff --git a/apps/web/playwright/snapshots/voip/element-call.spec.ts/incoming-call-group-video-toast-checked-linux.png b/apps/web/playwright/snapshots/voip/element-call.spec.ts/incoming-call-group-video-toast-checked-linux.png index 711d748767..a7fced9c8b 100644 Binary files a/apps/web/playwright/snapshots/voip/element-call.spec.ts/incoming-call-group-video-toast-checked-linux.png and b/apps/web/playwright/snapshots/voip/element-call.spec.ts/incoming-call-group-video-toast-checked-linux.png differ diff --git a/apps/web/playwright/snapshots/voip/element-call.spec.ts/incoming-call-group-video-toast-unchecked-linux.png b/apps/web/playwright/snapshots/voip/element-call.spec.ts/incoming-call-group-video-toast-unchecked-linux.png index 431b137108..c2f39b5855 100644 Binary files a/apps/web/playwright/snapshots/voip/element-call.spec.ts/incoming-call-group-video-toast-unchecked-linux.png and b/apps/web/playwright/snapshots/voip/element-call.spec.ts/incoming-call-group-video-toast-unchecked-linux.png differ diff --git a/apps/web/playwright/snapshots/voip/element-call.spec.ts/incoming-call-group-voice-toast-linux.png b/apps/web/playwright/snapshots/voip/element-call.spec.ts/incoming-call-group-voice-toast-linux.png index 974b14344a..ab5bbed950 100644 Binary files a/apps/web/playwright/snapshots/voip/element-call.spec.ts/incoming-call-group-voice-toast-linux.png and b/apps/web/playwright/snapshots/voip/element-call.spec.ts/incoming-call-group-voice-toast-linux.png differ diff --git a/apps/web/res/css/structures/_ToastContainer.pcss b/apps/web/res/css/structures/_ToastContainer.pcss index 5d73403be2..6f5b8158ec 100644 --- a/apps/web/res/css/structures/_ToastContainer.pcss +++ b/apps/web/res/css/structures/_ToastContainer.pcss @@ -9,10 +9,9 @@ Please see LICENSE files in the repository root for full details. .mx_ToastContainer { position: absolute; - top: 0; - left: 70px; + top: 12px; + left: 62px; z-index: 101; - padding: 4px; display: grid; grid-template-rows: 1fr 28px 8px; @@ -33,7 +32,7 @@ Please see LICENSE files in the repository root for full details. color: $primary-content; box-shadow: 0px 4px 24px rgb(0, 0, 0, 0.1); border: var(--cpd-border-width-1) solid var(--cpd-color-border-interactive-secondary); - border-radius: calc(var(--cpd-space-6x) - var(--cpd-border-width-1)); + border-radius: var(--cpd-space-3x); overflow: hidden; display: grid; grid-template-columns: 20px 1fr auto; diff --git a/apps/web/test/unit-tests/components/views/spaces/__snapshots__/SpacePanel-test.tsx.snap b/apps/web/test/unit-tests/components/views/spaces/__snapshots__/SpacePanel-test.tsx.snap index 6a964e90e0..a1c6cd2301 100644 --- a/apps/web/test/unit-tests/components/views/spaces/__snapshots__/SpacePanel-test.tsx.snap +++ b/apps/web/test/unit-tests/components/views/spaces/__snapshots__/SpacePanel-test.tsx.snap @@ -6,26 +6,30 @@ exports[` should show all activated MetaSpaces in the correct orde aria-label="Spaces" class="mx_SpacePanel collapsed newUi" > - + + t + + +
{ - return await clickToastButton(page, title, "primary"); + await clickToastButton(page, title, "primary"); } /** @@ -75,8 +75,10 @@ export async function acceptToast(page: Page, title: string): Promise { * @public * @param page - Playwright page we are working with. * @param title - Expected title of the toast. + * + * @returns true if the toast was found and the button was clicked, or false if the toast was not found (always returns true if `required` is true). */ -export async function acceptToastIfExists(page: Page, title: string): Promise { +export async function acceptToastIfExists(page: Page, title: string): Promise { return await clickToastButton(page, title, "primary", 2000, false); } @@ -90,7 +92,7 @@ export async function acceptToastIfExists(page: Page, title: string): Promise { - return await clickToastButton(page, title, "secondary"); + await clickToastButton(page, title, "secondary"); } /** @@ -102,9 +104,17 @@ export async function rejectToast(page: Page, title: string): Promise { * @public * @param page - Playwright page we are working with. * @param title - Expected title of the toast. + * @param options.timeout - Time in ms before we give up and decide the toast does not exist. + * + * @returns true if the toast was found and the button was clicked, or false if the toast was not found (always returns true if `required` is true). */ -export async function rejectToastIfExists(page: Page, title: string): Promise { - return await clickToastButton(page, title, "secondary", 2000, false); +export async function rejectToastIfExists( + page: Page, + title: string, + options: { timeout?: number } = {}, +): Promise { + const { timeout = 2000 } = options; + return await clickToastButton(page, title, "secondary", timeout, false); } /** @@ -127,6 +137,7 @@ export async function rejectToastIfExists(page: Page, title: string): Promise { +): Promise { let toast: Locator | null; if (required) { toast = await getToast(page, title, timeout); @@ -144,5 +155,7 @@ async function clickToastButton( if (toast) { await toast.locator(`.mx_Toast_buttons button[data-kind="${button}"]`).click(); + return true; } + return false; } diff --git a/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/all-options-auto.png b/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/all-options-auto.png index 26a942c132..b7c8ed96a4 100644 Binary files a/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/all-options-auto.png and b/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/all-options-auto.png differ diff --git a/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/condensed-auto.png b/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/condensed-auto.png index 2988063a74..02e3e526dd 100644 Binary files a/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/condensed-auto.png and b/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/condensed-auto.png differ diff --git a/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/default-auto.png b/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/default-auto.png index 681b200269..874bddd1c5 100644 Binary files a/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/default-auto.png and b/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/default-auto.png differ diff --git a/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/guest-auto.png b/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/guest-auto.png index b3cb9de8f8..7d61c64fed 100644 Binary files a/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/guest-auto.png and b/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/guest-auto.png differ diff --git a/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/guest-open-auto.png b/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/guest-open-auto.png index 001717f59f..1b76d9b9ff 100644 Binary files a/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/guest-open-auto.png and b/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/guest-open-auto.png differ diff --git a/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/longer-name-auto.png b/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/longer-name-auto.png index 7d385dcbd7..e756e557d9 100644 Binary files a/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/longer-name-auto.png and b/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/longer-name-auto.png differ diff --git a/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/no-avatar-auto.png b/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/no-avatar-auto.png new file mode 100644 index 0000000000..98d1d362f8 Binary files /dev/null and b/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/no-avatar-auto.png differ diff --git a/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/open-auto.png b/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/open-auto.png index 8dc8927d92..4be221e456 100644 Binary files a/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/open-auto.png and b/packages/shared-components/__vis__/linux/__baselines__/menus/UserMenu/UserMenu.stories.tsx/open-auto.png differ diff --git a/packages/shared-components/src/menus/UserMenu/UserMenu.module.css b/packages/shared-components/src/menus/UserMenu/UserMenu.module.css index fa3321114a..67f59e2f39 100644 --- a/packages/shared-components/src/menus/UserMenu/UserMenu.module.css +++ b/packages/shared-components/src/menus/UserMenu/UserMenu.module.css @@ -5,6 +5,13 @@ * Please see LICENSE files in the repository root for full details. */ +.wrapper { + display: flex; + align-items: center; + margin-top: var(--cpd-space-3x); + margin-bottom: var(--cpd-space-4x); +} + .container { /* As per design, seperator should span whole width. */ div[role="separator"] { @@ -50,6 +57,7 @@ .triggerButton { border: none; background: none; + padding: 0; display: flex; color: var(--cpd-color-body-primary); cursor: pointer; @@ -63,7 +71,7 @@ overflow: hidden; text-wrap: nowrap; } - margin-top: var(--cpd-space-3x); - margin-bottom: var(--cpd-space-4x); margin-left: var(--cpd-space-3x); + margin-right: var(--cpd-space-2x); + padding-inline-start: var(--cpd-space-1-5x); } diff --git a/packages/shared-components/src/menus/UserMenu/UserMenu.stories.tsx b/packages/shared-components/src/menus/UserMenu/UserMenu.stories.tsx index 2a5b809ce1..79b7ad6350 100644 --- a/packages/shared-components/src/menus/UserMenu/UserMenu.stories.tsx +++ b/packages/shared-components/src/menus/UserMenu/UserMenu.stories.tsx @@ -110,6 +110,17 @@ export const Condensed: Story = { }, }; +export const NoAvatar: Story = { + args: { + displayName: "Sally Sanderson", + userId: "@person-name:homeserver.com", + expanded: true, + open: true, + showAvatar: false, + }, + parameters: Open.parameters, +}; + export const Guest: Story = { args: { displayName: "Guest", diff --git a/packages/shared-components/src/menus/UserMenu/UserMenu.test.tsx b/packages/shared-components/src/menus/UserMenu/UserMenu.test.tsx index e8539ed76a..f1eacc0f4e 100644 --- a/packages/shared-components/src/menus/UserMenu/UserMenu.test.tsx +++ b/packages/shared-components/src/menus/UserMenu/UserMenu.test.tsx @@ -13,7 +13,7 @@ import userEvent from "@testing-library/user-event"; import * as stories from "./UserMenu.stories.tsx"; -const { Default, LongerName, Condensed, Guest } = composeStories(stories); +const { Default, LongerName, Condensed, Guest, Open, NoAvatar } = composeStories(stories); describe("UserMenu", () => { it("renders a button", async () => { @@ -38,4 +38,12 @@ describe("UserMenu", () => { await userEvent.click(getByRole("button")); expect(baseElement).toMatchSnapshot(); }); + it("renders an open menu", async () => { + const { baseElement } = render(); + expect(baseElement).toMatchSnapshot(); + }); + it("renders a menu without an avatar", async () => { + const { baseElement } = render(); + expect(baseElement).toMatchSnapshot(); + }); }); diff --git a/packages/shared-components/src/menus/UserMenu/UserMenu.tsx b/packages/shared-components/src/menus/UserMenu/UserMenu.tsx index 3389cba8f8..0bba25cdc4 100644 --- a/packages/shared-components/src/menus/UserMenu/UserMenu.tsx +++ b/packages/shared-components/src/menus/UserMenu/UserMenu.tsx @@ -102,7 +102,7 @@ export declare interface UserMenuViewActions { export type UserMenuViewProps = { vm: ViewModel; /** - * Class name for the container + * Class name for the trigger */ className?: string; }; @@ -113,75 +113,92 @@ export function UserMenuView({ vm, className }: UserMenuViewProps): JSX.Element const trigger = ( + ); + + // The menu should appear to the right of the avatar, over the displayname if the menu is expanded, + // so the display name goes outside the menu block in a wrapper. + return ( +
+ +
+ {showAvatar && } + + {displayName} + + + {userId} + + {manageAccountHref && ( + + )} + {actions.createAccount && ( + + )} + {actions.signIn && ( + + {_t("menus|user_menu|got_an_account")} + + {_t("menus|user_menu|sign_in")} + + + )} +
+ +
+ {actions.openHomePage && ( + + )} + {actions.linkNewDevice && ( + + )} + {actions.openSecurity && ( + + )} + {actions.openFeedback && ( + + )} + {actions.openSettings && ( + + )} +
+
{expanded && ( {displayName} )} - - ); - return ( - -
- {showAvatar && } - - {displayName} - - - {userId} - - {manageAccountHref && ( - - )} - {actions.createAccount && ( - - )} - {actions.signIn && ( - - {_t("menus|user_menu|got_an_account")} - - {_t("menus|user_menu|sign_in")} - - - )} -
- -
- {actions.openHomePage && ( - - )} - {actions.linkNewDevice && ( - - )} - {actions.openSecurity && ( - - )} - {actions.openFeedback && ( - - )} - {actions.openSettings && ( - - )} -
-
+
); } diff --git a/packages/shared-components/src/menus/UserMenu/__snapshots__/UserMenu.test.tsx.snap b/packages/shared-components/src/menus/UserMenu/__snapshots__/UserMenu.test.tsx.snap index 91e00d35fd..8eba39a162 100644 --- a/packages/shared-components/src/menus/UserMenu/__snapshots__/UserMenu.test.tsx.snap +++ b/packages/shared-components/src/menus/UserMenu/__snapshots__/UserMenu.test.tsx.snap @@ -2,141 +2,16 @@ exports[`UserMenu > renders a button 1`] = `
- -
-`; - -exports[`UserMenu > renders a button with a longer name 1`] = ` -
- -
-`; - -exports[`UserMenu > renders a guest menu 1`] = ` - - - - - -
-
- -`; - -exports[`UserMenu > renders a menu 1`] = ` - - - - - -
- + + Sally Sanderson + +
+
+`; + +exports[`UserMenu > renders a button with a longer name 1`] = ` +
+
+ + + Sally Sanderson with a longer name + +
+
+`; + +exports[`UserMenu > renders a guest menu 1`] = ` + + + + + +
+
+ + + Guest + +
+
+ +`; + +exports[`UserMenu > renders a menu 1`] = ` + + + + + +
+
+ Sally Sanderson - +
`; +exports[`UserMenu > renders a menu without an avatar 1`] = ` + +