Open a template from its cards even when a saved draft exists.

This commit is contained in:
adilallo committed 2026-11-22 18:08:34 -07:00
1 parent 851133e56d
commit 55b071aa83
11 files changed
+326 -140

No files matched your search

@@ -1,7 +1,11 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import {
FRESH_ENTRY_PENDING_KEY,
TEMPLATE_APPLY_LATCH_KEY,
clearTemplateApplyLatch,
hasFreshEntryPending,
hasTemplateApplyLatch,
latchTemplateApply,
prepareFreshCreateFlowEntry,
prepareFreshCreateFlowEntrySync,
} from "../../app/(app)/create/utils/prepareFreshCreateFlowEntry";
@@ -66,6 +70,25 @@ describe("prepareFreshCreateFlowEntrySync", () => {
});
});
describe("template apply latch", () => {
beforeEach(() => {
window.sessionStorage.clear();
});
afterEach(() => {
window.sessionStorage.clear();
});
it("sets, reads, and clears the session flag", () => {
expect(hasTemplateApplyLatch()).toBe(false);
latchTemplateApply();
expect(window.sessionStorage.getItem(TEMPLATE_APPLY_LATCH_KEY)).toBe("1");
expect(hasTemplateApplyLatch()).toBe(true);
clearTemplateApplyLatch();
expect(hasTemplateApplyLatch()).toBe(false);
});
});
describe("prepareFreshCreateFlowEntry", () => {
beforeEach(() => {
deleteServerDraft.mockReset();