Files
Copilot efc988fb9f Prevent unintentional trashing of non-empty untitled drafts on editor unmount (#12418)
* Initial plan

* Fix draft auto-delete check for non-empty untitled docs

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2026-05-21 20:15:54 -04:00

32 lines
737 B
TypeScript

import { shouldAutoDeleteDraftOnUnmount } from "./useDocumentSave";
describe("shouldAutoDeleteDraftOnUnmount", () => {
const baseOptions = {
title: "",
createdById: "user-1",
currentUserId: "user-1",
isDraft: true,
isActive: true,
hasEmptyTitle: true,
isPersistedOnce: true,
};
it("does not auto delete drafts with non-empty editor content", () => {
expect(
shouldAutoDeleteDraftOnUnmount({
...baseOptions,
isEditorEmpty: false,
})
).toBe(false);
});
it("auto deletes drafts that are still empty and untitled", () => {
expect(
shouldAutoDeleteDraftOnUnmount({
...baseOptions,
isEditorEmpty: true,
})
).toBe(true);
});
});