Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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(<OnboardingPreviewCard reviewability={REVIEWABILITY} />);

// 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,
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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(<NotificationReadinessCard />);

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(<NotificationReadinessCard />);

expect(screen.getByText("opt-in required")).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export function NotificationReadinessCard() {
const [optIn, setOptIn] = useLocalStorage<boolean>(
"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);

Expand Down
Loading