fix: use exercise weight step for workout controls
This commit is contained in:
1 parent
75fb168a03
commit
40ae5a6f9d
4 files changed
+58
-4
No files matched your search
@@ -13,7 +13,7 @@ import Media from '../components/Media.jsx'
|
||||
import { startFlow, exercisePicker, exConfigSheet, exerciseDetailSheet, topWeightSheet, finishWorkout, workoutCompleteSheet, confirmSheet, exerciseNoteSheet, sessionNoteSheet, swapActiveWorkoutExercise } from '../sheets.jsx'
|
||||
import Icon from '../components/Icon.jsx'
|
||||
import { Button, Check, NumberField } from '../components/ui.jsx'
|
||||
import { nextPrescription, applyPrescription, defaultIncrement } from '../lib/progression.js'
|
||||
import { nextPrescription, applyPrescription, defaultIncrement, weightIncrement } from '../lib/progression.js'
|
||||
import { progressionGuidance } from '../lib/progression-copy.js'
|
||||
import { glyphOf } from '../lib/glyphs.js'
|
||||
import { isWarmupRow, isDropSet, isRestPauseSet, dropsOf, clustersOf, addDrop, addCluster, removeDropAt, removeClusterAt, setDropAt, setClusterAt, nextDropWeight, nextBurstReps } from '../lib/workout-model.js'
|
||||
@@ -119,7 +119,8 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onField, onAddSet, onRemov
|
||||
const cfg = { ...(entry.target || {}), id: entry.id }
|
||||
const bw = !cardio && isBw(cfg)
|
||||
const added = bw && entry.sets.some(s => s.w > 0)
|
||||
const loadCol = { f: 'w', step: 2.5, dec: true, hd: bw ? t('Added ({0})', S.unit) : t('Weight ({0})', S.unit) }
|
||||
const loadStep = mode === 'reps' ? weightIncrement(cfg, S.unit) : 2.5
|
||||
const loadCol = { f: 'w', step: loadStep, dec: true, hd: bw ? t('Added ({0})', S.unit) : t('Weight ({0})', S.unit) }
|
||||
// The reps column is the total in every mode, unilateral included — the stepper walks in
|
||||
// twos there so the number you land on is one you can actually split evenly.
|
||||
const repCol = { f: 'r', step: repStep(cfg), dec: false, hd: t('Reps') }
|
||||
|
||||
@@ -401,6 +401,44 @@ describe('Workout add exercise flow', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('active workout weight controls', () => {
|
||||
const press = async (label, selector) => {
|
||||
const control = container.querySelector(selector)
|
||||
const button = control?.querySelector(`button[aria-label="${label}"]`)
|
||||
expect(button).toBeTruthy()
|
||||
await act(async () => { button.dispatchEvent(new dom.Event('click', { bubbles: true })) })
|
||||
await rerender()
|
||||
}
|
||||
|
||||
it('uses the configured reps weight step for manual increases and decreases, with the default fallback', async () => {
|
||||
await mount([exercise('plain-bench', [false], {
|
||||
target: { mode: 'reps', reps: 5, weight: 60, bodyweight: false, inc: 1 },
|
||||
})])
|
||||
|
||||
await press('Increase', '.setrow .stp.w')
|
||||
expect(mocks.S.active.entries[0].sets[0].w).toBe(61)
|
||||
await press('Decrease', '.setrow .stp.w')
|
||||
expect(mocks.S.active.entries[0].sets[0].w).toBe(60)
|
||||
|
||||
await unmount()
|
||||
await mount([exercise('plain-bench', [false])])
|
||||
await press('Increase', '.setrow .stp.w')
|
||||
expect(mocks.S.active.entries[0].sets[0].w).toBe(62.5)
|
||||
})
|
||||
|
||||
it('keeps timed seconds and optional timed weight on their existing steps', async () => {
|
||||
await mount([exercise('timed-plank', [false], {
|
||||
target: { mode: 'time', sec: 30, weight: 60, bodyweight: false, inc: 1 },
|
||||
sets: [{ sec: 30, w: 60, done: false }],
|
||||
})])
|
||||
|
||||
await press('Increase', '.setrow .stp.w')
|
||||
expect(mocks.S.active.entries[0].sets[0].sec).toBe(35)
|
||||
await press('Increase', '.setrow .stp.r')
|
||||
expect(mocks.S.active.entries[0].sets[0].w).toBe(62.5)
|
||||
})
|
||||
})
|
||||
|
||||
describe('Workout discard timer lifecycle', () => {
|
||||
it('preserves active timers while discard is awaiting confirmation', async () => {
|
||||
const timer = { left: 30, total: 90, endsAt: Date.now() + 30_000 }
|
||||
|
||||
Reference in new issue
Block a user