feat: consolidate local-first mnote web runtime

This commit is contained in:
lix-2026
2026-05-28 22:01:44 +08:00
parent 7354807ee9
commit 39b9a0183a
154 changed files with 13591 additions and 12728 deletions
@@ -165,6 +165,7 @@ async function run() {
const root = fs.mkdtempSync(path.join(os.tmpdir(), "mnote-local-open-doc-external-"));
const files = {
clean: "clean-sync.md",
aiClean: "clean-ai-sync.md",
dirty: "dirty-conflict.md",
aiDirty: "dirty-ai-conflict.md",
rename: "rename-open.md",
@@ -172,6 +173,7 @@ async function run() {
};
writeWorkspaceManifest(root, "user_real");
fs.writeFileSync(path.join(root, files.clean), markdown("Clean Sync", ["initial clean"]), "utf8");
fs.writeFileSync(path.join(root, files.aiClean), markdown("Clean AI Sync", ["initial ai clean"]), "utf8");
fs.writeFileSync(path.join(root, files.dirty), markdown("Dirty Conflict", ["initial dirty"]), "utf8");
fs.writeFileSync(path.join(root, files.aiDirty), markdown("Dirty AI Conflict", ["initial ai dirty"]), "utf8");
fs.writeFileSync(path.join(root, files.rename), markdown("Rename Open", ["initial rename"]), "utf8");
@@ -211,6 +213,17 @@ async function run() {
await waitForEditorStatus(page, "synced-external-change");
}));
await openDocument(page, root, files.aiClean);
await waitForEditorText(page, "initial ai clean");
await page.waitForTimeout(300);
navigationEvents.length = 0;
steps.push(await runStep("clean 文档 AI 后台写入后自动同步内容", navigationEvents, async () => {
const aiToken = `ai-clean-${Date.now()}`;
await callMarkdownEdit(root, files.aiClean, "initial ai clean", `initial ai clean ${aiToken}`);
await waitForEditorText(page, aiToken);
await waitForEditorStatus(page, "synced-external-change");
}));
await openDocument(page, root, files.dirty);
await waitForEditorText(page, "initial dirty");
await page.waitForTimeout(300);
@@ -262,7 +275,7 @@ async function run() {
fs.rmSync(path.join(root, files.delete));
await waitForEditorStatus(page, "external-change-conflict");
const runtime = await readEditorRuntime(page);
assert(runtime.error.includes("本地 Markdown 文件已在外部更新"), `删除提示不正确: ${JSON.stringify(runtime)}`);
assert(runtime.error.includes("已被删除"), `删除提示不正确: ${JSON.stringify(runtime)}`);
}));
const result = {