Merge merge request !2 (exercise catalogue and muscle metadata)

Keeps the ExRx-informed primary/secondary metadata for 223 catalogue
entries and the muscle-group UI, with two fixes to the branch:

- muscles.js dropped metadataOf, the muscleSnapshot fallback. A custom
  exercise deleted from the catalogue survives in history only as that
  snapshot, so without it those sessions silently stopped counting toward
  the body map and Stats — loadOfWorkouts returned {} where main returned
  {chest: 1}. Restored and widened to the new primaries/secondaries fields.
- It also replaced the shared isWarmupRow import with a local copy that
  only matches the exact string 'warmup'. phaseForSet normalises 'warm-up',
  'warm_up', casing and whitespace, so warm-up rows written in any other
  spelling would have counted as work here while counting as warm-ups
  everywhere else. Restored the import.

Both are covered by new tests. Locale conflicts resolved additively; the
three new muscle-group strings read the same in pt-BR, so they stay
inherited and the inheritance fingerprint is re-baselined.
This commit is contained in:
Duarte Santos committed 2026-08-25 14:22:40 +02:00
commit 5762096a5f
25 files changed
+3286 -40

No files matched your search

+1 -1
View File
@@ -192,7 +192,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}
+30
View File
@@ -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)')
})
})