4-26 树rust-2
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
||||
compareDocumentCanonicalOrder,
|
||||
getCanonicalDocumentByBusinessId,
|
||||
getCanonicalParentDocumentId,
|
||||
pickCanonicalDocumentRecordsByBusinessId,
|
||||
pickCanonicalDocumentRecord,
|
||||
} from "../../../convex/_utils/documentRecord";
|
||||
|
||||
@@ -176,3 +177,37 @@ describe("canonical document helper", () => {
|
||||
expect(parentId).toBe("parent_alive");
|
||||
});
|
||||
});
|
||||
|
||||
describe("pickCanonicalDocumentRecordsByBusinessId", () => {
|
||||
it("同一 workspace 扫描结果里 business id 重复时应先折叠成 canonical 记录,供树命令写链复用", () => {
|
||||
const records = pickCanonicalDocumentRecordsByBusinessId([
|
||||
{
|
||||
_id: "doc_old",
|
||||
id: "doc_1",
|
||||
parent_id: "parent_old",
|
||||
deleted_at: null,
|
||||
created_at: "2026-04-14T00:00:00.000Z",
|
||||
updated_at: "2026-04-14T00:00:01.000Z",
|
||||
},
|
||||
{
|
||||
_id: "doc_new",
|
||||
id: "doc_1",
|
||||
parent_id: "parent_new",
|
||||
deleted_at: null,
|
||||
created_at: "2026-04-14T00:00:02.000Z",
|
||||
updated_at: "2026-04-14T00:00:03.000Z",
|
||||
},
|
||||
{
|
||||
_id: "doc_2",
|
||||
id: "doc_2",
|
||||
parent_id: null,
|
||||
deleted_at: null,
|
||||
created_at: "2026-04-14T00:00:04.000Z",
|
||||
updated_at: "2026-04-14T00:00:05.000Z",
|
||||
},
|
||||
]);
|
||||
|
||||
expect(records).toHaveLength(2);
|
||||
expect(records.map((record) => record._id)).toEqual(["doc_new", "doc_2"]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user