Distinguish the Dashboard and Plan age-4 figures

Both screens showed an "expiring at age 4" number under near-identical
labels, and they disagreed -- 143 on the Dashboard versus 100 on the Plan
tab for the same parent. Both were correct: the Dashboard reflects the
saved plan, the Plan tab a proposal that has not been applied and which
simulates future recurring wishes.

The numbers are left untouched; forcing them to agree would make one of
them wrong. Instead each label now states its own basis ("om nuvarande
plan följs" / "om detta förslag tillämpas"), and the Plan tab's intro
says outright that the saved plan may differ, and why.

Tests assert the distinguishing copy on both screens so the two cannot
silently drift back to indistinguishable labels.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RXMhc9nT6sNz1SL4j8dznL
This commit is contained in:
2026-09-14 22:32:54 +02:00
parent dc4c0a5edd
commit 8c2e5dee1b
7 changed files with 74 additions and 8 deletions
+32
View File
@@ -201,6 +201,38 @@ describe('Dashboard', () => {
expect(screen.getByText(/Återstående till 4 års ålder/)).toBeInTheDocument()
})
// The combined expiring-at-4 figure reflects the currently saved plan, while
// the Plan tab's own figure (PlanResults.tsx) reflects an unsaved proposal —
// the label must say so, so the two screens are never confused for showing
// the same thing. See PlanAge4Projection vs Age4Projection in types/entities.ts.
it('labels the combined expiring-at-4 metric as reflecting the current saved plan', () => {
renderWithRouter(<Dashboard />)
expect(screen.getByTestId('metric-expiring-combined')).toHaveTextContent(
'Förfaller vid 4 år om nuvarande plan följs (alla föräldrar)',
)
})
it('labels the per-parent expiring-at-4 metric as reflecting the current saved plan', () => {
vi.mocked(hooks.useAnalytics).mockReturnValue({
data: {
...mockAnalyticsData,
parentProjections: [
{ personalDataUuid: 'pd-1', childId: 'c-1', birthDate: '2022-01-01', fourthBirthday: '2026-01-01', totalDays: 240, daysUsed: 30, plannedDaysBeforeB4: 10, projectedLeftAtB4: 200, savableAfterB4: 96, expiringAtB4: 60 },
{ personalDataUuid: 'pd-2', childId: 'c-1', birthDate: '2022-01-01', fourthBirthday: '2026-01-01', totalDays: 240, daysUsed: 20, plannedDaysBeforeB4: 5, projectedLeftAtB4: 210, savableAfterB4: 96, expiringAtB4: 44 },
],
combinedExpiringAtB4: 104,
},
isLoading: false,
error: null,
refresh: vi.fn(),
} as any)
renderWithRouter(<Dashboard />)
expect(screen.getByTestId('metric-expiring-parent-pd-1')).toHaveTextContent(
'Förfaller vid 4 år om nuvarande plan följs – Alex',
)
})
it('displays error message if analytics fails', () => {
vi.mocked(hooks.useAnalytics).mockReturnValue({
data: null,