From 5370e2184c23f49c21d8534a959e92756b972424 Mon Sep 17 00:00:00 2001 From: TheophileDiot Date: Mon, 31 Aug 2026 10:46:54 +0200 Subject: [PATCH] BodyMap tests: import the geometry before the first render, not inside the wait --- frontend/src/components/BodyMap.test.jsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/BodyMap.test.jsx b/frontend/src/components/BodyMap.test.jsx index 1cc2b43..cc328bb 100644 --- a/frontend/src/components/BodyMap.test.jsx +++ b/frontend/src/components/BodyMap.test.jsx @@ -1,7 +1,7 @@ // @vitest-environment happy-dom import React, { act } from 'react' import { createRoot } from 'react-dom/client' -import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest' import BodyMap, { BodyMapLegend } from './BodyMap.jsx' globalThis.IS_REACT_ACT_ENVIRONMENT = true @@ -9,6 +9,14 @@ globalThis.IS_REACT_ACT_ENVIRONMENT = true let container let root +// BodyMap fetches its ~90 KB of geometry with a dynamic import on first render, and the +// waitFor below allows one second for it. That is ample once the module is in the ESM +// registry and not always ample when it is not: on a loaded CI runner the first map render +// in this file paid the cold import and timed out, while every later test passed on the +// component's warm CACHE. Import it here so the wait covers rendering, not module loading, +// and the file stops depending on how fast the machine is. +beforeAll(() => import('../lib/body-paths.js')) + beforeEach(() => { container = document.createElement('div') document.body.appendChild(container)