fix(stats): remove duplicate muscle exercise list
This commit is contained in:
1 parent
c8f4d5bd18
commit
64ea41a5df
2 files changed
+31
-1
No files matched your search
@@ -191,7 +191,7 @@ function MuscleBalance({ S }) {
|
||||
{sel && <>
|
||||
<h4 className="sec" style={{ marginTop: 14 }}>{t('Exercises')} · {t(MUSCLE_NAME[sel])}</h4>
|
||||
{muscleExercises.length ? muscleExercises.map(row => (
|
||||
<div key={row.id} className="mrow" style={{ minHeight: 48, alignItems: 'stretch' }}>
|
||||
<div key={row.id} className="mrow" style={{ minHeight: 48, alignItems: 'stretch', cursor: 'pointer' }} onClick={() => onExercise && onExercise(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}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { bestWeightForEntry, metricModeForEntry, metricRowsForEntry } from '../lib/history.js'
|
||||
|
||||
const source = readFileSync(new URL('./Stats.jsx', import.meta.url), 'utf8')
|
||||
|
||||
describe('Stats mixed-entry metric contract', () => {
|
||||
it('selects authoritative reps rows before timed rows without stale topW', () => {
|
||||
const entry = { target: { mode: 'time', sec: 60 }, topW: 200, sets: [
|
||||
{ phase: 'work', mode: 'reps', w: 100, r: 5, done: true },
|
||||
{ phase: 'work', mode: 'time', w: 200, sec: 60, done: true }
|
||||
] }
|
||||
expect(metricModeForEntry(entry)).toBe('reps')
|
||||
expect(metricRowsForEntry(entry, metricModeForEntry(entry))).toEqual([entry.sets[0]])
|
||||
expect(bestWeightForEntry(entry)).toBe(100)
|
||||
})
|
||||
|
||||
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('onClick={() => onExercise && onExercise(row.id)}')
|
||||
})
|
||||
|
||||
it('uses the shared metric mode and row helpers rather than entryMode as a chart gate', () => {
|
||||
expect(source).toContain('metricModeForEntry')
|
||||
expect(source).toContain('metricRowsForEntry')
|
||||
expect(source).toContain('bestWeightForEntry')
|
||||
expect(source).not.toContain('const loggedMode = entryMode(en)')
|
||||
expect(source).not.toContain('(en.topW || 0)')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user