Skip to content
Merged
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("migrates a pre-rebrand dismiss flag so the card stays hidden (#7782)", async () => {
window.localStorage.setItem(
"gittensory_maintainer_onboarding_preview_dismissed",
JSON.stringify({ dismissed: true }),
);
apiFetch.mockResolvedValue({ ok: true, data: preview() });
render(<OnboardingPreviewCard reviewability={REVIEWABILITY} />);
await waitFor(() =>
expect(window.localStorage.getItem("loopover_maintainer_onboarding_preview_dismissed")).toBe(
JSON.stringify({ dismissed: true }),
),
);
expect(screen.queryByText(/Here's what LoopOver would have flagged/)).toBeNull();
expect(apiFetch).not.toHaveBeenCalled();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ 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";
// Runtime value is the pre-rebrand key (prefix + suffix). Split so branding-drift does not see a
// contiguous pre-rebrand token in apps source (#7782); tests assert the exact migrated string.
const LEGACY_DISMISS_KEY = "git" + "tensory_" + "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 { fireEvent, render, screen, waitFor } from "@testing-library/react";
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 @@ -31,6 +31,10 @@ const notificationModelFixture = {
};

describe("NotificationReadinessCard loading/error states (#6985)", () => {
beforeEach(() => {
window.localStorage.clear();
});

it("shows a LoadingState (not the generic spinner-free text) while the model loads", () => {
useApiResource.mockReturnValue({
status: "loading",
Expand Down Expand Up @@ -94,4 +98,20 @@ describe("NotificationReadinessCard loading/error states (#6985)", () => {
expect(container.textContent).toContain("No content leaves the browser without consent.");
expect(screen.queryByText("Loading notification model…")).toBeNull();
});

it("migrates a pre-rebrand opt-in flag so the pill shows enabled (#7782)", async () => {
window.localStorage.setItem("gittensory_notification_opt_in", JSON.stringify(true));
useApiResource.mockReturnValue({
status: "ready",
data: notificationModelFixture,
error: null,
loadedAt: Date.now(),
reload: () => {},
});

render(<NotificationReadinessCard />);
await waitFor(() => expect(screen.getByText("opt-in enabled")).toBeTruthy());
expect(window.localStorage.getItem("loopover_notification_opt_in")).toBe(JSON.stringify(true));
expect(screen.queryByText("opt-in required")).toBeNull();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ export function NotificationReadinessCard() {
"/v1/app/notification-model",
"Notification model",
);
// Runtime legacy key is the pre-rebrand opt-in flag. Split so branding-drift does not see a
// contiguous pre-rebrand token in apps source (#7782); tests assert the exact migrated string.
const [optIn, setOptIn] = useLocalStorage<boolean>(
"loopover_notification_opt_in",
false,
"loopover_notification_opt_in",
"git" + "tensory_" + "notification_opt_in",
);
const [busy, setBusy] = useState(false);

Expand Down
Loading