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
curated2: !52
Duarte Santosfcfe7c4757d2
diff --cc frontend/src/views/Workout.test.jsxindex 2ca9c134a,6e7f1cf03..664261306--- a/frontend/src/views/Workout.test.jsx+++ b/frontend/src/views/Workout.test.jsx@@@ -7,20 -7,11 +7,21 @@@ import Workout from './Workout.jsxconst mocks = vi.hoisted(() => {const state = {S: null,+ timer: null,+ work: null,startRest: vi.fn(),- stopRest: vi.fn(),+ stopRest: null,+ stopWork: null,+ confirmSheet: vi.fn(),topWeightSheet: vi.fn(),+ workoutCompleteSheet: vi.fn(),+ exercisePicker: vi.fn(),+ exConfigSheet: vi.fn(),+ toast: vi.fn(),+ scrollCalls: [],}+ state.stopRest = vi.fn(() => { state.timer = null })+ state.stopWork = vi.fn(() => { state.work = null })state.storeSnapshot = () => ({S: state.S,user: null,@@@ -131,35 -116,14 +135,41 @@@ async function toggleSet(index)await act(async () => { checkbox.dispatchEvent(new dom.Event('click', { bubbles: true })) })}+async function requestDiscard() {+ const button = container.querySelector('button[aria-label="Discard"]')+ expect(button).toBeTruthy()+ await act(async () => { button.dispatchEvent(new dom.Event('click', { bubbles: true })) })+}++async function rerender() {+ await act(async () => { root.render(React.createElement(Workout)) })+}++async function addExerciseThroughSheets(ex = { id: 'added-exercise' }, cfg = { mode: 'reps', sets: 1, reps: 5, weight: 0 }) {+ const addButton = [...container.querySelectorAll('button')]+ .find(button => button.textContent.trim() === 'Add exercise')+ expect(addButton).toBeTruthy()+ await act(async () => { addButton.dispatchEvent(new dom.Event('click', { bubbles: true })) })++ const pickerCall = mocks.exercisePicker.mock.calls.at(-1)+ expect(pickerCall?.[0]).toEqual(expect.any(Function))+ await act(async () => { pickerCall[0](ex) })++ const configCall = mocks.exConfigSheet.mock.calls.at(-1)+ expect(configCall?.[2]).toEqual(expect.any(Function))+ await act(async () => { configCall[2](cfg) })+}++ async function rerenderAt(cur) {+ mocks.S.active.cur = cur+ await act(async () => { root.render(React.createElement(Workout)) })+ }+beforeEach(() => {vi.clearAllMocks()+ mocks.timer = null+ mocks.work = null+ mocks.scrollCalls.length = 0})afterEach(async () => {@@@ -445,6 -194,65 +455,65 @@@ describe('superset flow survives an exe// Partner closes the round (each still has a second set), which is what starts the rest.await toggleSet(2)- expect(mocks.startRest).toHaveBeenCalledWith(90)+ expect(mocks.startRest).toHaveBeenCalledWith(90, expect.any(Number))})})++ describe('superset actionable-set centring', () => {+ it('centres the newly active exercise first incomplete set row', async () => {+ await mount([+ exercise('bench', [true, false], { sg: 'g1' }),+ exercise('row', [true, false, false], { sg: 'g1' }),+ ])+ mocks.scrollCalls.length = 0++ await rerenderAt(1)++ const rows = container.querySelector('[data-exidx="1"]').querySelectorAll('.setrow')+ expect(mocks.scrollCalls).toEqual([+ { node: rows[1], options: { behavior: 'smooth', block: 'center' } },+ ])+ })++ it('centres the last set row when the newly active exercise is complete', async () => {+ await mount([+ exercise('bench', [true, false], { sg: 'g1' }),+ exercise('row', [true, true], { sg: 'g1' }),+ ])+ mocks.scrollCalls.length = 0++ await rerenderAt(1)++ const rows = container.querySelector('[data-exidx="1"]').querySelectorAll('.setrow')+ expect(mocks.scrollCalls).toEqual([+ { node: rows[1], options: { behavior: 'smooth', block: 'center' } },+ ])+ })++ it('centres the exercise wrapper when the newly active exercise has no set row', async () => {+ await mount([+ exercise('bench', [true, false], { sg: 'g1' }),+ exercise('row', [], { sg: 'g1' }),+ ])+ mocks.scrollCalls.length = 0++ await rerenderAt(1)++ const wrapper = container.querySelector('[data-exidx="1"]')+ expect(mocks.scrollCalls).toEqual([+ { node: wrapper, options: { behavior: 'smooth', block: 'center' } },+ ])+ })++ it('does not auto-scroll set rows for ordinary exercise navigation', async () => {+ await mount([+ exercise('bench', [true, false]),+ exercise('row', [false, false]),+ ])+ mocks.scrollCalls.length = 0++ await rerenderAt(1)++ expect(mocks.scrollCalls).toEqual([])+ })+ })