Resume the draft from Create rule instead of deleting it.

This commit is contained in:
adilallo committed 2026-11-22 17:51:21 -07:00
1 parent d31045b0e5
commit a846169960
9 files changed
+119 -71

No files matched your search

+54
View File
@@ -0,0 +1,54 @@
import { afterEach, beforeEach, describe, expect, it } from "vitest";
import { CREATE_FLOW_ANONYMOUS_KEY } from "../../app/(app)/create/utils/anonymousDraftStorage";
import { CORE_VALUE_DETAILS_STORAGE_KEY } from "../../app/(app)/create/utils/coreValueDetailsLocalStorage";
import {
createRuleEntryPath,
hasBrowserCreateFlowDraft,
} from "../../app/(app)/create/utils/createRuleEntry";
describe("createRuleEntryPath", () => {
beforeEach(() => {
window.localStorage.clear();
});
afterEach(() => {
window.localStorage.clear();
});
it("opens the first step when there is no draft", () => {
expect(hasBrowserCreateFlowDraft()).toBe(false);
expect(createRuleEntryPath()).toBe("/create/informational");
});
it("resumes the stored step", () => {
window.localStorage.setItem(
CREATE_FLOW_ANONYMOUS_KEY,
JSON.stringify({
title: "Garden coop",
currentStep: "community-size",
}),
);
expect(hasBrowserCreateFlowDraft()).toBe(true);
expect(createRuleEntryPath()).toBe("/create/community-size");
});
it("does not resume a finished Rule screen", () => {
window.localStorage.setItem(
CREATE_FLOW_ANONYMOUS_KEY,
JSON.stringify({
title: "Garden coop",
currentStep: "completed",
}),
);
expect(createRuleEntryPath()).toBe("/create/informational");
});
it("treats leftover core-value details as a draft", () => {
window.localStorage.setItem(
CORE_VALUE_DETAILS_STORAGE_KEY,
JSON.stringify({ "1": { meaning: "m", signals: "s" } }),
);
expect(hasBrowserCreateFlowDraft()).toBe(true);
expect(createRuleEntryPath()).toBe("/create/informational");
});
});