From 244184c2d7f0ab93ef95e8a441ab6ebf145bc21d Mon Sep 17 00:00:00 2001 From: le king fu Date: Fri, 23 Oct 2026 21:01:11 -0400 Subject: [PATCH] test: give the delete fixtures numbers apart from their id (#467) A sort order equal to the id let a handler that passed the sort order pass the id assertion. The category fixtures of the CategoryDetailPanel and AccountsPage tests now carry a sort order (and a keyword count) of their own. Co-Authored-By: Claude Opus 5.5 --- .../categories/CategoryDetailPanel.delete.test.ts | 11 ++++++----- src/pages/AccountsPage.delete.test.ts | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/components/categories/CategoryDetailPanel.delete.test.ts b/src/components/categories/CategoryDetailPanel.delete.test.ts index 16f4570..3dcb4e0 100644 --- a/src/components/categories/CategoryDetailPanel.delete.test.ts +++ b/src/components/categories/CategoryDetailPanel.delete.test.ts @@ -30,7 +30,8 @@ import type { CategoryFormData, CategoryTreeNode } from "../../shared/types"; const harness = hookHarness(); -const node = (id: number, parent_id: number | null, name: string): CategoryTreeNode => ({ +/** A category whose numbers all differ from its id, so that only the id passes for it. */ +const node = (id: number, parent_id: number | null, name: string, sort_order: number): CategoryTreeNode => ({ id, name, parent_id, @@ -39,14 +40,14 @@ const node = (id: number, parent_id: number | null, name: string): CategoryTreeN type: "expense", is_active: true, is_inputable: true, - sort_order: id, - keyword_count: 0, + sort_order, + keyword_count: 4, i18n_key: null, children: [], }); -const HOUSING = node(1, null, "Logement"); -const RENT = node(10, 1, "Loyer"); +const HOUSING = node(1, null, "Logement", 1); +const RENT = node(10, 1, "Loyer", 2); const EDITING: CategoryFormData = { name: RENT.name, type: RENT.type, diff --git a/src/pages/AccountsPage.delete.test.ts b/src/pages/AccountsPage.delete.test.ts index a5e4d4b..628b8e1 100644 --- a/src/pages/AccountsPage.delete.test.ts +++ b/src/pages/AccountsPage.delete.test.ts @@ -36,12 +36,13 @@ import type { BalanceAccountWithCategory, BalanceCategory } from "../shared/type const harness = hookHarness(); -const category = (id: number, key: string, is_seed = false): BalanceCategory => ({ +/** A balance category; its sort order differs from its id, so that only the id passes for it. */ +const category = (id: number, key: string, sort_order: number, is_seed = false): BalanceCategory => ({ id, key, i18n_key: `balance.category.${key}`, kind: "simple", - sort_order: id, + sort_order, is_active: true, is_seed, asset_type: null, @@ -49,11 +50,11 @@ const category = (id: number, key: string, is_seed = false): BalanceCategory => }); /** A category of the user, without any account: the only one the page lets go. */ -const BOAT = category(21, "boat"); +const BOAT = category(21, "boat", 1); /** A category of the user, two accounts linked to it. */ -const ART = category(22, "art"); +const ART = category(22, "art", 2); /** A category of the seed, protected. */ -const CASH = category(23, "cash", true); +const CASH = category(23, "cash", 3, true); const account = (id: number, name: string, cat: BalanceCategory): BalanceAccountWithCategory => ({ id,