mirror of
https://github.com/AmanTahiliani/box-box.git
synced 2026-08-07 11:54:59 -04:00
Make Playwright runs hermetic and fix stale race-hub specs
Six suite failures had rotted in: three race-hub specs targeted the sub-tabbed Race Story UI deleted in the Phase 22 redesign, and the command-center specs depended on the real OpenF1 calendar, whose focus weekend drifted away from the seeded Monaco session as time passed. The e2e/visual configs now point BOXBOX_OPENF1_BASE_URL (new override) at an unreachable address so runs are hermetic and date-stable; the race-hub specs were rewritten against the current RaceStoryCanvas UI, and the one drifted mobile snapshot regenerated. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -172,12 +172,13 @@ Replay: `h`/`l` or arrows scrub laps
|
|||||||
|
|
||||||
- Go: tests in `openf1_test.go` hit the real OpenF1 API and use `skipOnRateLimit(t, err)` to skip on HTTP 429 (require internet). `internal/web` handler tests run offline.
|
- Go: tests in `openf1_test.go` hit the real OpenF1 API and use `skipOnRateLimit(t, err)` to skip on HTTP 429 (require internet). `internal/web` handler tests run offline.
|
||||||
- Frontend: Vitest + Testing Library in `frontend/src/test/` (`npm run test` inside `frontend/`).
|
- Frontend: Vitest + Testing Library in `frontend/src/test/` (`npm run test` inside `frontend/`).
|
||||||
- E2E/visual: Playwright at repo root (`npm run test:e2e`, `npm run test:visual`). Configs seed a temp domain DB and start the Go server with `BOXBOX_DISABLE_LIVE=1` plus a Vite dev server — no manual setup needed.
|
- E2E/visual: Playwright at repo root (`npm run test:e2e`, `npm run test:visual`). Configs seed a temp domain DB and start the Go server with `BOXBOX_DISABLE_LIVE=1` and `BOXBOX_OPENF1_BASE_URL` pointed at an unreachable address (hermetic: no live OpenF1 dependency, date-stable) plus a Vite dev server — no manual setup needed.
|
||||||
|
|
||||||
## Environment
|
## Environment
|
||||||
|
|
||||||
- `OPENF1_API_KEY` — Optional Bearer token for paid tier (live session WebSocket access)
|
- `OPENF1_API_KEY` — Optional Bearer token for paid tier (live session WebSocket access)
|
||||||
- `BOXBOX_DISABLE_LIVE=1` — Skip the background SignalR live feed in web mode (used by e2e)
|
- `BOXBOX_DISABLE_LIVE=1` — Skip the background SignalR live feed in web mode (used by e2e)
|
||||||
|
- `BOXBOX_OPENF1_BASE_URL` — Override the OpenF1 API root (default `https://api.openf1.org`; e2e sets an unreachable address for hermetic runs)
|
||||||
- `BOXBOX_API_PORT` — Go API port that the Vite dev proxy targets (default 8080)
|
- `BOXBOX_API_PORT` — Go API port that the Vite dev proxy targets (default 8080)
|
||||||
- Logs: TUI writes `box-box.log` in project root; web/ingest modes log to stderr
|
- Logs: TUI writes `box-box.log` in project root; web/ingest modes log to stderr
|
||||||
- HTTP cache at `~/.cache/box-box/cache.db`; domain DB at `~/.local/share/box-box/boxbox.db` (override with `--db`)
|
- HTTP cache at `~/.cache/box-box/cache.db`; domain DB at `~/.local/share/box-box/boxbox.db` (override with `--db`)
|
||||||
|
|||||||
12
cmd/main.go
12
cmd/main.go
@@ -41,11 +41,19 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BOXBOX_OPENF1_BASE_URL overrides the upstream OpenF1 API root. E2E runs
|
||||||
|
// point it at an unreachable address so tests stay hermetic and
|
||||||
|
// deterministic regardless of wall-clock date or network state.
|
||||||
|
baseURL := os.Getenv("BOXBOX_OPENF1_BASE_URL")
|
||||||
|
if baseURL == "" {
|
||||||
|
baseURL = "https://api.openf1.org"
|
||||||
|
}
|
||||||
|
|
||||||
var client *api.OpenF1Client
|
var client *api.OpenF1Client
|
||||||
if apiKey := os.Getenv("OPENF1_API_KEY"); apiKey != "" {
|
if apiKey := os.Getenv("OPENF1_API_KEY"); apiKey != "" {
|
||||||
client = api.NewOpenF1ClientWithKey("https://api.openf1.org", 15*time.Second, apiKey)
|
client = api.NewOpenF1ClientWithKey(baseURL, 15*time.Second, apiKey)
|
||||||
} else {
|
} else {
|
||||||
client = api.NewOpenF1Client("https://api.openf1.org", 15*time.Second)
|
client = api.NewOpenF1Client(baseURL, 15*time.Second)
|
||||||
}
|
}
|
||||||
defer client.Close()
|
defer client.Close()
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ export default defineConfig({
|
|||||||
],
|
],
|
||||||
webServer: [
|
webServer: [
|
||||||
{
|
{
|
||||||
command: `go run ./scripts/seed-e2e-db/main.go --db ${E2E_DB} && BOXBOX_DISABLE_LIVE=1 go run ./cmd/main.go --web --db ${E2E_DB} --port ${API_PORT}`,
|
// BOXBOX_OPENF1_BASE_URL points at an unreachable address so the e2e stack
|
||||||
|
// never depends on the live OpenF1 API (keeps runs hermetic + date-stable).
|
||||||
|
command: `go run ./scripts/seed-e2e-db/main.go --db ${E2E_DB} && BOXBOX_DISABLE_LIVE=1 BOXBOX_OPENF1_BASE_URL=http://127.0.0.1:9 go run ./cmd/main.go --web --db ${E2E_DB} --port ${API_PORT}`,
|
||||||
url: `http://localhost:${API_PORT}/api/v1/race-hub?session_key=9472`,
|
url: `http://localhost:${API_PORT}/api/v1/race-hub?session_key=9472`,
|
||||||
reuseExistingServer: false,
|
reuseExistingServer: false,
|
||||||
timeout: 120_000,
|
timeout: 120_000,
|
||||||
|
|||||||
@@ -49,7 +49,9 @@ export default defineConfig({
|
|||||||
],
|
],
|
||||||
webServer: [
|
webServer: [
|
||||||
{
|
{
|
||||||
command: `go run ./scripts/seed-e2e-db/main.go --db ${E2E_DB} && BOXBOX_DISABLE_LIVE=1 go run ./cmd/main.go --web --db ${E2E_DB} --port ${API_PORT}`,
|
// BOXBOX_OPENF1_BASE_URL points at an unreachable address so the visual stack
|
||||||
|
// never depends on the live OpenF1 API (keeps runs hermetic + date-stable).
|
||||||
|
command: `go run ./scripts/seed-e2e-db/main.go --db ${E2E_DB} && BOXBOX_DISABLE_LIVE=1 BOXBOX_OPENF1_BASE_URL=http://127.0.0.1:9 go run ./cmd/main.go --web --db ${E2E_DB} --port ${API_PORT}`,
|
||||||
url: `http://localhost:${API_PORT}/api/v1/race-hub?session_key=9472`,
|
url: `http://localhost:${API_PORT}/api/v1/race-hub?session_key=9472`,
|
||||||
reuseExistingServer: false,
|
reuseExistingServer: false,
|
||||||
timeout: 120_000,
|
timeout: 120_000,
|
||||||
|
|||||||
@@ -17,24 +17,29 @@ test.describe('Race Hub Weekend Workspace', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('shows final classification when switching to Race Story', async ({ page }) => {
|
test('shows final running order when switching to Race Story', async ({ page }) => {
|
||||||
await page.goto(`/race-hub?session_key=${FULL_SESSION}`)
|
await page.goto(`/race-hub?session_key=${FULL_SESSION}`)
|
||||||
await page.getByRole('tab', { name: 'Race Story' }).click()
|
await page.getByRole('tab', { name: 'Race Story' }).click()
|
||||||
|
|
||||||
await expect(page.getByText('Final Classification')).toBeVisible()
|
const verRow = page.locator('.rs-driver-row', {
|
||||||
await expect(page.locator('.drv-code', { hasText: 'VER' })).toBeVisible()
|
has: page.locator('.rs-driver-name', { hasText: 'VER' }),
|
||||||
await expect(page.locator('.drv-code', { hasText: 'HAM' })).toBeVisible()
|
})
|
||||||
|
const hamRow = page.locator('.rs-driver-row', {
|
||||||
|
has: page.locator('.rs-driver-name', { hasText: 'HAM' }),
|
||||||
|
})
|
||||||
|
await expect(verRow.locator('.rs-pos-col')).toHaveText('1')
|
||||||
|
await expect(hamRow.locator('.rs-pos-col')).toHaveText('2')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Race Story exposes classification, grid, and positions sub-views', async ({ page }) => {
|
test('Race Story renders the position evolution chart for a full session', async ({ page }) => {
|
||||||
await page.goto(`/race-hub?session_key=${FULL_SESSION}`)
|
await page.goto(`/race-hub?session_key=${FULL_SESSION}`)
|
||||||
await page.getByRole('tab', { name: 'Race Story' }).click()
|
await page.getByRole('tab', { name: 'Race Story' }).click()
|
||||||
|
|
||||||
await page.getByRole('tab', { name: 'Starting Grid' }).click()
|
|
||||||
await expect(page.locator('.sec-title', { hasText: 'Starting Grid' })).toBeVisible()
|
|
||||||
|
|
||||||
await page.getByRole('tab', { name: 'Positions' }).click()
|
|
||||||
await expect(page.locator('[data-testid="position-chart"]')).toBeVisible()
|
await expect(page.locator('[data-testid="position-chart"]')).toBeVisible()
|
||||||
|
await expect(
|
||||||
|
page.getByRole('img', { name: 'Position evolution chart' }),
|
||||||
|
).toBeVisible()
|
||||||
|
await expect(page.getByText('Lap-by-lap positions not available.')).not.toBeVisible()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('strategy tab renders stint chart when stints are available', async ({ page }) => {
|
test('strategy tab renders stint chart when stints are available', async ({ page }) => {
|
||||||
@@ -53,12 +58,11 @@ test.describe('Race Hub Weekend Workspace', () => {
|
|||||||
await expect(page.locator('[data-testid="strategy-chart"]')).not.toBeVisible()
|
await expect(page.locator('[data-testid="strategy-chart"]')).not.toBeVisible()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('positions sub-view shows missing notice when positions are unavailable', async ({
|
test('Race Story shows missing notice when positions are unavailable', async ({
|
||||||
page,
|
page,
|
||||||
}) => {
|
}) => {
|
||||||
await page.goto(`/race-hub?session_key=${CORE_ONLY_SESSION}`)
|
await page.goto(`/race-hub?session_key=${CORE_ONLY_SESSION}`)
|
||||||
await page.getByRole('tab', { name: 'Race Story' }).click()
|
await page.getByRole('tab', { name: 'Race Story' }).click()
|
||||||
await page.getByRole('tab', { name: 'Positions' }).click()
|
|
||||||
|
|
||||||
await expect(page.getByText('Lap-by-lap positions not available.')).toBeVisible()
|
await expect(page.getByText('Lap-by-lap positions not available.')).toBeVisible()
|
||||||
await expect(page.locator('[data-testid="position-chart"]')).not.toBeVisible()
|
await expect(page.locator('[data-testid="position-chart"]')).not.toBeVisible()
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 88 KiB |
@@ -19,6 +19,11 @@ export async function gotoCommandCenterReady(page: Page): Promise<void> {
|
|||||||
await expect(page.getByTestId('command-center')).toBeVisible()
|
await expect(page.getByTestId('command-center')).toBeVisible()
|
||||||
await expect(page.getByTestId('cc-focus')).toBeVisible()
|
await expect(page.getByTestId('cc-focus')).toBeVisible()
|
||||||
await expect(page.getByTestId('cc-session-9472')).toBeVisible()
|
await expect(page.getByTestId('cc-session-9472')).toBeVisible()
|
||||||
|
// The e2e stack runs with an unreachable OpenF1 base URL, so wait for the
|
||||||
|
// season-calendar query to settle on its local fallback before screenshotting.
|
||||||
|
await expect(
|
||||||
|
page.getByText('Using local meetings because the full calendar could not load.'),
|
||||||
|
).toBeVisible()
|
||||||
await waitForScreenshotReady(page)
|
await waitForScreenshotReady(page)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user