Skip to content

Commit 2fff666

Browse files
atulmguptaCopilot
andcommitted
ci+test: stabilize frontend on arc-runner (timeout, ResizeObserver, pin to ubuntu-latest)
The Backend job now passes on ubuntu-latest (see prior commit). The Frontend job was also failing on the arc-runner, with two distinct root causes — both pre-existing latent issues that only became visible once the upstream Test step got past the gcc problem and the suite actually started running: 1. **45 "Test timed out in 5000ms" failures.** The arc-runner is resource-starved enough that vitest's default 5s testTimeout is below the noise floor for tests that mount QueryClient + Router + lazy-loaded chart components. Bump `testTimeout` and `hookTimeout`n in `vite.config.ts` to 30s — generous enough to absorb CI jitter while still catching genuinely runaway tests. Local full-suite runtime is unchanged (~80s end-to-end). 2. **~10 "ReferenceError: ResizeObserver is not defined" failures.** jsdom doesn't ship `ResizeObserver`. A couple of individual test files installed ad-hoc `vi.stubGlobal('ResizeObserver', …)` shims, but as soon as ANY non-stubbing test imports a chart (Recharts ResponsiveContainer) or a grid (react-grid-layout) component transitively, it crashes. Install a global polyfill in `src/test-setup.ts`, matching what we already do for `IntersectionObserver` and `EventSource`. Removes per-test boilerplate that lived in `SmallMultiplesChart.test.tsx` and `DashboardGrid.mobile.test.tsx` (those files keep their local stubs — the global polyfill just makes them no-ops). 3. **Pin Frontend job to ubuntu-latest** for the same reason as Backend: even with the 30s timeout, the arc-runner's throughput is inconsistent enough that we trade flakes for wall-clock and burnt minutes. Re-pin to arc-runner once the runner image gets the bandwidth budget. Verified locally: - `npx tsc --noEmit` clean - `npm test -- --run` -> 397 files / 4137 tests / 0 failures - `npm run lint` (24 audit stages) clean Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 93423ff commit 2fff666

3 files changed

Lines changed: 32 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,13 @@ jobs:
180180
181181
frontend:
182182
name: Frontend (lint + test + build)
183-
runs-on: ${{ inputs.runner || 'arc-runner' }}
183+
# Pinned to ubuntu-latest to match the Backend job: the arc-runner is
184+
# too resource-starved for vitest's default 5s testTimeout (45+ tests
185+
# routinely time out under load even though the same suite finishes
186+
# in ~80s locally and on ubuntu-latest). Re-pin to arc-runner once
187+
# the runner image has the bandwidth budget for jsdom + chart-heavy
188+
# component trees.
189+
runs-on: ubuntu-latest
184190
defaults:
185191
run:
186192
working-directory: web

web/src/test-setup.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,23 @@ if (typeof globalThis.IntersectionObserver === 'undefined') {
116116
globalThis.IntersectionObserver = MockIntersectionObserver as any
117117
}
118118

119+
// Polyfill ResizeObserver for jsdom (used by Recharts ResponsiveContainer,
120+
// react-grid-layout, and a handful of our own chart wrappers). Individual
121+
// test files used to install ad-hoc `vi.stubGlobal('ResizeObserver', …)`,
122+
// but as soon as a non-stubbing test imports a chart/grid component
123+
// transitively, jsdom throws `ReferenceError: ResizeObserver is not
124+
// defined`. Installing it globally here matches what we do for
125+
// IntersectionObserver and EventSource and removes the per-test boilerplate.
126+
class MockResizeObserver {
127+
observe() {}
128+
unobserve() {}
129+
disconnect() {}
130+
}
131+
132+
if (typeof globalThis.ResizeObserver === 'undefined') {
133+
globalThis.ResizeObserver = MockResizeObserver as any
134+
}
135+
119136
// Mock EventSource for SSE tests (not available in jsdom)
120137
global.EventSource = class EventSource {
121138
static CONNECTING = 0

web/vite.config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,14 @@ export default defineConfig({
138138
environment: 'jsdom',
139139
setupFiles: ['./src/test-setup.ts'],
140140
include: ['src/**/*.test.{ts,tsx}'],
141+
// Default is 5000ms. CI runners (especially shared / cgroup-throttled
142+
// self-hosted ones) routinely starve vitest workers enough that 5s
143+
// is below the noise floor for tests that mount QueryClient + Router
144+
// + lazy-loaded chart components. 30s is generous enough to absorb
145+
// CI jitter while still catching genuinely runaway tests. Locally
146+
// the suite still completes in ~80s.
147+
testTimeout: 30000,
148+
hookTimeout: 30000,
141149
coverage: {
142150
reporter: ['text', 'lcov', 'html', 'json-summary'],
143151
include: ['src/**/*.{ts,tsx}'],

0 commit comments

Comments
 (0)