Stats → Strength: tapping an exercise row opens its history instead of throwing — the row called an onExercise handler that never existed (QA C13)
The "Exercises · <muscle>" rows in the Strength view have been styled and announced as
buttons since 64ea41a, but their handler referenced `onExercise`, which is neither a prop
nor anything in scope. Every tap and every Enter on a focused row ended in an uncaught
ReferenceError and nothing opened, on this branch and on v1.3.7 alike.
Each row quotes the exercise's estimated 1RM, so a tap now opens the exercise history sheet
that already exists for exactly this: the top-set / Est. 1RM curve plus the last sessions
set by set. No new strings.
The source-contract test in Stats.test.js had pinned the broken handler literally; it now
pins the working one and rejects a reappearance of `onExercise`. A component test taps a
Strength row with a real click and with Enter, asserts no error reaches the window and that
the history sheet is asked for the tapped exercise.
Verified on the QA rig (slot 78) with the verifier's own repro: seed-loaded @412 and
seed-standard @368 — after tap {"hash":"#/stats","sheets":1}, 0 new errors after
2 clicks + Enter (before: ReferenceError on each).
This commit is contained in:
1 parent
83b2a140d6
commit
55b9a29e66
3 files changed
+41
-3
No files matched your search
@@ -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}
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
Reference in new issue
Block a user