Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

useStore.tabs test: transform the store's heavy imports at collection

Duarte Santosb5db860aafa1
diff --git a/frontend/src/store/useStore.tabs.test.jsx b/frontend/src/store/useStore.tabs.test.jsx
index 60bb6ce3b..f4fbdb4dc 100644
--- a/frontend/src/store/useStore.tabs.test.jsx
+++ b/frontend/src/store/useStore.tabs.test.jsx
@@ -11,6 +11,15 @@ const h = vi.hoisted(() => ({ api: null }))
vi.mock('../lib/api.js', () => ({ api: (...a) => h.api(...a), setRemoteAuth: () => {} }))
vi.mock('./useUI.js', () => ({ useUI: { getState: () => ({ toast: () => {} }) } }))
+// The store's heavy imports (the 1 MB exercise table, the sync and mobile libraries) are
+// transformed here, while the file is collected. Cold, that took seconds and was billed to the
+// first test, past its timeout under a parallel run. The store itself is not imported here, so
+// no extra tab listens on the window; vi.resetModules() in openTab keeps the transforms.
+await Promise.all([
+ import('../lib/exercises.js'), import('../lib/mobile.js'), import('../lib/sync-merge.js'), import('../lib/media-store.js'),
+ import('../lib/remote.js'), import('../lib/health-sync.js'), import('../lib/i18n.js'),
+])
+
const clone = v => JSON.parse(JSON.stringify(v))
const w = (id, d = '2026-09-01') => ({ id, d, start: 1, entries: [] })
const ids = st => (st?.workouts || []).map(x => x.id)