Simpl-Resultat/src/components/balance/balanceLanding.test.ts
le king fu 82550d6d38
All checks were successful
PR Check / rust (pull_request) Successful in 25m34s
PR Check / frontend (pull_request) Successful in 2m30s
feat(balance): tile-based landing hub + reachable account management
Decouple the /balance empty-state guard into three explicit states via a
new pure helper `deriveLandingState` (empty / accounts-no-snapshot /
populated). Having accounts but no snapshot no longer strands the user on a
snapshot-only onboarding card: each state now renders navigation tiles
(HubReportNavCard, modeled on the Reports hub), and "Manage accounts"
(/balance/accounts) is reachable in every state, including the populated
dashboard.

- Remove BalanceOnboardingCard (component + test) and the dead
  balance.onboarding.* i18n keys; add balanceLanding.ts + test.
- Add balance.hub.* and balance.landing.* keys in FR and EN.
- CHANGELOG (EN + FR) under [Unreleased].

Resolves #244
2026-07-04 17:43:43 -04:00

30 lines
1.2 KiB
TypeScript

// balanceLanding — unit tests (issue #244)
//
// Covers the pure `deriveLandingState` helper that replaces the old boolean
// empty-state guard. No React rendering (this project has no jsdom configured);
// the decoupled-guard logic is exercised directly as a pure helper.
import { describe, it, expect } from "vitest";
import { deriveLandingState } from "./balanceLanding";
describe("balanceLanding — deriveLandingState", () => {
it("0 accounts → empty (regardless of snapshot flag)", () => {
expect(deriveLandingState(0, false)).toBe("empty");
// Anomalous (a snapshot implies an account) but handled conservatively.
expect(deriveLandingState(0, true)).toBe("empty");
});
it(">=1 account but no snapshot → accounts-no-snapshot (no longer 'empty')", () => {
expect(deriveLandingState(1, false)).toBe("accounts-no-snapshot");
expect(deriveLandingState(5, false)).toBe("accounts-no-snapshot");
});
it(">=1 account with a snapshot → populated", () => {
expect(deriveLandingState(1, true)).toBe("populated");
expect(deriveLandingState(12, true)).toBe("populated");
});
it("guards against negative counts → empty", () => {
expect(deriveLandingState(-1, true)).toBe("empty");
});
});