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.

Merge remote-tracking branch 'pr/443'

Duarte Santosf44f2e36763b
diff --cc frontend/src/views/Workout.test.jsx
index 029eb0c93,37726620c..53b04782f
--- a/frontend/src/views/Workout.test.jsx
+++ b/frontend/src/views/Workout.test.jsx
@@@ -1899,14 -1770,91 +1905,99 @@@ describe('workout controls: the more me
expect(mocks.confirmSheet).toHaveBeenCalled()
})
+ it('adds an in-session warm-up at the bar, never under it', async () => {
+ const bench = exercise('0025', [false], { target: { mode: 'reps', reps: 10, weight: 55 }, sets: [{ w: 55, r: 10, done: false }] })
+ await mount([bench], 0, { unit: 'lb' })
+ await act(async () => { container.querySelector('button[aria-label="More"]').dispatchEvent(new dom.Event('click', { bubbles: true })) })
+ await act(async () => { item('Add warm-up set').onClick() })
+ expect(mocks.S.active.entries[0].sets.map(s => s.w)).toEqual([45, 55])
+ })
+
+ // Move down on a superset member's More menu moved the whole superset and left the member next
+ // to the same partner (#377 reports it in the routine editor). It now swaps inside the superset.
+ it('moves a superset member inside its superset from that member\'s More menu', async () => {
+ await mount([
+ exercise('bench', [true]),
+ exercise('pull-up', [false], { sg: 'm' }),
+ exercise('leg-raise', [false], { sg: 'm' }),
+ exercise('plank', [false], { sg: 'm' }),
+ ], 1)
+ const more = container.querySelector('.ss-ex[data-exidx="2"] button[aria-label="More"]')
+ expect(more).toBeTruthy()
+ await act(async () => { more.dispatchEvent(new dom.Event('click', { bubbles: true })) })
+ expect(item('Move up').disabled).toBe(false)
+ expect(item('Move down').disabled).toBe(false)
+ await act(async () => { item('Move down').onClick() })
+
+ expect(mocks.S.active.entries.map(entry => entry.id)).toEqual(['bench', 'pull-up', 'plank', 'leg-raise'])
+ expect(mocks.S.active.entries.slice(1).map(entry => entry.sg)).toEqual(['m', 'm', 'm'])
+ expect(mocks.S.active.entries[mocks.S.active.cur].id).toBe('pull-up')
+ })
+
+ // A move reorders the entries, and two things the screen keeps by index have to follow their
+ // exercise: the running rest (timer.forIdx) and how many sets of each exercise have already
+ // counted as progress (the mark a tick is compared against to tell new work from a re-check).
+ const openMore = async exIdx => {
+ const more = container.querySelector(`.ss-ex[data-exidx="${exIdx}"] button[aria-label="More"]`)
+ || container.querySelector('button[aria-label="More"]')
+ await act(async () => { more.dispatchEvent(new dom.Event('click', { bubbles: true })) })
+ }
+ const restFor = forIdx => ({ left: 60, total: 60, endsAt: Date.now() + 60_000, forIdx, kind: 'set' })
+
+ it('a member swap during a rest hands the rest to the moved exercise\'s new place', async () => {
+ await mount([
+ exercise('bench', [true]),
+ exercise('pull-up', [true, false], { sg: 'm' }),
+ exercise('leg-raise', [true, false], { sg: 'm' }),
+ exercise('plank', [false, false], { sg: 'm' }),
+ ], 1)
+ mocks.timer = restFor(2)
+ await openMore(2)
+ await act(async () => { item('Move down').onClick() })
+
+ expect(mocks.S.active.entries.map(entry => entry.id)).toEqual(['bench', 'pull-up', 'plank', 'leg-raise'])
+ expect(mocks.timer.forIdx).toBe(3)
+ expect(mocks.S.active.entries[mocks.timer.forIdx].id).toBe('leg-raise')
+ expect(mocks.timer.endsAt).toBeGreaterThan(Date.now())
+ expect(mocks.stopRest).not.toHaveBeenCalled()
+ })
+
+ it('a whole-superset move during a rest hands the rest to the resting exercise\'s new place', async () => {
+ await mount([
+ exercise('bench', [true, false]),
+ exercise('pull-up', [false], { sg: 'm' }),
+ exercise('leg-raise', [false], { sg: 'm' }),
+ ], 1)
+ mocks.timer = restFor(0)
+ await openMore(1)
+ await act(async () => { item('Move up').onClick() })
+
+ expect(mocks.S.active.entries.map(entry => entry.id)).toEqual(['pull-up', 'leg-raise', 'bench'])
+ expect(mocks.timer.forIdx).toBe(2)
+ expect(mocks.S.active.entries[mocks.timer.forIdx].id).toBe('bench')
+ })
+
+ it('a member swap keeps each exercise\'s counted sets with it, so its next tick still counts', async () => {
+ // pull-up has two sets counted, leg-raise none. After the swap, the leg raise's first tick
+ // is new work and moves on through the superset; read against the pull-up's two it would be
+ // taken for a re-check and go nowhere.
+ await mount([
+ exercise('bench', [true]),
+ exercise('pull-up', [true, true, false], { sg: 'm' }),
+ exercise('leg-raise', [false, false, false], { sg: 'm' }),
+ exercise('plank', [false, false, false], { sg: 'm' }),
+ ], 1)
+ await openMore(1)
+ await act(async () => { item('Move down').onClick() })
+ expect(mocks.S.active.entries.map(entry => entry.id)).toEqual(['bench', 'leg-raise', 'pull-up', 'plank'])
+ expect(mocks.S.active.cur).toBe(1)
+
+ const tick = container.querySelector('.ss-ex[data-exidx="1"] [role="checkbox"]')
+ await act(async () => { tick.dispatchEvent(new dom.Event('click', { bubbles: true })) })
+ expect(mocks.S.active.entries[1].sets.filter(set => set.done)).toHaveLength(1)
+ expect(mocks.S.active.cur).toBe(2)
+ })
+
it('opens the exercise history sheet from the More menu, for the tapped exercise', async () => {
// the screen shows one exercise at a time, so "the tapped exercise" is the current one
await mount([exercise('plain-bench', [false]), exercise('plain-row', [false])], 1)