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.
JavaScript apple-watchbodyweightdockerfitnessfitness-trackergymhealthiosmcpnodejspasskeysprogressive-web-applicationspwareactself-hostedself-hostingvitewebauthnweightliftingworkout-tracker
Tests: quieter output (act environment flag, settle async media answers, unique workout ids in fixtures)
Duarte Santosdbcb99b8f0c3
diff --git a/frontend/src/sheets.finish-hold.test.jsx b/frontend/src/sheets.finish-hold.test.jsxindex 01b060e2b..53ada1bd3 100644--- a/frontend/src/sheets.finish-hold.test.jsx+++ b/frontend/src/sheets.finish-hold.test.jsx@@ -40,6 +40,7 @@ function install(sets) {const holdInto = set => vi.fn(elapsed => useStore.getState().update(s => { s.active.entries[0].sets[set].sec = elapsed }))beforeEach(() => {+ globalThis.IS_REACT_ACT_ENVIRONMENT = truevi.useFakeTimers()localStorage.clear()useUI.getState().stopRest()diff --git a/frontend/src/sheets.finish-keep-routine.test.jsx b/frontend/src/sheets.finish-keep-routine.test.jsxindex 012c110e7..c50229e2c 100644--- a/frontend/src/sheets.finish-keep-routine.test.jsx+++ b/frontend/src/sheets.finish-keep-routine.test.jsx@@ -21,6 +21,8 @@ function renderTopSheet() {mounted.push(root)act(() => root.render(sheet.render(() => useUI.getState().closeSheet(sheet.id))))}+// The photo section asks the media store whether it can keep files; let that answer land.+const settle = () => act(async () => {})const button = text => [...host.querySelectorAll('button')].find(b => b.textContent.trim() === text)function install(entries) {@@ -36,6 +38,7 @@ const bench = { id: '0025', rid: 'r1', target: { sets: 1, reps: 5, weight: 60 },const raise = { id: '0334', rid: 'r1', addedInSession: true, target: { sets: 2, reps: 12, weight: 8 }, sets: [{ w: 8, r: 12, done: true }, { w: 8, r: 12, done: true }] }beforeEach(() => {+ globalThis.IS_REACT_ACT_ENVIRONMENT = truelocalStorage.clear()useUI.setState({ sheets: [], timer: null, work: null })})@@ -45,10 +48,11 @@ afterEach(() => {})describe('finish summary: keep an added exercise in the routine', () => {- it('offers it, and one tap adds it with the setup of the session', () => {+ it('offers it, and one tap adds it with the setup of the session', async () => {install([clone(bench), clone(raise)])act(() => finishWorkoutNow())renderTopSheet()+ await settle()expect(host.querySelector('[data-keep-in-routine]')).toBeTruthy()// Nothing changed yet: the offer is only an offer.expect(S().routines[0].ex.map(x => x.id)).toEqual(['0025'])@@ -60,10 +64,11 @@ describe('finish summary: keep an added exercise in the routine', () => {expect(JSON.stringify(S().workouts.at(-1))).not.toContain('addedInSession')})- it('says nothing when the session added nothing', () => {+ it('says nothing when the session added nothing', async () => {install([clone(bench)])act(() => finishWorkoutNow())renderTopSheet()+ await settle()expect(host.querySelector('[data-keep-in-routine]')).toBeNull()})})diff --git a/frontend/src/sheets.workout-media.test.jsx b/frontend/src/sheets.workout-media.test.jsxindex a1c70b7fc..53caea39e 100644--- a/frontend/src/sheets.workout-media.test.jsx+++ b/frontend/src/sheets.workout-media.test.jsx@@ -152,7 +152,7 @@ describe('a workout\'s photos and videos', () => {expect([...media.pendingNow()]).toHaveLength(4) // two files, each with its poster})- it('a server without media storage: no section while there is nothing; with some, no Add and why', () => {+ it('a server without media storage: no section while there is nothing; with some, no Add and why', async () => {useStore.setState({ user: { id: 'u1', name: 'One' }, config: { passkeys: true } })workoutDetailSheet(S().workouts[0])expect(renderTop().querySelector('.wmedia')).toBeNull()@@ -162,9 +162,11 @@ describe('a workout\'s photos and videos', () => {expect(host.querySelectorAll('.wmedia-item')).toHaveLength(1)expect(host.querySelector('.wmedia-add')).toBeNull()expect(host.textContent).toContain('Your server does not store photos and videos yet.')+ // Let the media store's async answers land inside act, not after the test.+ await settle()})- it('signed in, Add is offered only when the server says a workout may carry media', () => {+ it('signed in, Add is offered only when the server says a workout may carry media', async () => {const caps = { imageMB: 2, gifMB: 8, videoMB: 40, videoSec: 60, quotaMB: 200 }useStore.setState({ user: { id: 'u1', name: 'One' }, config: { media: caps } })expect(render(<WorkoutMediaSection w={S().workouts[0]} hint />).querySelector('.wmedia')).toBeNull()@@ -176,6 +178,8 @@ describe('a workout\'s photos and videos', () => {// A guest is not held to it: the files stay on the device.useStore.setState({ user: null, config: { media: caps } })expect(render(<WorkoutMediaSection w={S().workouts[0]} />).querySelector('.wmedia-add')).toBeTruthy()+ // Let the media store's async answers land inside act, not after the test.+ await settle()})it('a browser that cannot store files shows no empty section', async () => {@@ -186,16 +190,18 @@ describe('a workout\'s photos and videos', () => {expect(host.querySelector('.wmedia')).toBeNull()})- it('signed out, the finish screen\'s section explains itself; where the files live is said once there are some', () => {+ it('signed out, the finish screen\'s section explains itself; where the files live is said once there are some', async () => {const host = render(<WorkoutMediaSection w={S().workouts[0]} hint />)expect(host.textContent).toContain('A progress photo or a form-check video, kept with this workout.')expect(host.textContent).not.toContain('Kept on this device only')useStore.setState(s => ({ S: { ...s.S, workouts: [workout({ media: [refOf(1)] })] } }))const withOne = render(<WorkoutMediaSection w={S().workouts[0]} hint />)expect(withOne.textContent).toContain('Kept on this device only')+ // Let the media store's async answers land inside act, not after the test.+ await settle()})- it('the viewer takes focus, keeps Tab inside, and steps with the arrow keys (mirrored right to left)', () => {+ it('the viewer takes focus, keeps Tab inside, and steps with the arrow keys (mirrored right to left)', async () => {useStore.setState(s => ({ S: { ...s.S, workouts: [workout({ media: [refOf(1), refOf(3), refOf(5)] })] } }))const opener = document.createElement('button')document.body.appendChild(opener)@@ -223,14 +229,18 @@ describe('a workout\'s photos and videos', () => {key('ArrowRight')expect(count()).toBe('2 / 3')} finally { document.documentElement.dir = 'ltr' }+ // Let the media store's async answers land inside act, not after the test.+ await settle()})- it('Delete workout in the detail sheet says its photos and videos go with it', () => {+ it('Delete workout in the detail sheet says its photos and videos go with it', async () => {useStore.setState(s => ({ S: { ...s.S, workouts: [workout({ media: [refOf(1)] })] } }))workoutDetailSheet(S().workouts[0])const host = renderTop()act(() => [...host.querySelectorAll('button')].find(b => b.textContent.trim() === 'Delete workout').click())expect(renderTop().textContent).toContain('This removes it from your history for good. Its photo or video is deleted with it.')+ // Let the media store's async answers land inside act, not after the test.+ await settle()})it('Delete workout without any says nothing about them', () => {diff --git a/frontend/src/views/History.grow.test.jsx b/frontend/src/views/History.grow.test.jsxindex 2d8b5aecf..b0b48a9d8 100644--- a/frontend/src/views/History.grow.test.jsx+++ b/frontend/src/views/History.grow.test.jsx@@ -40,6 +40,7 @@ const rows = host => host.querySelectorAll('.list .item').lengthdescribe('History grows as it is scrolled', () => {let History, PAGEbeforeEach(async () => {+ globalThis.IS_REACT_ACT_ENVIRONMENT = truevi.resetModules()observers = []window.IntersectionObserver = FakeIOdiff --git a/frontend/src/views/Stats.recovery.test.jsx b/frontend/src/views/Stats.recovery.test.jsxindex 4d2181c4f..8341ad602 100644--- a/frontend/src/views/Stats.recovery.test.jsx+++ b/frontend/src/views/Stats.recovery.test.jsx@@ -104,13 +104,13 @@ function lifecycleWorkouts(now = BASE_NOW) {]}-function allFatiguedWorkout(now = BASE_NOW) {+function allFatiguedWorkout(now = BASE_NOW, wid = 'all-fatigued') {const ids = ['1018', '1012', '1167', '1013', '3011', '1413', '1399', '1016', '1005','1010', '1003', '1001', '1511', '1494', '1002', '1000', '1396',]return workout(- 'all-fatigued',+ wid,now,ids.map(id => entry(id, Array.from({ length: 12 }, () => set(true)))),)@@ -324,7 +324,7 @@ describe('Stats muscle recovery view runtime', () => {it('renders fixed absolute bands through the actual Fatigue and Strength views', async () => {// Two back-to-back full sessions: even 0.4-weighted secondary movers accumulate// 2 x 12 x 0.4 / 8 = 1.2 raw units, clearing the top band everywhere.- resetFixture([allFatiguedWorkout(), allFatiguedWorkout()])+ resetFixture([allFatiguedWorkout(), allFatiguedWorkout(BASE_NOW, 'all-fatigued-2')])await mountStats()await click(viewButton('Fatigue'))const fatigueMap = lastMap()diff --git a/frontend/src/views/StructuralBalance.test.jsx b/frontend/src/views/StructuralBalance.test.jsxindex 7a7303a8e..8961a2da8 100644--- a/frontend/src/views/StructuralBalance.test.jsx+++ b/frontend/src/views/StructuralBalance.test.jsx@@ -27,7 +27,7 @@ function render(View = StructuralBalance) {function setDoneSet(w, r) { return { done: true, w, r } }function workoutAt(id, start, sets) {- return { d: new Date(start).toISOString(), start, entries: [{ id, sets }] }+ return { id: 'w-' + id, d: new Date(start).toISOString(), start, entries: [{ id, sets }] }}beforeEach(() => {