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.

Stats → Strength: tapping an exercise row opens its history instead of throwing — the row called an onExercise handler that never existed (QA C13)

Duarte Santos55b9a29e66e5
diff --git a/frontend/src/views/Stats.jsx b/frontend/src/views/Stats.jsx
index 636e26640..692b854c3 100644
--- a/frontend/src/views/Stats.jsx
+++ b/frontend/src/views/Stats.jsx
@@ -5,7 +5,7 @@ import { EXIDX, matchExercise } from '../lib/exercises.js'
import { lastBW, streakWeeks, setLabel, modeOf, effortOf, metricModeForEntry, metricRowsForEntry, bestWeightForEntry } 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'
@@ -189,8 +189,10 @@ function MuscleBalance({ S }) {
<div className="muted small" style={{ marginTop: 10 }}>{t('Strength shows retained muscle strength. Train again to reset it.')}</div>
{sel && <>
<h4 className="sec" style={{ marginTop: 14 }}>{t('Exercises')} · {t(MUSCLE_NAME[sel])}</h4>
+ {/* A row quotes the exercise's estimated 1RM, so a tap opens the exercise history
+ sheet — the curve behind that number plus the last sessions set by set. */}
{muscleExercises.length ? muscleExercises.map(row => (
- <div key={row.id} className="mrow" style={{ minHeight: 48, alignItems: 'stretch', cursor: 'pointer' }} {...tappable(() => onExercise && onExercise(row.id))}>
+ <div key={row.id} className="mrow" style={{ minHeight: 48, alignItems: 'stretch', cursor: 'pointer' }} {...tappable(() => exerciseHistorySheet(row.id))}>
<span className="nm" style={{ whiteSpace: 'normal', lineHeight: 1.35, display: 'flex', flexDirection: 'column', justifyContent: 'center' }}>
<span style={{ display: 'block', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
{row.name}
diff --git a/frontend/src/views/Stats.recovery.test.jsx b/frontend/src/views/Stats.recovery.test.jsx
index 402981f0f..93c105236 100644
--- a/frontend/src/views/Stats.recovery.test.jsx
+++ b/frontend/src/views/Stats.recovery.test.jsx
@@ -20,6 +20,7 @@ const LEGACY_SNAPSHOT_ID = 'legacy-snapshot-only'
const mocks = vi.hoisted(() => ({
maps: [],
mapMounts: 0,
+ exerciseHistorySheet: vi.fn(),
S: {
unit: 'kg', body: 'male', effort: 'rir', targetW: null,
bodyweight: [], routines: [], workouts: [],
@@ -32,6 +33,7 @@ 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') }))
@@ -139,6 +141,7 @@ function resetFixture(workouts = lifecycleWorkouts()) {
mocks.S.workouts = workouts
mocks.maps.length = 0
mocks.mapMounts = 0
+ mocks.exerciseHistorySheet.mockClear()
useUI.setState({ sheets: [] })
}
@@ -306,6 +309,36 @@ describe('Stats muscle recovery view runtime', () => {
})
})
+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('filters with the shared exercise matcher and still selects from the mounted sheet', async () => {
resetFixture(exercisePickerWorkouts())
diff --git a/frontend/src/views/Stats.test.js b/frontend/src/views/Stats.test.js
index 50f5ec758..179f8920d 100644
--- a/frontend/src/views/Stats.test.js
+++ b/frontend/src/views/Stats.test.js
@@ -19,7 +19,10 @@ describe('Stats mixed-entry metric contract', () => {
it('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', () => {