Merge fix/stats-strength: QA round 2026-09-19 (dev team)
This commit is contained in:
commit
6358bef1ae
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