Raise frontend branch coverage from 86.84% to 93.78%
Branches were the weakest metric and had the least headroom above the 85% floor. These are tests for decision paths that were genuinely unexercised, not padding. The largest gaps were systemic rather than per-file: the `err instanceof Error ? ... : fallback` branch was untested across eight data hooks, useVacationDays had no dedicated test file at all, and Calendar.tsx's missing-workspace/child/personalData fallbacks were never hit. Left deliberately uncovered, with reasons: `?? fallback` guards whose fallback cannot occur given how the value is constructed upstream, and guards behind buttons that are disabled whenever the guard would matter. Reaching those means calling handlers directly, which tests the test rather than the app. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RXMhc9nT6sNz1SL4j8dznL
This commit is contained in:
@@ -64,6 +64,18 @@ describe('CalendarDay', () => {
|
||||
expect(onClick).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('calls onActivate instead of onClick on Enter when onActivate is provided', () => {
|
||||
const onClick = vi.fn()
|
||||
const onActivate = vi.fn()
|
||||
const { getByTestId } = render(
|
||||
<CalendarDay date="2026-06-15" onClick={onClick} onActivate={onActivate} />
|
||||
)
|
||||
const day = getByTestId('calendar-day')
|
||||
fireEvent.keyDown(day, { key: 'Enter' })
|
||||
expect(onActivate).toHaveBeenCalledTimes(1)
|
||||
expect(onClick).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('calls onClick on Space key', () => {
|
||||
const onClick = vi.fn()
|
||||
const { getByTestId } = render(
|
||||
|
||||
@@ -65,6 +65,22 @@ describe('CalendarEvent', () => {
|
||||
expect(stopPropagation).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('prefixes the label with the parent label when provided', () => {
|
||||
const { getByTestId } = render(
|
||||
<CalendarEvent leaveType="vacation" color="#FF5733" parentLabel="Alice" />
|
||||
)
|
||||
const event = getByTestId('calendar-event')
|
||||
expect(event.textContent).toBe('Alice · vacation')
|
||||
})
|
||||
|
||||
it('shows the double-day badge when isDubbeldag is true', () => {
|
||||
const { getByTestId } = render(
|
||||
<CalendarEvent leaveType="vacation" color="#FF5733" isDubbeldag={true} />
|
||||
)
|
||||
const event = getByTestId('calendar-event')
|
||||
expect(event.textContent).toContain('2×')
|
||||
})
|
||||
|
||||
it('provides accessibility label', () => {
|
||||
const { getByTestId } = render(
|
||||
<CalendarEvent leaveType="vacation" color="#FF5733" onDismiss={() => {}} />
|
||||
|
||||
@@ -412,6 +412,39 @@ describe('CalendarWeek', () => {
|
||||
expect(events.length).toBeGreaterThanOrEqual(2)
|
||||
})
|
||||
|
||||
it('closes an open bar that runs through the last day of the week', () => {
|
||||
// A run of planned days ending on the week's final date (2026-01-11)
|
||||
// leaves the bar "open" when the loop over weekDates finishes, which
|
||||
// exercises the post-loop flush rather than the mid-loop gap-close path.
|
||||
const plannedDays: PlannedLeaveDay[] = [
|
||||
{
|
||||
id: '1',
|
||||
workspaceId: 'ws-1',
|
||||
childId: 'child-1',
|
||||
parentPersonalDataUuid: 'parent-1',
|
||||
date: '2026-01-10',
|
||||
dayType: 'vacation',
|
||||
isDubbeldag: false,
|
||||
createdAt: '2026-01-01',
|
||||
updatedAt: '2026-01-01',
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
workspaceId: 'ws-1',
|
||||
childId: 'child-1',
|
||||
parentPersonalDataUuid: 'parent-1',
|
||||
date: '2026-01-11',
|
||||
dayType: 'vacation',
|
||||
isDubbeldag: false,
|
||||
createdAt: '2026-01-01',
|
||||
updatedAt: '2026-01-01',
|
||||
},
|
||||
]
|
||||
render(<CalendarWeek {...defaultProps} plannedDays={plannedDays} />)
|
||||
const events = screen.getAllByTestId('calendar-event')
|
||||
expect(events.length).toBeGreaterThan(0)
|
||||
})
|
||||
|
||||
it('handles empty planned days', () => {
|
||||
render(<CalendarWeek {...defaultProps} plannedDays={[]} />)
|
||||
expect(screen.queryByTestId('calendar-event')).not.toBeInTheDocument()
|
||||
|
||||
Reference in New Issue
Block a user