fix: check category parents and repair orphan categories (#393) #472
1 changed files with 8 additions and 2 deletions
|
|
@ -358,8 +358,14 @@ describe("reattachCategory on rows already in a cycle (#393)", () => {
|
|||
expect(db.writes()).toEqual(["BEGIN", "ROLLBACK", "BEGIN", "ROLLBACK"]);
|
||||
});
|
||||
|
||||
it("reattaches a category whose parent was deleted", async () => {
|
||||
const db = useFakeDb([row(1, null), row(2, null, { is_active: 0 }), row(20, 2), row(21, 20)]);
|
||||
it("reattaches a category whose parent was deleted, counting its active descendants only", async () => {
|
||||
const db = useFakeDb([
|
||||
row(1, null),
|
||||
row(2, null, { is_active: 0 }),
|
||||
row(20, 2),
|
||||
row(21, 20),
|
||||
row(22, 20, { is_active: 0 }),
|
||||
]);
|
||||
expect(await reattachCategory(20, 1)).toBe(2);
|
||||
expect(db.rows().find((r) => r.id === 20)?.parent_id).toBe(1);
|
||||
expect(await findOrphanCategories()).toEqual([]);
|
||||
|
|
|
|||
Loading…
Reference in a new issue