Workout QA: the per-side set number is a real button again, a unilateral set's volume is each side's weight × reps, timed and cardio sets from older data read as time again, finish summary tiles stay 2×2 in the dialog on desktop, exercise names in menu titles and toasts are capitalised (Kg no longer is)

This commit is contained in:
Duarte Santos committed 2026-09-12 13:37:59 +02:00
1 parent 88a1c317e5
commit 33be28b8e6
6 files changed
+38 -11

No files matched your search

+3
View File
@@ -26,6 +26,9 @@ export function fmtDur(ms) {
export const durPart = ms => (ms >= 60000 ? [fmtDur(ms)] : [])
// Numbers follow the UI language, like the dates above — a hardcoded locale put Swiss
// apostrophes ("7'535 kg") in front of every user, in every language.
// Exercise names are stored lower-case and shown through CSS `capitalize`; text that has no
// element of its own (a toast) capitalises here instead.
export const capWords = s => String(s || '').replace(/(^|[\s(\-\/])(\p{Ll})/gu, (m, pre, ch) => pre + ch.toUpperCase())
export const fmtNum = n => (Math.round(n * 10) / 10).toLocaleString(dateLocale())
// Volume stays in the profile's unit throughout: the old shorthand turned anything over
// 10 000 into "t", which is wrong for a pound profile and made one list mix "18.8t" with
+10 -2
View File
@@ -107,7 +107,10 @@ const effortTail = s => {
// entry or a workout entry); passing an id alone keeps the old body-part behaviour.
export function setLabel(id, s, cfg) {
const c = cfg || { id }
const mode = modeOf(c)
let mode = modeOf(c)
// A set saved by an older build carries no target with it; the set's own fields still say what
// it was — seconds for a timed set, minutes for cardio — so those are not read back as "0 reps".
if (!cfg && !(s.r > 0)) { if (s.min > 0 || s.speed > 0) mode = 'cardio'; else if (s.sec > 0) mode = 'time' }
if (mode === 'cardio') return `${s.min || 0} min @ ${fmtNum(s.speed || 0)} km/h`
if (mode === 'time') return fmtSec(s.sec) + (s.w > 0 ? ` · ${fmtNum(s.w)}` : '')
const bw = isBw({ ...c, id: c.id ?? id })
@@ -483,8 +486,13 @@ export function workoutVolume(w) {
// does it; this line was the one that did not, which only stopped being harmless when a
// routine started planning warm-ups by default. The number is written into the saved
// workout, so an inflated one would stay wrong forever.
// A per-side row's mirror is `w = max(L, R), r = L + R` (workout-model syncSideAggregate) —
// right for a headline, wrong for a product: 14×10 left and 12.5×6 right is 215, not 14×16.
// Each side is its own weight × reps, with its own drops and bursts.
w.entries.forEach(e => e.sets.forEach(s => {
if (s.done && !isWarmupRow(s)) v += (s.w || 0) * (s.r || 0) + extraVolumeOf(s)
if (!s.done || isWarmupRow(s)) return
if (isSideSet(s)) { for (const side of [s.sides.L, s.sides.R]) v += (side.w || 0) * (side.r || 0) + extraVolumeOf(side); return }
v += (s.w || 0) * (s.r || 0) + extraVolumeOf(s)
}))
return v
}
+15
View File
@@ -1161,3 +1161,18 @@ describe('lastEntryFor / buildSets skip a noProg entry', () => {
expect(bestWeightFor(S, LIFT2)).toBe(140)
})
})
describe('per-side volume and legacy timed sets (QA round 2026-09-12)', () => {
it('sums each side of a unilateral set on its own instead of max weight × total reps', () => {
const w = { entries: [{ id: 'x', sets: [
{ done: true, sides: { L: { w: 14, r: 10, done: true }, R: { w: 12.5, r: 6, done: true } }, w: 14, r: 16 },
{ done: true, w: 100, r: 10 }
] }] }
expect(workoutVolume(w)).toBe(14 * 10 + 12.5 * 6 + 1000)
})
it('reads a timed or cardio set saved without a target from the set itself', () => {
expect(setLabel('0001', { sec: 45, done: true })).toBe('0:45')
expect(setLabel('0001', { min: 20, speed: 8, done: true })).toBe('20 min @ 8 km/h')
expect(setLabel('0025', { w: 60, r: 10, done: true })).toBe('60×10')
})
})