From 8a9d9909f900e099bedd2af6931cd581f2d117da Mon Sep 17 00:00:00 2001 From: le king fu Date: Sun, 18 Oct 2026 19:28:45 -0400 Subject: [PATCH] test: pin the reattachment count to active descendants (#393) A deactivated child of the reattached category is not counted in the number of categories put back, which the Journal line reports. Resolves #393 Co-Authored-By: Claude Opus 5.5 --- src/services/categoryService.test.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/services/categoryService.test.ts b/src/services/categoryService.test.ts index 1a0bb8a..f74c42e 100644 --- a/src/services/categoryService.test.ts +++ b/src/services/categoryService.test.ts @@ -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([]);