大批外部 Markdown 导入时立即展示已发现文件,补充明确的同步和索引状态,并让云叶冒险场景延续到工作区。 Co-Authored-By: Codex <noreply@anthropic.com>
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import type { PageMeta } from "@silverbulletmd/silverbullet/type/index";
|
|
import { expect, test } from "vitest";
|
|
import { mergePlainleafPageLists } from "./plainleaf_page_list.ts";
|
|
|
|
function page(name: string, description?: string): PageMeta {
|
|
return {
|
|
ref: name,
|
|
tag: "page",
|
|
name,
|
|
description,
|
|
created: "2026-08-13T00:00:00Z",
|
|
lastModified: "2026-08-13T00:00:00Z",
|
|
perm: "rw",
|
|
};
|
|
}
|
|
|
|
test("keeps discovered Markdown visible while indexing is incomplete", () => {
|
|
const result = mergePlainleafPageLists(
|
|
[page("极空间记事本/已整理", "索引信息")],
|
|
[page("极空间记事本/已整理"), page("极空间记事本/等待整理")],
|
|
);
|
|
|
|
expect(result.map((item) => item.name)).toEqual([
|
|
"极空间记事本/已整理",
|
|
"极空间记事本/等待整理",
|
|
]);
|
|
expect(result[0].description).toBe("索引信息");
|
|
});
|
|
|
|
test("does not let an aspiring link hide a discovered real file", () => {
|
|
const aspiring = page("极空间记事本/真实笔记");
|
|
aspiring._isAspiring = true;
|
|
|
|
const result = mergePlainleafPageLists(
|
|
[aspiring],
|
|
[page("极空间记事本/真实笔记", "来自文件系统")],
|
|
);
|
|
|
|
expect(result).toHaveLength(1);
|
|
expect(result[0]._isAspiring).not.toBe(true);
|
|
expect(result[0].description).toBe("来自文件系统");
|
|
});
|