|
1 | | -import { fireEvent, render, screen } from "@testing-library/react"; |
2 | | -import { describe, expect, it, vi } from "vitest"; |
| 1 | +import { fireEvent, render, screen, waitFor } from "@testing-library/react"; |
| 2 | +import { beforeEach, describe, expect, it, vi } from "vitest"; |
3 | 3 |
|
4 | 4 | // #6985: a real fetch failure used to render the same generic text as "still loading" — these tests |
5 | 5 | // pin the three render paths (loading / error / success) now that LoadingState/ErrorState replace it. |
@@ -31,6 +31,10 @@ const notificationModelFixture = { |
31 | 31 | }; |
32 | 32 |
|
33 | 33 | describe("NotificationReadinessCard loading/error states (#6985)", () => { |
| 34 | + beforeEach(() => { |
| 35 | + window.localStorage.clear(); |
| 36 | + }); |
| 37 | + |
34 | 38 | it("shows a LoadingState (not the generic spinner-free text) while the model loads", () => { |
35 | 39 | useApiResource.mockReturnValue({ |
36 | 40 | status: "loading", |
@@ -94,4 +98,20 @@ describe("NotificationReadinessCard loading/error states (#6985)", () => { |
94 | 98 | expect(container.textContent).toContain("No content leaves the browser without consent."); |
95 | 99 | expect(screen.queryByText("Loading notification model…")).toBeNull(); |
96 | 100 | }); |
| 101 | + |
| 102 | + it("migrates a pre-rebrand gittensory_ opt-in flag so the pill shows enabled (#7782)", async () => { |
| 103 | + window.localStorage.setItem("gittensory_notification_opt_in", JSON.stringify(true)); |
| 104 | + useApiResource.mockReturnValue({ |
| 105 | + status: "ready", |
| 106 | + data: notificationModelFixture, |
| 107 | + error: null, |
| 108 | + loadedAt: Date.now(), |
| 109 | + reload: () => {}, |
| 110 | + }); |
| 111 | + |
| 112 | + render(<NotificationReadinessCard />); |
| 113 | + await waitFor(() => expect(screen.getByText("opt-in enabled")).toBeTruthy()); |
| 114 | + expect(window.localStorage.getItem("loopover_notification_opt_in")).toBe(JSON.stringify(true)); |
| 115 | + expect(screen.queryByText("opt-in required")).toBeNull(); |
| 116 | + }); |
97 | 117 | }); |
0 commit comments