Keep the browser draft on screen after Save your progress, including when the save link is dead.

This commit is contained in:
adilallo committed 2026-11-22 17:50:06 -07:00
1 parent d576ed81d9
commit d31045b0e5
6 files changed
+141 -12

No files matched your search

+34 -1
View File
@@ -45,7 +45,11 @@ vi.mock("../../app/(app)/create/utils/anonymousDraftStorage", async (importOrigi
import { EMAIL_MAX_LEN } from "../../lib/create/isValidCreateFlowSaveEmail";
import { requestMagicLink } from "../../lib/create/api";
import { setTransferPendingFlag } from "../../app/(app)/create/utils/anonymousDraftStorage";
import {
CREATE_FLOW_ANONYMOUS_KEY,
CREATE_FLOW_TRANSFER_PENDING_KEY,
setTransferPendingFlag,
} from "../../app/(app)/create/utils/anonymousDraftStorage";
function renderLoginForm() {
return renderWithProviders(
@@ -62,6 +66,7 @@ describe("LoginForm", () => {
navMock.replace.mockReset();
navMock.pathname = "/";
navMock.searchParams = new URLSearchParams();
window.localStorage.clear();
});
it("renders title, email field, and submit control", () => {
@@ -368,6 +373,34 @@ describe("LoginForm", () => {
).toBeInTheDocument();
});
it("clears the transfer flag on an expired link and keeps the browser draft", () => {
window.localStorage.setItem(
CREATE_FLOW_ANONYMOUS_KEY,
JSON.stringify({ title: "Garden coop" }),
);
window.localStorage.setItem(CREATE_FLOW_TRANSFER_PENDING_KEY, "1");
navMock.searchParams = new URLSearchParams("error=expired_link");
renderLoginForm();
expect(window.localStorage.getItem(CREATE_FLOW_TRANSFER_PENDING_KEY)).toBeNull();
expect(window.localStorage.getItem(CREATE_FLOW_ANONYMOUS_KEY)).toContain(
"Garden coop",
);
});
it("clears the transfer flag on an already-used link and keeps the browser draft", () => {
window.localStorage.setItem(
CREATE_FLOW_ANONYMOUS_KEY,
JSON.stringify({ title: "Garden coop" }),
);
window.localStorage.setItem(CREATE_FLOW_TRANSFER_PENDING_KEY, "1");
navMock.searchParams = new URLSearchParams("error=invalid_link");
renderLoginForm();
expect(window.localStorage.getItem(CREATE_FLOW_TRANSFER_PENDING_KEY)).toBeNull();
expect(window.localStorage.getItem(CREATE_FLOW_ANONYMOUS_KEY)).toContain(
"Garden coop",
);
});
it("shows URL-driven error for invalid_link", () => {
navMock.searchParams = new URLSearchParams("error=invalid_link");
renderLoginForm();