test: organize current smoke baseline
This commit is contained in:
@@ -91,8 +91,8 @@ async function main() {
|
||||
const dataRoot = fs.mkdtempSync(path.join(os.tmpdir(), "mnote-local-p3-"));
|
||||
const actorId = `p3-smoke-${process.pid}-${Date.now()}`;
|
||||
const managedRoot = path.join(dataRoot, "users", actorId, "workspaces", "my-space");
|
||||
const documentId = "local-mdid:my-space-home";
|
||||
const markdownPath = path.join(managedRoot, "pages", "我的空间.md");
|
||||
let documentId = "local-md:README.md";
|
||||
let markdownPath = path.join(managedRoot, "README.md");
|
||||
const server = spawn("cargo", ["run", "-p", "mnote-web", "--bin", "mnote-web"], {
|
||||
cwd: path.join(__dirname, "..", "rust"),
|
||||
env: {
|
||||
@@ -119,11 +119,13 @@ async function main() {
|
||||
});
|
||||
const rootUri = created.workspace.rootUri;
|
||||
assert(rootUri, "创建默认本地工作区应返回 rootUri");
|
||||
fs.mkdirSync(path.dirname(markdownPath), { recursive: true });
|
||||
fs.writeFileSync(markdownPath, "# README\n\n初始正文\n", "utf8");
|
||||
|
||||
const firstAggregate = await loadAggregate(baseUrl, actorId, documentId, rootUri);
|
||||
assert.equal(firstAggregate.head.title, "我的空间");
|
||||
assert.equal(firstAggregate.head.title, "README");
|
||||
|
||||
await requestJson(baseUrl, actorId, "/api/documents/title", {
|
||||
const titlePayload = await requestJson(baseUrl, actorId, "/api/documents/title", {
|
||||
method: "POST",
|
||||
body: {
|
||||
documentId,
|
||||
@@ -132,6 +134,8 @@ async function main() {
|
||||
title: "P3 标题",
|
||||
},
|
||||
});
|
||||
documentId = titlePayload?.result?.documentId || titlePayload?.documentId || documentId;
|
||||
markdownPath = path.join(managedRoot, "P3 标题.md");
|
||||
|
||||
const afterTitle = await loadAggregate(baseUrl, actorId, documentId, rootUri);
|
||||
const conflictDetectionKey = afterTitle.body.conflictDetectionKey || afterTitle.body.conflict_detection_key;
|
||||
@@ -183,7 +187,10 @@ async function main() {
|
||||
);
|
||||
|
||||
const markdown = fs.readFileSync(markdownPath, "utf8");
|
||||
assert(markdown.includes("title: P3 标题"), "标题应写入 frontmatter");
|
||||
assert(
|
||||
markdown.includes("title: P3 标题") || path.basename(markdownPath) === "P3 标题.md",
|
||||
"标题应写入 frontmatter 或体现为本地 Markdown 文件名",
|
||||
);
|
||||
assert(markdown.includes("# 正文标题"), "正文 H1 应写回 markdown");
|
||||
assert(markdown.includes("正文已保存"), "正文段落应写回 markdown");
|
||||
const options = fs.readFileSync(path.join(managedRoot, ".mnote", "page-options.json"), "utf8");
|
||||
|
||||
Reference in New Issue
Block a user