Replace empty BalanceOverviewCard with BalanceOnboardingCard showing two steps: 1. Create an account 2. Enter a snapshot Step 2 is grayed out until at least one account exists; the entire card is replaced by BalanceOverviewCard once a snapshot is recorded. Hide "+ New snapshot" button when 0 accounts (it lives inside the overview card, which is now hidden in that state). Improve SnapshotEditPage noAccounts copy to clarify account vs snapshot semantics. Resolves #178
41 lines
1.5 KiB
TypeScript
41 lines
1.5 KiB
TypeScript
// BalanceOnboardingCard — unit tests (issue #178)
|
|
//
|
|
// NOTE: This project does not have @testing-library/react or jsdom configured
|
|
// (logged as MEDIUM in autopilot decisions-log). Tests cover the pure
|
|
// `deriveOnboardingSteps` helper that drives the visual state of each step.
|
|
// All React rendering is bypassed.
|
|
|
|
import { describe, it, expect } from "vitest";
|
|
import { deriveOnboardingSteps } from "./BalanceOnboardingCard";
|
|
|
|
describe("BalanceOnboardingCard — deriveOnboardingSteps", () => {
|
|
it("0 accounts, 0 snapshots → step1 active, step2 disabled", () => {
|
|
const r = deriveOnboardingSteps(0, 0);
|
|
expect(r.step1).toBe("active");
|
|
expect(r.step2).toBe("disabled");
|
|
});
|
|
|
|
it(">=1 account, 0 snapshots → step1 done, step2 active", () => {
|
|
const r = deriveOnboardingSteps(1, 0);
|
|
expect(r.step1).toBe("done");
|
|
expect(r.step2).toBe("active");
|
|
|
|
const r2 = deriveOnboardingSteps(5, 0);
|
|
expect(r2.step1).toBe("done");
|
|
expect(r2.step2).toBe("active");
|
|
});
|
|
|
|
it(">=1 account, >=1 snapshot → both done (defensive — card normally hidden)", () => {
|
|
const r = deriveOnboardingSteps(2, 3);
|
|
expect(r.step1).toBe("done");
|
|
expect(r.step2).toBe("done");
|
|
});
|
|
|
|
it("guard: 0 accounts but >=1 snapshot (anomaly) → step1 active, step2 done", () => {
|
|
// This combination should not happen in practice (a snapshot requires at
|
|
// least one account), but the helper handles it conservatively.
|
|
const r = deriveOnboardingSteps(0, 1);
|
|
expect(r.step1).toBe("active");
|
|
expect(r.step2).toBe("done");
|
|
});
|
|
});
|