diff --git a/playwright/e2e/release-announcement/releaseAnnouncement.spec.ts b/playwright/e2e/release-announcement/releaseAnnouncement.spec.ts index 6e6e26ea6f..080c1b0329 100644 --- a/playwright/e2e/release-announcement/releaseAnnouncement.spec.ts +++ b/playwright/e2e/release-announcement/releaseAnnouncement.spec.ts @@ -29,6 +29,9 @@ test.describe("Release announcement", () => { "should display the new room list release announcement", { tag: "@screenshot" }, async ({ page, app, room, util }) => { + // dismiss the toast so the announcement appears + await page.getByRole("button", { name: "Dismiss" }).click(); + const name = "Chats has a new look!"; // The release announcement should be displayed diff --git a/playwright/snapshots/release-announcement/releaseAnnouncement.spec.ts/release-announcement-Chats-has-a-new-look--linux.png b/playwright/snapshots/release-announcement/releaseAnnouncement.spec.ts/release-announcement-Chats-has-a-new-look--linux.png index 56b301d4cc..54deb9e4a6 100644 Binary files a/playwright/snapshots/release-announcement/releaseAnnouncement.spec.ts/release-announcement-Chats-has-a-new-look--linux.png and b/playwright/snapshots/release-announcement/releaseAnnouncement.spec.ts/release-announcement-Chats-has-a-new-look--linux.png differ diff --git a/src/stores/ReleaseAnnouncementStore.ts b/src/stores/ReleaseAnnouncementStore.ts index f31e5a5c02..67e37ef773 100644 --- a/src/stores/ReleaseAnnouncementStore.ts +++ b/src/stores/ReleaseAnnouncementStore.ts @@ -13,6 +13,7 @@ import { cloneDeep } from "lodash"; import SettingsStore from "../settings/SettingsStore"; import { SettingLevel } from "../settings/SettingLevel"; import { Features } from "../settings/Settings"; +import ToastStore from "./ToastStore"; /** * The features are shown in the array order. @@ -76,6 +77,9 @@ export class ReleaseAnnouncementStore extends TypedEventEmitter { this.emit("releaseAnnouncementChanged", this.getReleaseAnnouncement()); }); + ToastStore.sharedInstance().on("update", () => { + this.emit("releaseAnnouncementChanged", this.getReleaseAnnouncement()); + }); } /** @@ -104,6 +108,9 @@ export class ReleaseAnnouncementStore extends TypedEventEmitter 0) return null; + const viewedReleaseAnnouncements = this.getViewedReleaseAnnouncements(); // Find the first feature that has not been viewed diff --git a/test/unit-tests/stores/ReleaseAnnouncementStore-test.tsx b/test/unit-tests/stores/ReleaseAnnouncementStore-test.tsx index 58f67b696f..7381c1f9c5 100644 --- a/test/unit-tests/stores/ReleaseAnnouncementStore-test.tsx +++ b/test/unit-tests/stores/ReleaseAnnouncementStore-test.tsx @@ -11,8 +11,10 @@ import { mocked } from "jest-mock"; import SettingsStore, { type CallbackFn } from "../../../src/settings/SettingsStore"; import { type Feature, ReleaseAnnouncementStore } from "../../../src/stores/ReleaseAnnouncementStore"; import { type SettingLevel } from "../../../src/settings/SettingLevel"; +import ToastStore from "../../../src/stores/ToastStore"; jest.mock("../../../src/settings/SettingsStore"); +jest.mock("../../../src/stores/ToastStore"); describe("ReleaseAnnouncementStore", () => { let releaseAnnouncementStore: ReleaseAnnouncementStore; @@ -48,6 +50,11 @@ describe("ReleaseAnnouncementStore", () => { return "watcherId"; }); + mocked(ToastStore.sharedInstance).mockReturnValue({ + on: jest.fn(), + getToasts: jest.fn().mockReturnValue([]), + } as any); + releaseAnnouncementStore = new ReleaseAnnouncementStore(); }); @@ -118,4 +125,10 @@ describe("ReleaseAnnouncementStore", () => { expect(await promise).toBe("newRoomList_sort"); expect(releaseAnnouncementStore.getReleaseAnnouncement()).toBe("newRoomList_sort"); }); + + it("should return null when there are toasts on screen", async () => { + mocked(ToastStore.sharedInstance().getToasts).mockReturnValue([{} as any]); + + expect(releaseAnnouncementStore.getReleaseAnnouncement()).toBeNull(); + }); });