Muscle names in the picker row, config sheet, Muscles rows and the workout tag go through MUSCLE_NAME — "gluteal", "forearm" and "hip-flexors" leaked as raw ids, and "forearm" stayed English in German (QA C9)

Custom exercises and the batch-1/Olympic metadata (#207) name muscles by the map's ids, for which
only the display names in MUSCLE_NAME have translations. The detail sheet and the Library row
already mapped through it; the picker row subtitle, the routine config sheet tags, the Muscles
explorer rows and the tag under the exercise name in a workout translated the id directly.

Rig check on the branch build (slot 71, en + de): picker row "Glutes · barbell" / "Gesäß · Langhantel",
custom config tags Glutes/barbell/Forearms/Hip flexors, power clean config tags in German
Beinbeuger/Langhantel/Waden/Unterarme/Schultern, Muscles > Glutes "Primary target · Glutes · barbell",
workout tag "Glutes" / "Gesäß".
This commit is contained in:
Duarte Santos committed 2026-09-19 21:17:20 +02:00
1 parent cc116bdbcc
commit 2bf86a5318
5 files changed
+131 -6

No files matched your search

+107
View File
@@ -0,0 +1,107 @@
// @vitest-environment happy-dom
// QA C9. Custom exercises and the newer exercise metadata name muscles by the map's ids. The
// picker row, the routine config sheet and the Muscles rows printed those ids ("gluteal",
// "forearm", "hip-flexors") where the detail sheet already said Glutes / Forearms / Hip flexors —
// and in German "forearm" stayed English, because only the display names have translations.
import React, { act } from 'react'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { createRoot } from 'react-dom/client'
import { EXIDX, registerCustom } from './lib/exercises.js'
import { DEF, useStore } from './store/useStore.js'
import { useUI } from './store/useUI.js'
import { _setLangState } from './lib/i18n-core.js'
import de from './locales/de.js'
import { exercisePicker, exConfigSheet } from './sheets.jsx'
import MuscleExplorer from './components/MuscleExplorer.jsx'
const mounted = []
const S = () => useStore.getState().S
// Renders whatever sheet is on top and returns its host element.
function renderTop() {
const sheet = useUI.getState().sheets.at(-1)
const host = document.createElement('div')
document.body.appendChild(host)
const root = createRoot(host)
mounted.push(root)
act(() => root.render(sheet.render(() => useUI.getState().closeSheet(sheet.id))))
return host
}
function render(node) {
const host = document.createElement('div')
document.body.appendChild(host)
const root = createRoot(host)
mounted.push(root)
act(() => root.render(node))
return host
}
function type(el, value) {
Object.getOwnPropertyDescriptor(el.constructor.prototype, 'value').set.call(el, value)
el.dispatchEvent(new Event('input', { bubbles: true }))
}
const rowFor = (host, name) => [...host.querySelectorAll('.item')].find(e => e.textContent.includes(name))
const custom = (over = {}) => ({
id: 'cqa1', n: 'QA Custom Thrust', bp: 'upper legs', eq: 'barbell', custom: true, desc: '',
tg: 'gluteal', sm: ['forearm', 'hip-flexors'], primaries: ['gluteal'], secondaries: ['forearm', 'hip-flexors'],
muscleGroups: ['gluteal', 'forearm', 'hip-flexors'], ...over,
})
function seed(ex) {
useStore.setState(s => ({ S: { ...s.S, customEx: [ex] } }))
registerCustom([ex])
}
beforeEach(() => {
globalThis.IS_REACT_ACT_ENVIRONMENT = true
useUI.setState({ sheets: [], toastMsg: '' })
useStore.setState({ S: structuredClone(DEF), user: null })
registerCustom([])
_setLangState('en', null, null, null)
document.body.innerHTML = ''
})
afterEach(() => {
act(() => { mounted.splice(0).forEach(root => root.unmount()) })
_setLangState('en', null, null, null)
registerCustom([])
})
describe('muscle names in the rows and tags (QA C9)', () => {
it('picker row shows the display name, not the map id', () => {
seed(custom())
exercisePicker(vi.fn())
const host = renderTop()
act(() => type(host.querySelector('input.input'), 'QA Custom'))
expect(rowFor(host, 'QA Custom Thrust').querySelector('.ss').textContent).toBe('Glutes · barbell')
})
it('config sheet tags read like the detail sheet, for a custom exercise and for power clean', () => {
seed(custom())
exConfigSheet(EXIDX.cqa1, null, vi.fn())
const tags = h => [...h.querySelectorAll('.tag')].map(e => e.textContent.trim())
expect(tags(renderTop())).toEqual(['Glutes', 'barbell', 'Forearms', 'Hip flexors'])
// #207 Olympic lifts list their secondaries as map ids ('forearm', 'deltoids').
exConfigSheet(EXIDX['0648'], null, vi.fn())
expect(tags(renderTop())).toEqual(['hamstrings', 'barbell', 'Calves', 'Forearms', 'Shoulders'])
})
it('translates them in German too — "forearm" was staying English', () => {
_setLangState('de', de, null, null)
seed(custom())
exConfigSheet(EXIDX['0648'], null, vi.fn())
const tags = [...renderTop().querySelectorAll('.tag')].map(e => e.textContent.trim())
expect(tags).toEqual(['Beinbeuger', 'Langhantel', 'Waden', 'Unterarme', 'Schultern'])
exercisePicker(vi.fn())
const host = renderTop()
act(() => type(host.querySelector('input.input'), 'QA Custom'))
expect(rowFor(host, 'QA Custom Thrust').querySelector('.ss').textContent).toBe('Gesäß · Langhantel')
})
it('Muscles explorer row names the target the same way', () => {
seed(custom())
const host = render(<MuscleExplorer onDetail={vi.fn()} onPlan={vi.fn()} />)
const chip = [...host.querySelectorAll('.chip[aria-pressed]')].find(e => e.textContent.startsWith('Glutes'))
act(() => chip.click())
act(() => type(host.querySelector('.search input'), 'QA Custom'))
expect(rowFor(host, 'QA Custom Thrust').querySelector('.ss').textContent).toBe('Primary target · Glutes · barbell')
})
})