diff --git a/apps/loopover-ui/src/components/site/app-panels/onboarding-preview-card.test.tsx b/apps/loopover-ui/src/components/site/app-panels/onboarding-preview-card.test.tsx index 4a6beac325..1cf3adadb5 100644 --- a/apps/loopover-ui/src/components/site/app-panels/onboarding-preview-card.test.tsx +++ b/apps/loopover-ui/src/components/site/app-panels/onboarding-preview-card.test.tsx @@ -145,4 +145,20 @@ describe("OnboardingPreviewCard", () => { expect(screen.queryByText(/Here's what LoopOver would have flagged/)).toBeNull(); expect(apiFetch).not.toHaveBeenCalled(); }); + + it("honors a pre-rebrand dismissal stored under the legacy key and migrates it forward (#7782)", () => { + apiFetch.mockResolvedValue({ ok: true, data: preview() }); + const dismissed = JSON.stringify({ dismissed: true }); + window.localStorage.setItem("gittensory_maintainer_onboarding_preview_dismissed", dismissed); + + render(); + + // The card stays dismissed for a maintainer who dismissed it before the rebrand... + expect(screen.queryByText(/Here's what LoopOver would have flagged/)).toBeNull(); + expect(apiFetch).not.toHaveBeenCalled(); + // ...and the legacy value is written forward so later reads hit the current key directly. + expect(window.localStorage.getItem("loopover_maintainer_onboarding_preview_dismissed")).toBe( + dismissed, + ); + }); }); diff --git a/apps/loopover-ui/src/components/site/app-panels/onboarding-preview-card.tsx b/apps/loopover-ui/src/components/site/app-panels/onboarding-preview-card.tsx index 7e754f20e3..fe3c3e903d 100644 --- a/apps/loopover-ui/src/components/site/app-panels/onboarding-preview-card.tsx +++ b/apps/loopover-ui/src/components/site/app-panels/onboarding-preview-card.tsx @@ -19,7 +19,7 @@ type ReviewabilityRow = { pr: string; title: string; reason: string }; const DISMISS_KEY = "loopover_maintainer_onboarding_preview_dismissed"; // One-time rebrand migration fallback -- see useLocalStorage's legacyKey param. -const LEGACY_DISMISS_KEY = "loopover_maintainer_onboarding_preview_dismissed"; +const LEGACY_DISMISS_KEY = "gittensory_maintainer_onboarding_preview_dismissed"; /** Builds a settings-preview form from a REAL cached PR (title, and a linked-issue number scraped from * `reason` when present) — everything else (author identity, labels, body) isn't in the reviewability diff --git a/apps/loopover-ui/src/components/site/notification-readiness-card.test.tsx b/apps/loopover-ui/src/components/site/notification-readiness-card.test.tsx index c5a42c53a1..f0cd5d8472 100644 --- a/apps/loopover-ui/src/components/site/notification-readiness-card.test.tsx +++ b/apps/loopover-ui/src/components/site/notification-readiness-card.test.tsx @@ -1,5 +1,5 @@ import { fireEvent, render, screen } from "@testing-library/react"; -import { describe, expect, it, vi } from "vitest"; +import { beforeEach, describe, expect, it, vi } from "vitest"; // #6985: a real fetch failure used to render the same generic text as "still loading" — these tests // pin the three render paths (loading / error / success) now that LoadingState/ErrorState replace it. @@ -95,3 +95,31 @@ describe("NotificationReadinessCard loading/error states (#6985)", () => { expect(screen.queryByText("Loading notification model…")).toBeNull(); }); }); + +describe("NotificationReadinessCard legacy opt-in migration (#7782)", () => { + beforeEach(() => { + window.localStorage.clear(); + useApiResource.mockReturnValue({ + status: "ready", + data: notificationModelFixture, + error: null, + loadedAt: Date.now(), + reload: () => {}, + }); + }); + + it("reads a pre-rebrand opt-in stored under the legacy key and migrates it forward", () => { + window.localStorage.setItem("gittensory_notification_opt_in", "true"); + + render(); + + expect(screen.getByText("opt-in enabled")).toBeTruthy(); + expect(window.localStorage.getItem("loopover_notification_opt_in")).toBe("true"); + }); + + it("stays opted out when neither the current nor the legacy key is set", () => { + render(); + + expect(screen.getByText("opt-in required")).toBeTruthy(); + }); +}); diff --git a/apps/loopover-ui/src/components/site/notification-readiness-card.tsx b/apps/loopover-ui/src/components/site/notification-readiness-card.tsx index 36459045c2..a3a2fc0d0e 100644 --- a/apps/loopover-ui/src/components/site/notification-readiness-card.tsx +++ b/apps/loopover-ui/src/components/site/notification-readiness-card.tsx @@ -33,7 +33,8 @@ export function NotificationReadinessCard() { const [optIn, setOptIn] = useLocalStorage( "loopover_notification_opt_in", false, - "loopover_notification_opt_in", + // One-time rebrand migration fallback -- see useLocalStorage's legacyKey param. + "gittensory_notification_opt_in", ); const [busy, setBusy] = useState(false);