- 补齐 design/10-review 执行清单、验收标准与相关设计治理记录 - 迁移已完成的 tree、mindmap、runtime fallback、AI kernel 等设计和缺陷条目 - 推进 Rust Web runtime、tree/sidebar、page aggregate、mindmap 与 OnlyOffice 路由侧验证支撑 - 增加 task177-task180 smoke/audit 脚本及前端相关测试覆盖
94 lines
3.3 KiB
JavaScript
94 lines
3.3 KiB
JavaScript
const assert = require("node:assert/strict");
|
|
|
|
const {
|
|
auditSidebarMindmapGhostCandidates,
|
|
} = require("./task180-mindmap-ghost-candidate-audit");
|
|
|
|
const fixture = {
|
|
documents: [
|
|
{ id: "doc_1", title: "带重复导图的页面" },
|
|
{ id: "doc_2", title: "正常页面" },
|
|
],
|
|
mindmapAssets: [
|
|
{ id: "mind_a", document_id: "doc_1", asset_type: "mindmap", deleted_at: null },
|
|
{ id: "mind_b", document_id: "doc_1", asset_type: "mindmap", deleted_at: null },
|
|
{ id: "mind_b", document_id: "doc_1", asset_type: "mindmap", deleted_at: null },
|
|
{ id: "mind_c", document_id: "doc_2", asset_type: "mindmap", deleted_at: "2026-05-01" },
|
|
{ id: "mind_orphan", document_id: "doc_missing", asset_type: "mindmap", deleted_at: null },
|
|
],
|
|
kernelFileTreeProjection: {
|
|
items: [
|
|
{
|
|
rowId: "asset:mind_a",
|
|
rowKind: "asset",
|
|
title: "mind_a",
|
|
resourceMeta: { resourceKind: "mindmap", documentId: "doc_1", assetId: "mind_a" },
|
|
},
|
|
{
|
|
rowId: "asset:mind_a:dup",
|
|
rowKind: "asset",
|
|
title: "mind_a duplicate",
|
|
resourceMeta: { resourceKind: "mindmap", documentId: "doc_1", assetId: "mind_a" },
|
|
},
|
|
],
|
|
},
|
|
};
|
|
|
|
const result = auditSidebarMindmapGhostCandidates(fixture);
|
|
|
|
assert.equal(result.ok, true);
|
|
assert.equal(result.summary.activeMindmapAssets, 4);
|
|
assert.equal(result.summary.documentGroupsWithMultipleActiveMindmaps, 1);
|
|
assert.equal(result.summary.duplicateActiveAssetIds, 1);
|
|
assert.equal(result.summary.activeAssetsWithMissingDocument, 1);
|
|
assert.equal(result.summary.duplicateFileTreeMindmapRows, 1);
|
|
assert.deepEqual(result.candidates.multipleActiveMindmapsByDocument[0].mindmapIds, [
|
|
"mind_a",
|
|
"mind_b",
|
|
"mind_b",
|
|
]);
|
|
assert.deepEqual(result.candidates.duplicateActiveAssetIds[0].assetId, "mind_b");
|
|
assert.deepEqual(result.candidates.activeAssetsWithMissingDocument[0].assetId, "mind_orphan");
|
|
assert.deepEqual(result.candidates.duplicateFileTreeMindmapRows[0].assetId, "mind_a");
|
|
|
|
const fileProjectionResult = auditSidebarMindmapGhostCandidates({
|
|
ok: true,
|
|
result: {
|
|
items: [
|
|
{
|
|
rowId: "resource:mind_projection",
|
|
title: "导图",
|
|
resourceMeta: { resourceKind: "mindmap", documentId: "doc_projection", assetId: "mind_projection" },
|
|
},
|
|
{
|
|
rowId: "resource:mind_projection:duplicate",
|
|
title: "导图副本",
|
|
resourceMeta: { resourceKind: "mindmap", documentId: "doc_projection", assetId: "mind_projection" },
|
|
},
|
|
],
|
|
},
|
|
});
|
|
|
|
assert.equal(fileProjectionResult.summary.documents, 0);
|
|
assert.equal(fileProjectionResult.summary.activeMindmapAssets, 0);
|
|
assert.equal(fileProjectionResult.summary.fileTreeMindmapRows, 2);
|
|
assert.equal(fileProjectionResult.summary.duplicateFileTreeMindmapRows, 1);
|
|
assert.deepEqual(fileProjectionResult.candidates.duplicateFileTreeMindmapRows[0].rowIds, [
|
|
"resource:mind_projection",
|
|
"resource:mind_projection:duplicate",
|
|
]);
|
|
|
|
const directItemsResult = auditSidebarMindmapGhostCandidates({
|
|
items: [
|
|
{
|
|
row_id: "resource:mind_direct",
|
|
resource_meta: { resource_kind: "mindmap", document_id: "doc_direct", asset_id: "mind_direct" },
|
|
},
|
|
],
|
|
});
|
|
|
|
assert.equal(directItemsResult.summary.fileTreeMindmapRows, 1);
|
|
assert.equal(directItemsResult.summary.duplicateFileTreeMindmapRows, 0);
|
|
|
|
console.log("task180 mindmap ghost candidate audit self-test passed");
|