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_NOTES,21 hasReleaseNotes,22 shouldShowWhatsNew,23 markWhatsNewSeen,24} = await import("./release-notes");2526describe("release-notes", () => {27 beforeEach(() => {28 Object.keys(store).forEach((k) => delete store[k]);29 vi.clearAllMocks();30 });3132 it("PEACH_VERSION is a non-empty string", () => {33 expect(typeof PEACH_VERSION).toBe("string");34 expect(PEACH_VERSION.length).toBeGreaterThan(0);35 });3637 it("CURRENT_NOTES has entries for the V4 release", () => {38 expect(CURRENT_NOTES.length).toBeGreaterThan(0);39 const breaking = CURRENT_NOTES.find((n) => n.breaking);40 expect(breaking).toBeDefined();41 expect(breaking!.body.toLowerCase()).toContain("android");42 });4344 it("hasReleaseNotes returns true when notes exist", () => {45 expect(hasReleaseNotes()).toBe(true);46 });4748 it("shouldShowWhatsNew returns true when stored version differs", async () => {49 store["peach_whats_new_seen"] = "0.0.1";50 expect(await shouldShowWhatsNew()).toBe(true);51 });5253 it("shouldShowWhatsNew returns false when stored version matches", async () => {54 store["peach_whats_new_seen"] = PEACH_VERSION;55 expect(await shouldShowWhatsNew()).toBe(false);56 });5758 it("shouldShowWhatsNew returns false on a fresh install (nothing seen yet)", async () => {59 expect(await shouldShowWhatsNew()).toBe(false);60 });6162 it("markWhatsNewSeen stores the current version and suppresses reshowing", async () => {63 64 store["peach_whats_new_seen"] = "0.0.1";65 expect(await shouldShowWhatsNew()).toBe(true);66 await markWhatsNewSeen();67 expect(await shouldShowWhatsNew()).toBe(false);68 expect(store["peach_whats_new_seen"]).toBe(PEACH_VERSION);69 });7071 it("a version bump re-triggers the screen", async () => {72 await markWhatsNewSeen();73 expect(await shouldShowWhatsNew()).toBe(false);74 75 store["peach_whats_new_seen"] = "5.0.0";76 expect(await shouldShowWhatsNew()).toBe(true);77 });78});