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 <noreply@anthropic.com>
This commit is contained in:
le king fu 2026-10-23 21:01:11 -04:00
commit ed49c74cc9
2 changed files with 12 additions and 10 deletions

View file

@ -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,

View file

@ -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,