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
Merge v1.3.8 main into contribution #212
Space-Hermesd70c0ddbe284
diff --cc frontend/src/lib/assisted.test.jsindex 000000000,1a000d537..d674bbee9mode 000000,100644..100644--- a/frontend/src/lib/assisted.test.js+++ b/frontend/src/lib/assisted.test.js@@@ -1,0 -1,106 +1,117 @@@+ // Issue #232: an assistance machine carries part of your body weight, so LESS load is the+ // harder set, the record, and what progression should aim for. The reporter's case: 30 kg of+ // assistance, then 20 kg — the 20 is the new best, and the next session should ask for less.+ import { describe, it, expect } from 'vitest'+ import { isAssisted, betterWeight, beatsWeight, EXIDX } from './exercises.js'+ import { bestWeightFor, bestWeightForEntry } from './history.js'+ import { readSession, nextPrescription } from './progression.js'+ import { bestSetOf, e1rmSeries, is1RMRecord } from './onerm.js'++ const ASSISTED = '0017' // assisted pull-up, leverage machine+ const PLAIN = '0025' // barbell bench press+ const set = (w, r, done = true) => ({ w, r, done })+ const workout = (d, id, sets) => ({ d, start: Date.parse(d + 'T10:00:00Z'), entries: [{ id, target: { mode: 'reps', sets: 1, reps: 8, weight: sets[0].w }, sets }] })++ describe('which exercises count as assisted', () => {+ it('takes the leverage machine whose name says assisted, and nothing else', () => {+ expect(isAssisted(ASSISTED)).toBe(true)+ expect(EXIDX[ASSISTED].eq).toBe('leverage machine')+ expect(isAssisted(PLAIN)).toBe(false)+ // a partner holding your legs, a medicine ball, a band, your own body — ordinary load+ for (const id of ['0011', '1708', '0014', '0970', '0697']) expect(isAssisted(id), id).toBe(false)+ })++ it('lets an exercise or a routine config say so outright', () => {+ expect(isAssisted({ id: PLAIN, assisted: true })).toBe(true)+ expect(isAssisted({ id: ASSISTED, assisted: false })).toBe(false)+ expect(isAssisted({ id: PLAIN, target: { assisted: true } })).toBe(true)+ expect(isAssisted({ n: 'My gym’s assisted dip', eq: 'leverage machine' })).toBe(true)+ })++ it('folds and compares loads the right way round', () => {+ expect(betterWeight(ASSISTED, 30, 20)).toBe(20)+ expect(betterWeight(PLAIN, 30, 20)).toBe(30)+ expect(beatsWeight(ASSISTED, 20, 30)).toBe(true)+ expect(beatsWeight(ASSISTED, 40, 30)).toBe(false)+ expect(beatsWeight(ASSISTED, 30, 0)).toBe(true) // nothing logged yet+ expect(beatsWeight(ASSISTED, 0, 30)).toBe(false) // no load logged is not a record+ })+ })++ describe('the record is the lightest assistance', () => {+ const S = { unit: 'kg', workouts: [workout('2026-09-01', ASSISTED, [set(30, 8)]), workout('2026-09-08', ASSISTED, [set(20, 8)])] }++ it('reports the smallest load as the best, across history and within a session', () => {+ expect(bestWeightFor(S, ASSISTED)).toBe(20)+ expect(bestWeightForEntry({ id: ASSISTED, sets: [set(30, 8), set(20, 8)] })).toBe(20)+ expect(bestWeightForEntry({ id: PLAIN, sets: [set(30, 8), set(20, 8)] })).toBe(30)+ })+++ it('folds repeated occurrences in one workout with the assisted ordering', () => {++ const repeated = { unit: 'kg', workouts: [{ d: '2026-09-08', start: 1, entries: [++ { id: ASSISTED, sets: [set(30, 8)] },++ { id: ASSISTED, sets: [set(20, 8)] },++ ] }] }++ expect(bestWeightFor(repeated, ASSISTED)).toBe(20)++ })+++ it('ignores an unlogged load instead of calling 0 the best', () => {+ expect(bestWeightForEntry({ id: ASSISTED, sets: [set(0, 8), set(25, 8)] })).toBe(25)+ })+ })++ describe('progression asks for less help', () => {+ const cfg = { id: ASSISTED, sets: 1, reps: 8, weight: 30, prog: 'linear', inc: 5 }+ const hist = w => ({ unit: 'kg', workouts: [{ d: '2026-09-08', start: 1, entries: [{ id: ASSISTED, target: { ...cfg, weight: w }, sets: [set(w, 8)] }] }] })++ it('takes assistance away after a clean session', () => {+ const p = nextPrescription(hist(30), cfg)+ expect(p.kind).toBe('up')+ expect(p.weight).toBe(25)+ expect(p.why.join(' ')).toMatch(/less help/)+ })++ it('never goes below no assistance at all', () => {+ const p = nextPrescription(hist(5), { ...cfg, weight: 5 })+ expect(p.weight).toBeGreaterThanOrEqual(0)+ })++ it('reads the lightest completed set as the session load', () => {+ const read = readSession({ id: ASSISTED, target: { mode: 'reps', sets: 2, reps: 8 }, sets: [set(30, 8), set(20, 8)] })+ expect(read.weight).toBe(20)+ })++ it('still adds weight on an ordinary lift', () => {+ const plain = { id: PLAIN, sets: 1, reps: 8, weight: 60, prog: 'linear', inc: 5 }+ const S = { unit: 'kg', workouts: [{ d: '2026-09-08', start: 1, entries: [{ id: PLAIN, target: plain, sets: [set(60, 8)] }] }] }+ expect(nextPrescription(S, plain).weight).toBe(65)+ })+ })++ describe('no one-rep max for an assistance machine', () => {+ it('leaves it out of the estimate, the curve and the record check', () => {+ const entry = { id: ASSISTED, sets: [set(30, 8)] }+ expect(bestSetOf(entry)).toBe(null)- const S = { unit: 'kg', workouts: [workout('2026-09-01', ASSISTED, [set(30, 8)])] }++ const S = { unit: 'kg', workouts: [{ d: '2026-09-01', start: 1, entries: [++ { id: ASSISTED, sets: [set(30, 8)] },++ { id: ASSISTED, sets: [set(20, 8)] },++ ] }] }+ expect(e1rmSeries(S, ASSISTED)).toEqual([])+ expect(is1RMRecord(S, ASSISTED, entry)).toBe(null)+ // the ordinary lift still gets one+ expect(bestSetOf({ id: PLAIN, sets: [set(100, 5)] })).not.toBe(null)+ })+ })++ describe('a sync does not hand the help back', () => {+ it('keeps the smaller assistance and the larger ordinary load', async () => {+ const { mergeStates } = await import('./sync-merge.js')+ const phone = { _ts: 2000, exWeights: { [ASSISTED]: { w: 20, d: '2026-09-08' }, [PLAIN]: { w: 100, d: '2026-09-08' } } }+ const server = { _ts: 1000, exWeights: { [ASSISTED]: { w: 30, d: '2026-09-01' }, [PLAIN]: { w: 90, d: '2026-09-01' } } }+ expect(mergeStates(phone, server).exWeights[ASSISTED].w).toBe(20)+ expect(mergeStates(phone, server).exWeights[PLAIN].w).toBe(100)+ // and the other way round, so it does not depend on which copy is newer+ expect(mergeStates(server, phone).exWeights[ASSISTED].w).toBe(20)+ expect(mergeStates(server, phone).exWeights[PLAIN].w).toBe(100)+ })+ })diff --cc frontend/src/lib/history.jsindex 45fa223a9,2ebbc0683..7768bf3fe--- a/frontend/src/lib/history.js+++ b/frontend/src/lib/history.js@@@ -1,7 -1,7 +1,7 @@@// Pure helpers over the state object S (ported 1:1 from the vanilla app).import { todayISO, isoOf, weekKey, weekStartOf, fmtNum } from './format.js'- import { isCardio, isBodyweightEq } from './exercises.js'+ import { isCardio, isBodyweightEq, isAssisted, betterWeight } from './exercises.js'-import { phaseForSet, modeForSet, modeForEntry, isWarmupRow, normalizeMode, completedVolumeOf, nextDropWeight, splitBurstReps, makeSideSet, isSideSet, syncSideAggregate } from './workout-model.js'+import { phaseForSet, modeForSet, modeForEntry, isWarmupRow, normalizeMode, completedVolumeOf, hasCompletedWork, nextDropWeight, splitBurstReps, makeSideSet, isSideSet, syncSideAggregate } from './workout-model.js'const objectOf = value => value && typeof value === 'object' && !Array.isArray(value) ? value : {}// Completed-state-independent work rows whose authoritative mode matches the requested mode.const workRowsForMode = (entry = {}, mode = 'reps') => {@@@ -740,19 -719,22 +743,27 @@@ export function bestWeightForEntry(entr// completed work row (timed holds can carry an added load too).const completedRows = repsRows.length? repsRows- : workRows.filter(set => set?.done === true && !isWarmupRow(set))+ : workRows.filter(set => hasCompletedWork(set) && !isWarmupRow(set))+ // On an assistance machine the smallest load is the best set, so "best" folds the other way+ // (issue #232). Everything below still returns a plain number — the caller does not branch.+ const assisted = isAssisted(entry.id ? { id: entry.id } : entry)let best = 0let hasUsableWeight = falsecompletedRows.forEach(set => {- const weight = Number(set?.w)- if (!Number.isFinite(weight)) return- // A 0 on an assistance machine is a row with no load entered, not a set done with no help- // at all — folding it in as "the least assistance ever" would invent a record nobody did- // and then ask for negative help next time. Anyone truly needing none has left the machine- // behind and should log the unassisted exercise instead.- if (assisted && !(weight > 0)) return- best = hasUsableWeight ? betterWeight(entry.id, best, weight) : weight- hasUsableWeight = true+ const completedSets = isSideSet(set)+ ? [set.sides.L, set.sides.R].filter(side => side?.done === true)+ : [set]+ completedSets.forEach(completedSet => {+ const weight = Number(completedSet?.w)+ if (!Number.isFinite(weight)) return++ // A 0 on an assistance machine is a row with no load entered, not a set done with no help++ // at all — folding it in as "the least assistance ever" would invent a record nobody did++ // and then ask for negative help next time. Anyone truly needing none has left the machine++ // behind and should log the unassisted exercise instead.++ if (assisted && !(weight > 0)) return++ best = hasUsableWeight ? betterWeight(entry.id, best, weight) : weight+ hasUsableWeight = true- if (weight > best) best = weight+ })})// A real completed row, including an explicit zero for an unloaded bodyweight set, alwaysdiff --cc frontend/src/lib/onerm.jsindex b9cb89a8b,b96246fa1..1837819b1--- a/frontend/src/lib/onerm.js+++ b/frontend/src/lib/onerm.js@@@ -1,5 -1,5 +1,6 @@@-import { isWarmupRow } from './workout-model.js'+ import { isAssisted } from './exercises.js'+import { isSideSet } from './workout-model.js'+import { entriesForExercise, metricRowsForEntry } from './history.js'// Estimated one-rep max (issue #18).//// Deliberately knows nothing about the exercise database: an estimate needs a weight AND a@@@ -44,15 -44,15 +45,19 @@@ export function estimate1RM(w, r, formu// `topW` is ignored on purpose: it records the working weight a user confirmed after the// exercise, with no rep count attached, so it cannot produce an estimate.export function bestSetOf(entry, formula = DEFAULT_FORMULA) {+ // An assistance machine has no one-rep max to estimate: the load is the help you were given,+ // so Epley on it would rise as you got weaker and call that a record (issue #232). These+ // exercises stay out of the estimate, the curve and the strength list entirely.+ if (isAssisted(entry?.id ? { id: entry.id } : entry)) return nulllet best = null- ;(entry?.sets || []).forEach(s => {- if (!s.done || isWarmupRow(s)) return- const est = estimate1RM(s.w, s.r, formula)- if (est !== null && (!best || est > best.est)) best = { est, w: Number(s.w), r: Math.round(Number(s.r)) }+ metricRowsForEntry(entry, 'reps').forEach(s => {+ const sets = isSideSet(s)+ ? [s.sides.L, s.sides.R].filter(side => side?.done === true)+ : [s]+ sets.forEach(set => {+ const est = estimate1RM(set.w, set.r, formula)+ if (est !== null && (!best || est > best.est)) best = { est, w: Number(set.w), r: Math.round(Number(set.r)) }+ })})return best}@@@ -69,9 -60,12 +74,10 @@@ function bestSetOfEntries(entries, form// One point per workout in which the exercise produced an estimate — feeds the trend chart.// Chronological, matching the order workouts are appended in.export function e1rmSeries(S, exId, formula = DEFAULT_FORMULA) {+ if (isAssisted(exId)) return []const pts = [];(S.workouts || []).forEach(w => {- const entry = w.entries.find(e => e.id === exId)- if (!entry) return- const best = bestSetOf(entry, formula)+ const best = bestSetOfEntries(entriesForExercise(w, exId), formula)if (best) pts.push({ t: w.start, d: w.d, y: best.est, w: best.w, r: best.r })})return ptsdiff --cc frontend/src/views/Stats.jsxindex 5ac033184,3af72bb3b..cc82165c9--- a/frontend/src/views/Stats.jsx+++ b/frontend/src/views/Stats.jsx@@@ -1,11 -1,11 +1,11 @@@import { useEffect, useMemo, useState } from 'react'import { useNavigate } from 'react-router-dom'import { useStore } from '../store/useStore.js'- import { EXIDX, matchExercise } from '../lib/exercises.js'+ import { EXIDX, matchExercise, betterWeight } from '../lib/exercises.js'-import { lastBW, streakWeeks, setLabel, modeOf, effortOf, metricModeForEntry, metricRowsForEntry, bestWeightForEntry } from '../lib/history.js'+import { lastBW, streakWeeks, setLabel, modeOf, effortOf, entriesForExercise, metricEntriesForExercise, metricModeForEntry, bestWeightForEntry, completedRepsOf } from '../lib/history.js'import { fmtNum, fmtDate, fmtVol, todayISO, weekStartOf } from '../lib/format.js'import { t, exerciseNameFor, getLang } from '../lib/i18n.js'- import { bwSheet, goalSheet, calendarSheet, workoutDetailSheet, WorkoutRow, bwDeltaColor } from '../sheets.jsx'+ import { bwSheet, goalSheet, calendarSheet, workoutDetailSheet, exerciseHistorySheet, WorkoutRow, bwDeltaColor } from '../sheets.jsx'import LineChart from '../components/LineChart.jsx'import Heatmap from '../components/Heatmap.jsx'import Icon from '../components/Icon.jsx'@@@ -299,13 -301,6 +301,17 @@@ export default function Stats()const workouts = S.workoutsconst monthW = workouts.filter(w => String(w.d || '').slice(0, 7) === todayISO().slice(0, 7)).length+ const metricDataOf = (workout, id) => {+ const entries = metricEntriesForExercise(workout, id)+ const mode = entries.at(-1)?.mode || null+ const sameMode = entries.filter(item => item.mode === mode)- const best = mode === 'reps' ? Math.max(0, ...sameMode.map(item => bestWeightForEntry(item.entry))) : 0++ const best = mode === 'reps' ? sameMode.reduce((value, item) => {++ const candidate = bestWeightForEntry(item.entry)++ if (!(candidate > 0)) return value++ return value > 0 ? betterWeight(id, value, candidate) : candidate++ }, 0) : 0+ return { mode, entries: sameMode, rows: sameMode.flatMap(item => item.rows), best }+ }const entryOf = id => workouts.flatMap(w => w.entries).find(e => e.id === id)const listOf = value => Array.isArray(value) ? value : value == null || value === '' ? [] : [value]const firstAvailable = (...values) => {@@@ -389,16 -383,20 +395,19 @@@let exPts = [], exList = [], exBest = 0if (curEx) {workouts.forEach(w => {- const en = w.entries.find(e => e.id === curEx)- if (en) {- const loggedMode = metricModeForEntry(en)- if (loggedMode !== curMode) return- const doneSets = metricRowsForEntry(en, curMode)+ const data = metricDataOf(w, curEx)+ if (data.mode === curMode) {+ const doneSets = data.rows+ const representative = data.entries.at(-1)?.entryconst mx = curMode === 'reps'- ? (repsOnly ? bestRepsOf(en) : bestWeightForEntry(en))+ ? (repsOnly ? Math.max(0, ...doneSets.map(completedRepsOf)) : data.best): Math.max(0, ...doneSets.map(metric))if (mx > 0) {- exPts.push({ t: w.start, y: mx, d: w.d, sets: doneSets, target: en.target })+ exPts.push({ t: w.start, y: mx, d: w.d, sets: doneSets, target: representative?.target })- if (mx > exBest) exBest = mx+ // Weighted work on an assistance machine reads the other way: the smallest load is the+ // best (issue #232). Reps, duration and speed are always "more is better".+ const better = curMode === 'reps' && !repsOnly ? betterWeight(curEx, exBest || mx, mx) : Math.max(exBest, mx)+ exBest = exBest > 0 ? better : mx}}})diff --cc frontend/src/views/Stats.recovery.test.jsxindex ded42a26e,93c105236..7378b730f--- a/frontend/src/views/Stats.recovery.test.jsx+++ b/frontend/src/views/Stats.recovery.test.jsx@@@ -19,8 -19,8 +19,9 @@@ const LEGACY_SNAPSHOT_ID = 'legacy-snapconst mocks = vi.hoisted(() => ({maps: [],+ charts: [],mapMounts: 0,+ exerciseHistorySheet: vi.fn(),S: {unit: 'kg', body: 'male', effort: 'rir', targetW: null,bodyweight: [], routines: [], workouts: [],@@@ -33,12 -33,10 +34,13 @@@ vi.mock('../store/useStore.js', () => (vi.mock('react-router-dom', () => ({ useNavigate: () => () => {} }))vi.mock('../sheets.jsx', () => ({bwSheet: () => {}, goalSheet: () => {}, calendarSheet: () => {}, workoutDetailSheet: () => {},+ exerciseHistorySheet: mocks.exerciseHistorySheet,WorkoutRow: () => React.createElement('div'), bwDeltaColor: () => 'inherit',}))-vi.mock('../components/LineChart.jsx', () => ({ default: () => React.createElement('div') }))+vi.mock('../components/LineChart.jsx', () => ({ default: props => {+ mocks.charts.push(props)+ return React.createElement('div')+} }))vi.mock('../components/Heatmap.jsx', () => ({ default: () => React.createElement('div') }))vi.mock('../components/Icon.jsx', () => ({ default: props => React.createElement('span', props) }))vi.mock('../components/BodyMap.jsx', () => ({@@@ -142,8 -140,8 +144,9 @@@ function resetFixture(workouts = lifecymocks.S.bodyweight = []mocks.S.workouts = workoutsmocks.maps.length = 0+ mocks.charts.length = 0mocks.mapMounts = 0+ mocks.exerciseHistorySheet.mockClear()useUI.setState({ sheets: [] })}@@@ -311,63 -309,37 +314,107 @@@ describe('Stats muscle recovery view ru})})+ describe('Stats strength exercise rows', () => {+ // The rows under "Exercises · <muscle>" are presented as buttons (role, tabIndex, pointer+ // cursor) but for a year called a handler that never existed, so every tap threw+ // "onExercise is not defined" and opened nothing (QA C13). A tap now opens the exercise's+ // history sheet — the one place that already draws the Est. 1RM curve the row quotes.+ it('opens the exercise history sheet when a row is tapped instead of throwing', async () => {+ resetFixture(exercisePickerWorkouts())+ await mountStats()+ const thrown = []+ dom.addEventListener('error', e => { thrown.push(e.error || e.message); e.preventDefault() })++ await click(viewButton('Strength'))+ await click(muscleCard().querySelector('[data-muscle="chest"]'))+ expect(muscleCard().textContent).toContain('Exercises · Chest')+ const row = [...muscleCard().querySelectorAll('.mrow[role="button"]')].find(el => el.textContent.includes('Est. 1RM'))+ expect(row, 'expected a tappable exercise row for the chest').toBeTruthy()+ expect(row.textContent).toContain('barbell bench press')++ await click(row)+ expect(thrown).toEqual([])+ expect(mocks.exerciseHistorySheet).toHaveBeenCalledTimes(1)+ expect(mocks.exerciseHistorySheet).toHaveBeenCalledWith('0025')++ // The keyboard path of tappable() must land in the same place.+ await act(async () => { row.dispatchEvent(new dom.KeyboardEvent('keydown', { key: 'Enter', bubbles: true })) })+ expect(thrown).toEqual([])+ expect(mocks.exerciseHistorySheet).toHaveBeenCalledTimes(2)+ })+ })+describe('Stats exercise progress picker', () => {+ it('keeps a legacy reps record whose load is stored only in topW', async () => {+ resetFixture([workout('legacy-topw', BASE_NOW, [+ { id: '0025', target: { mode: 'reps' }, topW: 70, sets: [] },+ ])])+ await mountStats()++ const card = [...container.querySelectorAll('.card')].find(el => el.querySelector('h2')?.textContent.trim() === 'Exercise progress')+ expect(card.textContent).toContain('70 kg')+ const progressChart = mocks.charts.find(chart => chart.points?.some(point => point.y === 70))+ expect(progressChart?.points).toHaveLength(1)+ expect(progressChart.points[0].y).toBe(70)+ })++ it('keeps the strongest topW across repeated legacy records', async () => {+ resetFixture([workout('legacy-topw-duplicates', BASE_NOW, [+ { id: '0025', target: { mode: 'reps' }, topW: 70, sets: [] },+ { id: '0025', target: { mode: 'reps' }, topW: 60, sets: [] },+ ])])+ await mountStats()++ const card = [...container.querySelectorAll('.card')].find(el => el.querySelector('h2')?.textContent.trim() === 'Exercise progress')+ expect(card.textContent).toContain('70 kg')+ const progressChart = mocks.charts.find(chart => chart.points?.some(point => point.y === 70))+ expect(progressChart?.points).toHaveLength(1)+ expect(progressChart.points[0].y).toBe(70)+ })++ it('keeps a legacy topW when a modern occurrence shares the workout', async () => {+ resetFixture([workout('modern-and-legacy', BASE_NOW, [+ entry('0025', [set(true, { w: 50, r: 5 })]),+ { id: '0025', target: { mode: 'reps' }, topW: 70, sets: [] },+ ])])+ await mountStats()++ const card = [...container.querySelectorAll('.card')].find(el => el.querySelector('h2')?.textContent.trim() === 'Exercise progress')+ expect(card.textContent).toContain('70 kg')+ const progressChart = mocks.charts.find(chart => chart.points?.some(point => point.y === 70))+ expect(progressChart?.points).toHaveLength(1)+ expect(progressChart.points[0].y).toBe(70)+ })++ it('aggregates duplicate exercise occurrences into one progress point', async () => {+ resetFixture([workout('duplicate', BASE_NOW, [+ entry('0025', [set(true, { w: 60, r: 5 })]),+ entry('0025', [set(true, { w: 80, r: 5 })]),+ ])])+ await mountStats()++ const card = [...container.querySelectorAll('.card')].find(el => el.querySelector('h2')?.textContent.trim() === 'Exercise progress')+ expect(card.textContent).toContain('80 kg')+ const progressChart = mocks.charts.find(chart => chart.points?.some(point => point.y === 80))+ expect(progressChart?.points).toHaveLength(1)+ expect(progressChart.points[0].y).toBe(80)+ expect(card.textContent).toContain('60×5 80×5')+ })+++ it('aggregates repeated assisted occurrences by the lightest load', async () => {++ resetFixture([workout('assisted-duplicate', BASE_NOW, [++ entry('0017', [set(true, { w: 30, r: 8 })]),++ entry('0017', [set(true, { w: 20, r: 8 })]),++ ])])++ await mountStats()++++ const card = [...container.querySelectorAll('.card')].find(el => el.querySelector('h2')?.textContent.trim() === 'Exercise progress')++ expect(card.textContent).toContain('20 kg')++ const progressChart = mocks.charts.find(chart => chart.points?.some(point => point.y === 20))++ expect(progressChart?.points).toHaveLength(1)++ expect(progressChart.points[0].y).toBe(20)++ })++it('filters with the shared exercise matcher and still selects from the mounted sheet', async () => {resetFixture(exercisePickerWorkouts())await mountStats()diff --cc frontend/src/views/Stats.test.jsindex 6f6972642,179f8920d..9539aa327--- a/frontend/src/views/Stats.test.js+++ b/frontend/src/views/Stats.test.js@@@ -19,13 -19,15 +19,16 @@@ describe('Stats mixed-entry metric contit('renders one clickable muscle exercise list rather than a duplicate non-clickable copy', () => {expect((source.match(/muscleExercises\.length \? muscleExercises\.map\(row =>/g) || []).length).toBe(1)- expect(source).toContain('{...tappable(() => onExercise && onExercise(row.id))}')+ // The handler must be one that exists: the previous `onExercise` was never defined and+ // every tap threw (QA C13), so the row opens the exercise history sheet instead.+ expect(source).toContain('{...tappable(() => exerciseHistorySheet(row.id))}')+ expect(source).not.toContain('onExercise')})- it('uses the shared metric mode and row helpers rather than entryMode as a chart gate', () => {+ it('uses the shared metric mode and occurrence helpers rather than entryMode as a chart gate', () => {expect(source).toContain('metricModeForEntry')- expect(source).toContain('metricRowsForEntry')+ expect(source).toContain('metricEntriesForExercise')+ expect(source).toContain('completedRepsOf')expect(source).toContain('bestWeightForEntry')expect(source).not.toContain('const loggedMode = entryMode(en)')expect(source).not.toContain('(en.topW || 0)')