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.

Tests: four timing races that turn CI red on a fast or a busy runner

Clauded927f18a651e
diff --git a/api/test/server-media.test.js b/api/test/server-media.test.js
index 95b7bdbf1..3ebe160dd 100644
--- a/api/test/server-media.test.js
+++ b/api/test/server-media.test.js
@@ -385,6 +385,9 @@ test('PUT /api/data still answers 200 when the media bookkeeping fails', async t
const r = await h.pushState(refState());
assert.equal(r.status, 200);
assert.equal((await r.json()).ok, true);
+ // The line goes to stderr before the reply, but the test hears the two on separate pipes: on a
+ // busy machine the reply can be read first.
+ for (let i = 0; i < 100 && !/media noteState/.test(h.log); i++) await new Promise(res => setTimeout(res, 20));
assert.match(h.log, /media noteState/);
const saved = JSON.parse(fs.readFileSync(path.join(h.dataDir, `state-${U1}.json`), 'utf8'));
assert.equal(saved._rev, 1, 'the state itself was saved');
diff --git a/frontend/src/views/CoachChat.demo-failure.test.jsx b/frontend/src/views/CoachChat.demo-failure.test.jsx
index 2a176e3d7..5be6a2881 100644
--- a/frontend/src/views/CoachChat.demo-failure.test.jsx
+++ b/frontend/src/views/CoachChat.demo-failure.test.jsx
@@ -101,6 +101,9 @@ describe('the demo Coach failing inside its timer', () => {
installDom()
await act(async () => { root.render(React.createElement(CoachChat)) })
await settle()
+ // coach-api imports the demo on first use; a cold load is file I/O, which twenty microtasks
+ // do not wait for, so the request would still be in flight when the first line is read.
+ await import('../lib/coach-demo.js')
await click(chip(/Last workout/))
expect(mocks.toast).not.toHaveBeenCalled() // the request was accepted