Warn on tab close when create-flow module or wizard edits have not been saved.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
||||
captureMethodCardCustomizeSnapshot,
|
||||
confirmDiscardMethodCardCustomizeSession,
|
||||
isMethodCardCustomizeSessionDirty,
|
||||
isMethodCardCustomizeUnloadBlocked,
|
||||
} from "../../lib/create/methodCardCustomizeSession";
|
||||
|
||||
const HEADER_0 = { title: "", description: "" };
|
||||
@@ -88,4 +89,24 @@ describe("methodCardCustomizeSession", () => {
|
||||
).toBe(false);
|
||||
expect(confirmFn).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("unload block is false when the modal is closed or snapshot is missing", () => {
|
||||
const snap = captureMethodCardCustomizeSnapshot({ x: 1 }, null, HEADER_0);
|
||||
expect(
|
||||
isMethodCardCustomizeUnloadBlocked(false, snap, { x: 2 }, null, HEADER_0),
|
||||
).toBe(false);
|
||||
expect(
|
||||
isMethodCardCustomizeUnloadBlocked(true, null, { x: 2 }, null, HEADER_0),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("unload block is true only when the open modal is dirty", () => {
|
||||
const snap = captureMethodCardCustomizeSnapshot({ x: 1 }, null, HEADER_0);
|
||||
expect(
|
||||
isMethodCardCustomizeUnloadBlocked(true, snap, { x: 1 }, null, HEADER_0),
|
||||
).toBe(false);
|
||||
expect(
|
||||
isMethodCardCustomizeUnloadBlocked(true, snap, { x: 2 }, null, HEADER_0),
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user