diff --git a/frontend/src/pages/CommandCenterPage.tsx b/frontend/src/pages/CommandCenterPage.tsx index b355145..316268f 100644 --- a/frontend/src/pages/CommandCenterPage.tsx +++ b/frontend/src/pages/CommandCenterPage.tsx @@ -163,6 +163,12 @@ export function CommandCenterPage() { const lastPastWeekend = lastPastMeeting ? weekendsByKey.get(lastPastMeeting.meeting_key) : undefined const lastRaceAnalysis = pickAnalysisSession(lastPastWeekend) const lastRaceSessionKey = lastRaceAnalysis?.session.session_key + const railSessions = + focusWeekendSessions.length > 0 + ? focusWeekendSessions + : heroStateKind === 'between' + ? lastPastWeekend?.sessions ?? [] + : [] const lastRaceHubQuery = useQuery({ queryKey: ['race-hub', lastRaceSessionKey, 'hero-podium'], @@ -403,14 +409,14 @@ export function CommandCenterPage() { )} - {focusWeekendSessions.length > 0 && ( + {railSessions.length > 0 && (
Weekend Schedule - {focusWeekendSessions.length} sessions + {railSessions.length} sessions
- {focusWeekendSessions.map(({ session, source, datasets }) => { + {railSessions.map(({ session, source, datasets }) => { const status = classifySessionStatus(session, nowDate) const isNext = nextSession?.session_key === session.session_key const isCurrent = currentSession?.session_key === session.session_key diff --git a/frontend/src/test/CommandCenterPage.test.tsx b/frontend/src/test/CommandCenterPage.test.tsx index 76c1583..69a3205 100644 --- a/frontend/src/test/CommandCenterPage.test.tsx +++ b/frontend/src/test/CommandCenterPage.test.tsx @@ -245,4 +245,34 @@ describe('CommandCenterPage', () => { vi.useRealTimers() }) + + it('keeps the completed local session rail available when the next weekend has no sessions', async () => { + const nextMeeting = { + ...meeting, + meeting_key: 1303, + meeting_name: 'Canada', + country_name: 'Canada', + country_code: 'CAN', + circuit_short_name: 'Montreal', + date_start: '2026-06-12T00:00:00+00:00', + date_end: '2026-06-14T23:59:59+00:00', + year: 2026, + } + + vi.setSystemTime(new Date('2026-06-06T15:15:00Z')) + mockFetchSeasons.mockResolvedValue([2026]) + mockFetchLocalMeetings.mockResolvedValue([meeting]) + mockFetchSeasonMeetings.mockResolvedValue([meeting, nextMeeting]) + mockFetchWeekend.mockResolvedValue(weekend) + mockFetchSessions.mockResolvedValue([]) + + renderPage() + + await waitFor(() => { + expect(screen.getByTestId('cc-session-9472')).toBeInTheDocument() + }) + expect(screen.getByTestId('cc-schedule')).toHaveTextContent('1 sessions') + + vi.useRealTimers() + }) })