Files
Netcatty/components/TextEditorModal.test.tsx
陈大猫 1b08e5ee88 [codex] Fix SFTP editor saved state (#887)
* Fix SFTP editor saved state

* Restore window input focus after SFTP editor

* Harden SFTP editor save flows
2026-05-01 16:31:58 +08:00

46 lines
1.3 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { createTextEditorModalSnapshot } from "./TextEditorModal.tsx";
import { createTextEditorSaveCoordinator } from "../application/state/textEditorSaveCoordinator.ts";
test("promotion snapshot uses the latest saved baseline after a save", async () => {
let baselineContent = "old";
let content = "saved";
const coordinator = createTextEditorSaveCoordinator({
onSave: async () => {},
onSaveSuccess: (savedContent) => {
baselineContent = savedContent;
},
});
await coordinator.save(content);
const snapshot = createTextEditorModalSnapshot({
fileName: "file.txt",
getBaselineContent: () => baselineContent,
getContent: () => content,
languageId: "plaintext",
wordWrap: false,
getViewState: () => null,
isSaving: () => false,
});
assert.equal(snapshot?.baselineContent, "saved");
assert.equal(snapshot?.content, "saved");
});
test("promotion snapshot is blocked while saving", () => {
const snapshot = createTextEditorModalSnapshot({
fileName: "file.txt",
getBaselineContent: () => "old",
getContent: () => "new",
languageId: "plaintext",
wordWrap: false,
getViewState: () => null,
isSaving: () => true,
});
assert.equal(snapshot, null);
});