1import { describe, it, expect, beforeEach, vi } from "vitest";234const store: Record<string, unknown> = {};56vi.stubGlobal("chrome", {7 storage: {8 local: {9 get: vi.fn(async (key: string) => ({ [key]: store[key] })),10 set: vi.fn(async (entries: Record<string, unknown>) => {11 Object.assign(store, entries);12 }),13 },14 },15});161718const {19 PEACH_VERSION,20 CURRENT_NOTICE_ID,21 CURRENT_NOTES,22 hasReleaseNotes,23 shouldShowWhatsNew,24 markWhatsNewSeen,25} = await import("./release-notes");2627describe("release-notes", () => {28 beforeEach(() => {29 Object.keys(store).forEach((k) => delete store[k]);30 vi.clearAllMocks();31 });3233 it("PEACH_VERSION is a non-empty string", () => {34 expect(typeof PEACH_VERSION).toBe("string");35 expect(PEACH_VERSION.length).toBeGreaterThan(0);36 });3738 it("CURRENT_NOTES has entries for the V4 release", () => {39 expect(CURRENT_NOTES.length).toBeGreaterThan(0);40 const breaking = CURRENT_NOTES.find((n) => n.breaking);41 expect(breaking).toBeDefined();42 expect(breaking!.body.toLowerCase()).toContain("android");43 });4445 it("hasReleaseNotes returns true when notes exist", () => {46 expect(hasReleaseNotes()).toBe(true);47 });4849 it("shouldShowWhatsNew returns true when the important notice changes", async () => {50 store["peach_whats_new_seen"] = "previous-critical-notice";51 expect(await shouldShowWhatsNew()).toBe(true);52 });5354 it("shouldShowWhatsNew returns false when the important notice matches", async () => {55 store["peach_whats_new_seen"] = CURRENT_NOTICE_ID;56 expect(await shouldShowWhatsNew()).toBe(false);57 });5859 it("does not reshow unchanged notes after a patch-version dismissal", async () => {60 store["peach_whats_new_seen"] = "5.2.3";61 expect(await shouldShowWhatsNew()).toBe(false);62 expect(store["peach_whats_new_seen"]).toBe(CURRENT_NOTICE_ID);63 });6465 it("shouldShowWhatsNew returns false on a fresh install (nothing seen yet)", async () => {66 expect(await shouldShowWhatsNew()).toBe(false);67 });6869 it("markWhatsNewSeen stores the current version and suppresses reshowing", async () => {70 71 store["peach_whats_new_seen"] = "previous-critical-notice";72 expect(await shouldShowWhatsNew()).toBe(true);73 await markWhatsNewSeen();74 expect(await shouldShowWhatsNew()).toBe(false);75 expect(store["peach_whats_new_seen"]).toBe(CURRENT_NOTICE_ID);76 });7778 it("a new important notice re-triggers the screen", async () => {79 await markWhatsNewSeen();80 expect(await shouldShowWhatsNew()).toBe(false);81 store["peach_whats_new_seen"] = "future-breaking-notice";82 expect(await shouldShowWhatsNew()).toBe(true);83 });84});