Compare commits

..
Author SHA1 Message Date
AmanTahilianiandCursor 2393842fb6 fix(#103): allow pinch-zoom and lift Admin muted contrast
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-30 15:36:18 -04:00
7 changed files with 49 additions and 170 deletions

No files matched your search

+1 -1
View File
@@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#0d0d0d" />
<meta name="description" content="box-box: A premium Live F1 Dashboard and Timing Tower" />
+13 -46
View File
@@ -58,67 +58,35 @@ function SectionState({
return <>{children}</>
}
function circuitIdentity(meeting: Meeting): { name: string; place: string } {
const name = meeting.circuit_short_name?.trim() || meeting.meeting_name
const location = meeting.location?.trim() ?? ''
const country = meeting.country_name?.trim() ?? ''
const parts: string[] = []
if (location) parts.push(location)
if (country && country !== location) parts.push(country)
return { name, place: parts.join(' · ') }
}
function TrackOutlineCard({
meeting,
outline,
loading,
error,
accent,
}: {
meeting: Meeting
outline: TrackOutline | null | undefined
loading: boolean
error: Error | null
accent: string
}) {
const outlinePath = useMemo(() => buildOutlinePath(outline?.points ?? []), [outline])
const identity = circuitIdentity(meeting)
let body: ReactNode
if (loading) {
body = <div className="preview-section-state">Loading…</div>
} else if (error) {
body = (
<div className="preview-section-state error">
{error instanceof Error ? error.message : 'Failed to load'}
</div>
)
} else if (outlinePath) {
body = (
<div className="preview-track-stage" style={{ ['--preview-accent' as string]: accent }}>
<svg className="preview-track-svg" viewBox="0 0 100 100" role="img" aria-label="Circuit outline">
<path className="preview-track-shadow" d={outlinePath} />
<path className="preview-track-outline" d={outlinePath} />
</svg>
</div>
)
} else {
body = (
<div className="preview-track-fallback" data-testid="preview-track-fallback">
<div className="preview-track-fallback-glyph" aria-hidden />
<p className="preview-track-fallback-name">{identity.name}</p>
{identity.place && <p className="preview-track-fallback-place">{identity.place}</p>}
<p className="preview-track-fallback-hint">
A GPS track outline is not available in the local cache.
</p>
</div>
)
}
return (
<section className="preview-card" data-testid="preview-track-card">
<h2 className="preview-card-title">Circuit</h2>
{body}
<SectionState
loading={loading}
error={error}
empty={!outline || !outlinePath}
emptyMessage="Track outline unavailable for this circuit"
>
<div className="preview-track-stage" style={{ ['--preview-accent' as string]: accent }}>
<svg className="preview-track-svg" viewBox="0 0 100 100" role="img" aria-label="Circuit outline">
<path className="preview-track-shadow" d={outlinePath} />
<path className="preview-track-outline" d={outlinePath} />
</svg>
</div>
</SectionState>
</section>
)
}
@@ -440,7 +408,6 @@ export function RacePreviewPage() {
<div className="preview-grid">
<TrackOutlineCard
meeting={previewMeeting}
outline={trackOutlineQuery.data}
loading={trackOutlineQuery.isLoading}
error={trackOutlineQuery.isError ? (trackOutlineQuery.error as Error) : null}
+3 -1
View File
@@ -21,7 +21,9 @@ const rootRoute = createRootRoute({
component: () => (
<>
<Nav />
<Outlet />
<main>
<Outlet />
</main>
</>
),
})
+5 -5
View File
@@ -1434,7 +1434,7 @@ a { color: inherit; text-decoration: none; }
font-weight: 700;
letter-spacing: 0.14em;
text-transform: uppercase;
color: var(--text-3);
color: var(--text-2);
}
.dl-page-title {
@@ -1444,7 +1444,7 @@ a { color: inherit; text-decoration: none; }
.dl-page-sub {
font-size: 11px;
color: var(--text-3);
color: var(--text-2);
}
.dl-page-banner {
@@ -1470,7 +1470,7 @@ a { color: inherit; text-decoration: none; }
flex-wrap: wrap;
gap: var(--s5);
font-size: 11px;
color: var(--text-3);
color: var(--text-2);
letter-spacing: 0.05em;
text-transform: uppercase;
}
@@ -1554,7 +1554,7 @@ a { color: inherit; text-decoration: none; }
font-size: 9px;
text-transform: uppercase;
letter-spacing: 0.08em;
color: var(--text-3);
color: var(--text-2);
}
.dl-stat-val {
@@ -1592,7 +1592,7 @@ a { color: inherit; text-decoration: none; }
.dl-content-meta {
font-size: 12px;
color: var(--text-3);
color: var(--text-2);
font-family: var(--f-mono);
}
-41
View File
@@ -203,47 +203,6 @@
stroke-linejoin: round;
}
.preview-track-fallback {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
gap: var(--s2);
min-height: 180px;
padding: var(--s5);
}
.preview-track-fallback-glyph {
width: 88px;
height: 52px;
margin-bottom: var(--s2);
border: 2px dashed rgba(255, 255, 255, 0.14);
border-radius: 42% 50% 46% 54%;
}
.preview-track-fallback-name {
font-size: 1.2rem;
font-weight: 600;
color: var(--text-1);
margin: 0;
}
.preview-track-fallback-place {
font-size: 0.85rem;
color: var(--text-2);
margin: 0;
}
.preview-track-fallback-hint {
font-size: 0.8rem;
line-height: 1.5;
color: var(--text-3);
max-width: 22rem;
margin: var(--s2) 0 0;
}
.preview-podium {
display: flex;
flex-direction: column;
+27 -4
View File
@@ -1,7 +1,9 @@
import { readFileSync } from 'node:fs'
import { resolve } from 'node:path'
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { render, screen, waitFor, fireEvent } from '@testing-library/react'
import { render, screen, waitFor } from '@testing-library/react'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { RouterProvider, createRouter, createRootRoute, createRoute } from '@tanstack/react-router'
import { RouterProvider, createRouter, createRootRoute, createRoute, Outlet } from '@tanstack/react-router'
import { DataLibraryPage } from '../pages/DataLibraryPage'
import type { DatasetInfo, Meeting, Weekend } from '../types'
@@ -75,14 +77,16 @@ function renderPage() {
const rootRoute = createRootRoute({
component: () => (
<QueryClientProvider client={queryClient}>
<DataLibraryPage />
<main>
<Outlet />
</main>
</QueryClientProvider>
),
})
const indexRoute = createRoute({
getParentRoute: () => rootRoute,
path: '/',
component: () => null,
component: DataLibraryPage,
})
const router = createRouter({ routeTree: rootRoute.addChildren([indexRoute]) })
@@ -103,6 +107,9 @@ describe('DataLibraryPage', () => {
renderPage()
expect(await screen.findByTestId('data-library-empty')).toBeInTheDocument()
expect(screen.getByRole('main')).toContainElement(screen.getByTestId('data-library-empty'))
expect(screen.getByText('box-box · admin')).toBeInTheDocument()
expect(screen.getByText(/Local SQLite domain store/i)).toBeInTheDocument()
expect(screen.getByText(/No ingested seasons yet/i)).toBeInTheDocument()
expect(screen.getByText('box-box --ingest-year 2025')).toBeInTheDocument()
})
@@ -115,10 +122,15 @@ describe('DataLibraryPage', () => {
renderPage()
expect(await screen.findByTestId('data-library')).toBeInTheDocument()
expect(screen.getByRole('main')).toContainElement(screen.getByTestId('data-library'))
await waitFor(() => {
expect(mockFetchLocalMeetings).toHaveBeenCalledWith(2025)
})
expect(screen.getByText('box-box · admin')).toBeInTheDocument()
const statLabels = [...document.querySelectorAll('.dl-stat-label')].map((el) => el.textContent)
expect(statLabels).toEqual(expect.arrayContaining(['Full', 'Partial', 'Cancelled', 'Missing', 'Total']))
expect(document.querySelector('.dl-content-meta')).toHaveTextContent(/1 meeting/)
expect(await screen.findByTestId('meeting-detail')).toBeInTheDocument()
expect(screen.getAllByText('Monaco').length).toBeGreaterThan(0)
expect(screen.getByText('11/11')).toBeInTheDocument()
@@ -126,6 +138,17 @@ describe('DataLibraryPage', () => {
expect(screen.getByText('box-box --ingest-session 9472')).toBeInTheDocument()
})
it('does not disable pinch-zoom in the viewport meta', () => {
const html = readFileSync(resolve(__dirname, '../../index.html'), 'utf8')
const match = html.match(/<meta name="viewport" content="([^"]+)"/)
expect(match).not.toBeNull()
const content = match![1]
expect(content).toMatch(/width\s*=\s*device-width/)
expect(content).toMatch(/initial-scale\s*=\s*1/)
expect(content).not.toMatch(/user-scalable\s*=\s*no/i)
expect(content).not.toMatch(/maximum-scale/i)
})
it('shows partial badge for partial weekends', async () => {
const partialWeekend: Weekend = {
...weekend,
@@ -223,8 +223,6 @@ describe('RacePreviewPage', () => {
expect(screen.getByTestId('preview-header')).toHaveTextContent('Monaco')
expect(screen.getByTestId('preview-schedule')).toHaveTextContent('FP1')
expect(screen.getByTestId('preview-track-card')).toBeInTheDocument()
expect(screen.getByRole('img', { name: 'Circuit outline' })).toBeInTheDocument()
expect(screen.queryByTestId('preview-track-fallback')).not.toBeInTheDocument()
await waitFor(() => {
expect(screen.getByTestId('preview-last-year-card')).toHaveTextContent('VER')
@@ -275,75 +273,5 @@ describe('RacePreviewPage', () => {
await waitFor(() => {
expect(screen.getByTestId('preview-last-year-card')).toHaveTextContent('First time on the calendar')
})
const fallback = screen.getByTestId('preview-track-fallback')
expect(screen.getByTestId('preview-track-card')).toContainElement(fallback)
expect(fallback).toHaveTextContent('Monaco')
expect(fallback).toHaveTextContent('A GPS track outline is not available in the local cache.')
expect(screen.queryByRole('img', { name: 'Circuit outline' })).not.toBeInTheDocument()
})
it('shows a designed circuit fallback when the track outline is unavailable', async () => {
const italianGp: Meeting = {
...upcomingMeeting,
meeting_name: 'Italian Grand Prix',
meeting_official_name: 'Formula 1 Pirelli Gran Premio d\'Italia',
location: 'Monza',
country_name: 'Italy',
country_code: 'ITA',
circuit_short_name: 'Monza',
}
mockFetchMeetings.mockImplementation(async (year: number) => {
if (year === 2099) return [italianGp]
if (year === 2098) return [{ ...italianGp, meeting_key: 90, year: 2098 }]
return []
})
mockFetchSessions.mockImplementation(async (meetingKey: number) => {
if (meetingKey === 100) return sessions
if (meetingKey === 90) return [priorRaceSession]
return []
})
mockFetchTrackOutline.mockResolvedValue(null)
renderPage()
await waitFor(() => {
expect(screen.getByTestId('preview-track-fallback')).toBeInTheDocument()
})
const card = screen.getByTestId('preview-track-card')
const fallback = screen.getByTestId('preview-track-fallback')
expect(card).toContainElement(fallback)
expect(card).toHaveTextContent('Circuit')
expect(fallback).toHaveTextContent('Monza')
expect(fallback).toHaveTextContent('Italy')
expect(fallback).toHaveTextContent('A GPS track outline is not available in the local cache.')
expect(fallback).not.toHaveTextContent(/unknown/i)
expect(screen.queryByRole('img', { name: 'Circuit outline' })).not.toBeInTheDocument()
expect(card).not.toHaveTextContent('Track outline unavailable for this circuit')
})
it('keeps a thrown outline request distinct from the designed unavailable state', async () => {
mockFetchMeetings.mockImplementation(async (year: number) => {
if (year === 2099) return [upcomingMeeting]
if (year === 2098) return [priorMeeting]
return []
})
mockFetchSessions.mockImplementation(async (meetingKey: number) => {
if (meetingKey === 100) return sessions
if (meetingKey === 90) return [priorRaceSession]
return []
})
mockFetchTrackOutline.mockRejectedValue(new Error('outline request failed'))
renderPage()
await waitFor(() => {
expect(screen.getByTestId('preview-track-card')).toHaveTextContent('outline request failed')
})
expect(screen.queryByTestId('preview-track-fallback')).not.toBeInTheDocument()
expect(screen.queryByRole('img', { name: 'Circuit outline' })).not.toBeInTheDocument()
})
})