From 933891ee998e3a978841d413fa78e56bbb6449b5 Mon Sep 17 00:00:00 2001 From: Space_Hermes Date: Thu, 27 Aug 2026 19:40:49 +0200 Subject: [PATCH 1/2] Fix routine move controls for grouped exercises --- frontend/src/index.css | 1 + frontend/src/lib/history.js | 16 ++ frontend/src/lib/pt-br-locale.test.js | 2 +- frontend/src/locales/de.js | 2 + frontend/src/locales/es.js | 2 + frontend/src/locales/fr.js | 2 + frontend/src/locales/hi.js | 2 + frontend/src/locales/it.js | 2 + frontend/src/locales/ko.js | 2 + frontend/src/locales/pl.js | 2 + frontend/src/locales/pt-BR.js | 2 + frontend/src/locales/pt.js | 2 + frontend/src/locales/ru.js | 2 + frontend/src/locales/tr.js | 2 + frontend/src/locales/zh.js | 2 + frontend/src/views/RoutineEdit.jsx | 18 +- frontend/src/views/RoutineEdit.move.test.jsx | 167 +++++++++++++++++++ 17 files changed, 223 insertions(+), 5 deletions(-) create mode 100644 frontend/src/views/RoutineEdit.move.test.jsx diff --git a/frontend/src/index.css b/frontend/src/index.css index a348459..8a26a5c 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -184,6 +184,7 @@ body.resting #app{padding-bottom:calc(250px + var(--sab))} } .iconbtn:active{background:var(--surface-2);transform:scale(.92)} .iconbtn.on-ss{background:var(--acc-soft);color:var(--acc)} +.iconbtn:disabled{opacity:.32;pointer-events:none} h4.sec{ font-size:13px;font-weight:400;letter-spacing:-.004em;color:var(--label-2); diff --git a/frontend/src/lib/history.js b/frontend/src/lib/history.js index edac277..bb03370 100644 --- a/frontend/src/lib/history.js +++ b/frontend/src/lib/history.js @@ -421,6 +421,22 @@ export function supersetUnits(items) { }) return units } + +// Move the selected occurrence's complete display unit by one neighbouring unit. Returning a +// new array keeps this helper pure; the caller decides how to persist it. Index identity matters +// here because the same exercise id may appear more than once with different setup. +export function moveSupersetUnit(items, index, direction) { + if (!Array.isArray(items) || (direction !== -1 && direction !== 1)) return null + const units = supersetUnits(items) + const source = units.findIndex(unit => unit.includes(index)) + const target = source + direction + if (source < 0 || target < 0 || target >= units.length) return null + const reordered = [...units] + const selected = reordered[source] + reordered[source] = reordered[target] + reordered[target] = selected + return reordered.flat().map(i => items[i]) +} export function unitOf(units, idx) { return units.find(u => u.includes(idx)) || [idx] } export function streakWeeks(S) { diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.js index 91a4a63..7e4beb1 100644 --- a/frontend/src/lib/pt-br-locale.test.js +++ b/frontend/src/lib/pt-br-locale.test.js @@ -27,7 +27,7 @@ describe('Brazilian Portuguese locale', () => { .sort(byCodeUnit) const fingerprint = createHash('sha256').update(JSON.stringify(inherited)).digest('hex') - expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(291) + expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(293) expect(inherited).toHaveLength(449) // If this fails, review the changed keys and wording before accepting a new hash. From // frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.js index 8c91155..7a68ad0 100644 --- a/frontend/src/locales/de.js +++ b/frontend/src/locales/de.js @@ -36,6 +36,8 @@ export default { 'rescheduled': 'verschoben', 'Prev': 'Zurück', 'Next': 'Weiter', + 'Move up': 'Nach oben', + 'Move down': 'Nach unten', // --- days & months --- 'Sunday': 'Sonntag', 'Monday': 'Montag', 'Tuesday': 'Dienstag', 'Wednesday': 'Mittwoch', 'Thursday': 'Donnerstag', 'Friday': 'Freitag', 'Saturday': 'Samstag', diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.js index b1ea117..b784179 100644 --- a/frontend/src/locales/es.js +++ b/frontend/src/locales/es.js @@ -35,6 +35,8 @@ export default { 'rescheduled': 'reprogramado', 'Prev': 'Anterior', 'Next': 'Siguiente', + 'Move up': 'Subir', + 'Move down': 'Bajar', 'Sunday': 'Domingo', 'Monday': 'Lunes', 'Tuesday': 'Martes', 'Wednesday': 'Miércoles', 'Thursday': 'Jueves', 'Friday': 'Viernes', 'Saturday': 'Sábado', 'Su': 'Do', 'Mo': 'Lu', 'Tu': 'Ma', 'We': 'Mi', 'Th': 'Ju', 'Fr': 'Vi', 'Sa': 'Sá', diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.js index 387bf25..b48e3e2 100644 --- a/frontend/src/locales/fr.js +++ b/frontend/src/locales/fr.js @@ -35,6 +35,8 @@ export default { 'rescheduled': 'reprogrammé', 'Prev': 'Préc.', 'Next': 'Suiv.', + 'Move up': 'Monter', + 'Move down': 'Descendre', 'Sunday': 'Dimanche', 'Monday': 'Lundi', 'Tuesday': 'Mardi', 'Wednesday': 'Mercredi', 'Thursday': 'Jeudi', 'Friday': 'Vendredi', 'Saturday': 'Samedi', 'Su': 'Di', 'Mo': 'Lu', 'Tu': 'Ma', 'We': 'Me', 'Th': 'Je', 'Fr': 'Ve', 'Sa': 'Sa', diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.js index 09038df..11ca1a4 100644 --- a/frontend/src/locales/hi.js +++ b/frontend/src/locales/hi.js @@ -35,6 +35,8 @@ export default { 'rescheduled': 'बदला गया', 'Prev': 'पिछला', 'Next': 'अगला', + 'Move up': 'ऊपर ले जाएँ', + 'Move down': 'नीचे ले जाएँ', 'Sunday': 'रविवार', 'Monday': 'सोमवार', 'Tuesday': 'मंगलवार', 'Wednesday': 'बुधवार', 'Thursday': 'गुरुवार', 'Friday': 'शुक्रवार', 'Saturday': 'शनिवार', 'Su': 'र', 'Mo': 'सो', 'Tu': 'मं', 'We': 'बु', 'Th': 'गु', 'Fr': 'शु', 'Sa': 'श', diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.js index 1c53c34..d50843e 100644 --- a/frontend/src/locales/it.js +++ b/frontend/src/locales/it.js @@ -35,6 +35,8 @@ export default { 'rescheduled': 'riprogrammato', 'Prev': 'Prec.', 'Next': 'Succ.', + 'Move up': 'Sposta su', + 'Move down': 'Sposta giù', 'Sunday': 'Domenica', 'Monday': 'Lunedì', 'Tuesday': 'Martedì', 'Wednesday': 'Mercoledì', 'Thursday': 'Giovedì', 'Friday': 'Venerdì', 'Saturday': 'Sabato', 'Su': 'Do', 'Mo': 'Lu', 'Tu': 'Ma', 'We': 'Me', 'Th': 'Gi', 'Fr': 'Ve', 'Sa': 'Sa', diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.js index 170f6d3..addeb66 100644 --- a/frontend/src/locales/ko.js +++ b/frontend/src/locales/ko.js @@ -35,6 +35,8 @@ export default { 'rescheduled': '변경됨', 'Prev': '이전', 'Next': '다음', + 'Move up': '위로 이동', + 'Move down': '아래로 이동', 'Sunday': '일요일', 'Monday': '월요일', 'Tuesday': '화요일', 'Wednesday': '수요일', 'Thursday': '목요일', 'Friday': '금요일', 'Saturday': '토요일', 'Su': '일', 'Mo': '월', 'Tu': '화', 'We': '수', 'Th': '목', 'Fr': '금', 'Sa': '토', diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.js index b914fbc..dc4bc14 100644 --- a/frontend/src/locales/pl.js +++ b/frontend/src/locales/pl.js @@ -35,6 +35,8 @@ export default { 'rescheduled': 'przełożono', 'Prev': 'Wstecz', 'Next': 'Dalej', + 'Move up': 'Przenieś w górę', + 'Move down': 'Przenieś w dół', 'Sunday': 'Niedziela', 'Monday': 'Poniedziałek', 'Tuesday': 'Wtorek', 'Wednesday': 'Środa', 'Thursday': 'Czwartek', 'Friday': 'Piątek', 'Saturday': 'Sobota', 'Su': 'Nd', 'Mo': 'Pn', 'Tu': 'Wt', 'We': 'Śr', 'Th': 'Cz', 'Fr': 'Pt', 'Sa': 'So', diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.js index 11022ba..c76f829 100644 --- a/frontend/src/locales/pt-BR.js +++ b/frontend/src/locales/pt-BR.js @@ -180,6 +180,8 @@ export const PT_BR_OVERRIDES = { // Regional wording inherited from pt-PT would otherwise leak into pt-BR. 'Next': 'Próximo', + 'Move up': 'Mover para cima', + 'Move down': 'Mover para baixo', '{0} to gain': '{0} para ganhar', '{0} to lose': '{0} para perder', '{0} set still unchecked. Finish the workout now?': 'Falta {0} série sem marcar. Finalizar o treino agora?', diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.js index d14ccb1..00000da 100644 --- a/frontend/src/locales/pt.js +++ b/frontend/src/locales/pt.js @@ -35,6 +35,8 @@ export default { 'rescheduled': 'reagendado', 'Prev': 'Anterior', 'Next': 'Seguinte', + 'Move up': 'Mover para cima', + 'Move down': 'Mover para baixo', 'Sunday': 'Domingo', 'Monday': 'Segunda-feira', 'Tuesday': 'Terça-feira', 'Wednesday': 'Quarta-feira', 'Thursday': 'Quinta-feira', 'Friday': 'Sexta-feira', 'Saturday': 'Sábado', 'Su': 'Do', 'Mo': 'Se', 'Tu': 'Te', 'We': 'Qa', 'Th': 'Qi', 'Fr': 'Sx', 'Sa': 'Sá', diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.js index 1e260d1..02674a9 100644 --- a/frontend/src/locales/ru.js +++ b/frontend/src/locales/ru.js @@ -35,6 +35,8 @@ export default { 'rescheduled': 'перенесено', 'Prev': 'Назад', 'Next': 'Далее', + 'Move up': 'Переместить вверх', + 'Move down': 'Переместить вниз', 'Sunday': 'Воскресенье', 'Monday': 'Понедельник', 'Tuesday': 'Вторник', 'Wednesday': 'Среда', 'Thursday': 'Четверг', 'Friday': 'Пятница', 'Saturday': 'Суббота', 'Su': 'Вс', 'Mo': 'Пн', 'Tu': 'Вт', 'We': 'Ср', 'Th': 'Чт', 'Fr': 'Пт', 'Sa': 'Сб', diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.js index 79b3125..3c990e5 100644 --- a/frontend/src/locales/tr.js +++ b/frontend/src/locales/tr.js @@ -35,6 +35,8 @@ export default { 'rescheduled': 'ertelendi', 'Prev': 'Önceki', 'Next': 'Sonraki', + 'Move up': 'Yukarı taşı', + 'Move down': 'Aşağı taşı', 'Sunday': 'Pazar', 'Monday': 'Pazartesi', 'Tuesday': 'Salı', 'Wednesday': 'Çarşamba', 'Thursday': 'Perşembe', 'Friday': 'Cuma', 'Saturday': 'Cumartesi', 'Su': 'Pz', 'Mo': 'Pt', 'Tu': 'Sa', 'We': 'Ça', 'Th': 'Pe', 'Fr': 'Cu', 'Sa': 'Ct', diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.js index 533434d..5cbc9b0 100644 --- a/frontend/src/locales/zh.js +++ b/frontend/src/locales/zh.js @@ -35,6 +35,8 @@ export default { 'rescheduled': '已改期', 'Prev': '上一个', 'Next': '下一个', + 'Move up': '上移', + 'Move down': '下移', 'Sunday': '星期日', 'Monday': '星期一', 'Tuesday': '星期二', 'Wednesday': '星期三', 'Thursday': '星期四', 'Friday': '星期五', 'Saturday': '星期六', 'Su': '日', 'Mo': '一', 'Tu': '二', 'We': '三', 'Th': '四', 'Fr': '五', 'Sa': '六', diff --git a/frontend/src/views/RoutineEdit.jsx b/frontend/src/views/RoutineEdit.jsx index a8c492c..50b2c04 100644 --- a/frontend/src/views/RoutineEdit.jsx +++ b/frontend/src/views/RoutineEdit.jsx @@ -5,7 +5,7 @@ import { exOr } from '../lib/exercises.js' import { activeProfile, exAvailable } from '../lib/equipment.js' import { uid } from '../lib/format.js' import { t, exerciseNameFor } from '../lib/i18n.js' -import { supersetUnits, cleanupSg, exLine } from '../lib/history.js' +import { supersetUnits, moveSupersetUnit, cleanupSg, exLine } from '../lib/history.js' import { Thumb } from '../components/Media.jsx' import { glyphPicker, exercisePicker, exConfigSheet, confirmSheet } from '../sheets.jsx' import Icon from '../components/Icon.jsx' @@ -29,7 +29,16 @@ export default function RoutineEdit() { if (!r) return null const edit = fn => update(s => { fn(s.routines.find(x => x.id === id).ex) }) - const move = (i, dir) => edit(ex => { const j = i + dir; if (j < 0 || j >= ex.length) return;[ex[i], ex[j]] = [ex[j], ex[i]]; cleanupSg(ex) }) + const move = (i, dir) => { + // Guard before update so a stale/boundary activation cannot trigger persistence or cleanup. + if (!moveSupersetUnit(r.ex, i, dir)) return + edit(ex => { + const reordered = moveSupersetUnit(ex, i, dir) + if (!reordered) return + ex.splice(0, ex.length, ...reordered) + cleanupSg(ex) + }) + } const toggleLink = i => edit(ex => { if (i < 1) return const cur = ex[i], prev = ex[i - 1] @@ -39,6 +48,7 @@ export default function RoutineEdit() { }) const units = supersetUnits(r.ex) + const unitIndex = new Map(units.flatMap((unit, index) => unit.map(i => [i, index]))) const unitFirst = new Set(units.filter(u => u.length > 1).map(u => u[0])) const inSS = new Set(units.filter(u => u.length > 1).flat()) const profile = activeProfile(S) @@ -88,8 +98,8 @@ export default function RoutineEdit() {
{i > 0 && }
- - + +
diff --git a/frontend/src/views/RoutineEdit.move.test.jsx b/frontend/src/views/RoutineEdit.move.test.jsx new file mode 100644 index 0000000..7aa3330 --- /dev/null +++ b/frontend/src/views/RoutineEdit.move.test.jsx @@ -0,0 +1,167 @@ +// @vitest-environment happy-dom +import React, { act } from 'react' +import { createRoot } from 'react-dom/client' +import { MemoryRouter, Route, Routes } from 'react-router-dom' +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import RoutineEdit from './RoutineEdit.jsx' +import { DEF, useStore } from '../store/useStore.js' +import { _setLangState } from '../lib/i18n-core.js' +import de from '../locales/de.js' +import { buildPlanBundle, parsePlan } from '../lib/plan-share.js' + +const mocks = vi.hoisted(() => ({ exConfigSheet: vi.fn() })) +vi.mock('../lib/api.js', () => ({ api: vi.fn(() => Promise.resolve({})) })) +vi.mock('../sheets.jsx', () => ({ + glyphPicker: vi.fn(), exercisePicker: vi.fn(), exConfigSheet: mocks.exConfigSheet, confirmSheet: vi.fn() +})) +vi.mock('../components/Media.jsx', () => ({ Thumb: () => null })) +vi.mock('../components/BodyMap.jsx', () => ({ default: () => null })) + +globalThis.IS_REACT_ACT_ENVIRONMENT = true +const clone = value => JSON.parse(JSON.stringify(value)) +const custom = id => ({ id, n: id, bp: 'chest', eq: 'body weight', tg: 'chest', custom: true }) +const entry = (id, setup, sg) => ({ + id, sets: 3, reps: 5, weight: setup, note: `setup-${setup}`, + ...(sg ? { sg } : {}) +}) + +let root +let container + +function setRoutine(ex) { + const S = clone(DEF) + S.routines = [{ id: 'r1', name: 'Move test', emoji: 'dumbbell', ex }] + S.customEx = ['c1', 'c2', 'c3', 'c4'].map(custom) + useStore.setState({ S, user: null }) +} + +function renderRoutine() { + container = document.createElement('div') + document.body.appendChild(container) + root = createRoot(container) + act(() => root.render( + + } /> + + )) +} + +function itemFor(name) { + return [...container.querySelectorAll('.item')].find(item => item.textContent.includes(name)) +} + +function moveButton(name, direction) { + return itemFor(name).querySelector(`button[aria-label="${direction}"]`) +} + +beforeEach(() => { + localStorage.clear() + mocks.exConfigSheet.mockClear() + _setLangState('en', null, null, null) + root = null + container = null +}) + +afterEach(() => { + if (root) act(() => root.unmount()) + if (container) container.remove() + _setLangState('en', null, null, null) +}) + +describe('routine move controls', () => { + it('moves a selected superset member as one contiguous unit and persists complete occurrences', () => { + setRoutine([ + entry('c1', 10, 'g'), + entry('c2', 20, 'g'), + entry('c3', 30) + ]) + renderRoutine() + + act(() => moveButton('setup-20', 'Move down').click()) + + const moved = useStore.getState().S.routines[0].ex + expect(moved).toEqual([ + entry('c3', 30), + entry('c1', 10, 'g'), + entry('c2', 20, 'g') + ]) + expect(JSON.parse(localStorage.getItem('gym_state_v1')).routines[0].ex).toEqual(moved) + }) + + it('moves the selected duplicate occurrence without aliasing its configuration', () => { + setRoutine([ + entry('c1', 10), + entry('c2', 20), + entry('c1', 30) + ]) + renderRoutine() + + act(() => moveButton('setup-30', 'Move up').click()) + + expect(useStore.getState().S.routines[0].ex).toEqual([ + entry('c1', 10), + entry('c1', 30), + entry('c2', 20) + ]) + }) + + it('disables unit-boundary directions without cleaning or persisting state', () => { + setRoutine([ + entry('c1', 10, 'orphan'), + entry('c2', 20) + ]) + renderRoutine() + const before = useStore.getState().S + + expect(moveButton('c1', 'Move up').disabled).toBe(true) + expect(moveButton('c2', 'Move down').disabled).toBe(true) + act(() => moveButton('c1', 'Move up').click()) + + expect(useStore.getState().S).toBe(before) + expect(useStore.getState().S.routines[0].ex[0].sg).toBe('orphan') + expect(localStorage.getItem('gym_state_v1')).toBeNull() + }) + + it('uses localized accessible names and titles, retains button focus, and does not open config', () => { + _setLangState('de', de, null, null) + setRoutine([entry('c1', 10), entry('c2', 20)]) + renderRoutine() + const button = moveButton('c2', 'Nach oben') + + expect(button.title).toBe('Nach oben') + button.focus() + act(() => button.click()) + + expect(document.activeElement?.tagName).toBe('BUTTON') + expect(mocks.exConfigSheet).not.toHaveBeenCalled() + }) + + it('retains reordered occurrence order and grouping through plan export and import', () => { + setRoutine([ + entry('c1', 10, 'g'), + entry('c2', 20, 'g'), + entry('c3', 30) + ]) + renderRoutine() + act(() => moveButton('setup-10', 'Move down').click()) + + const parsed = parsePlan(JSON.stringify(buildPlanBundle(useStore.getState().S, 'Move test'))) + expect(parsed.routines[0].ex).toEqual([ + entry('c3', 30), + entry('c1', 10, 'g'), + entry('c2', 20, 'g') + ]) + }) +}) + +describe('routine move-control locale coverage', () => { + const packs = import.meta.glob('../locales/*.js', { eager: true, import: 'default' }) + + it('defines both accessible names in all twelve locale packs', () => { + expect(Object.keys(packs)).toHaveLength(12) + Object.entries(packs).forEach(([path, pack]) => { + expect(pack, `${path} is missing Move up`).toHaveProperty('Move up') + expect(pack, `${path} is missing Move down`).toHaveProperty('Move down') + }) + }) +}) From 84274b48d20df4a95fee05a7eb02658625926b96 Mon Sep 17 00:00:00 2001 From: Space_Hermes Date: Thu, 27 Aug 2026 20:06:19 +0200 Subject: [PATCH 2/2] Fix disabled routine move control hit targets --- frontend/src/index.css | 2 +- frontend/src/views/RoutineEdit.move.test.jsx | 58 ++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/frontend/src/index.css b/frontend/src/index.css index 8a26a5c..c58debd 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -184,7 +184,7 @@ body.resting #app{padding-bottom:calc(250px + var(--sab))} } .iconbtn:active{background:var(--surface-2);transform:scale(.92)} .iconbtn.on-ss{background:var(--acc-soft);color:var(--acc)} -.iconbtn:disabled{opacity:.32;pointer-events:none} +.iconbtn:disabled{opacity:.32} h4.sec{ font-size:13px;font-weight:400;letter-spacing:-.004em;color:var(--label-2); diff --git a/frontend/src/views/RoutineEdit.move.test.jsx b/frontend/src/views/RoutineEdit.move.test.jsx index 7aa3330..d83c73e 100644 --- a/frontend/src/views/RoutineEdit.move.test.jsx +++ b/frontend/src/views/RoutineEdit.move.test.jsx @@ -1,4 +1,6 @@ // @vitest-environment happy-dom +import { readFileSync } from 'node:fs' +import { resolve } from 'node:path' import React, { act } from 'react' import { createRoot } from 'react-dom/client' import { MemoryRouter, Route, Routes } from 'react-router-dom' @@ -9,6 +11,8 @@ import { _setLangState } from '../lib/i18n-core.js' import de from '../locales/de.js' import { buildPlanBundle, parsePlan } from '../lib/plan-share.js' +const cssSource = readFileSync(resolve(process.cwd(), 'src/index.css'), 'utf8') + const mocks = vi.hoisted(() => ({ exConfigSheet: vi.fn() })) vi.mock('../lib/api.js', () => ({ api: vi.fn(() => Promise.resolve({})) })) vi.mock('../sheets.jsx', () => ({ @@ -54,6 +58,22 @@ function moveButton(name, direction) { return itemFor(name).querySelector(`button[aria-label="${direction}"]`) } +function pointerActivateArea(button) { + // Model browser hit-testing: pointer-events:none removes the disabled button + // from the target chain, exposing the clickable routine row underneath. + const disabledRule = cssSource.match(/\.iconbtn:disabled\s*\{[^}]*\}/)?.[0] || '' + const target = /pointer-events\s*:\s*none/.test(disabledRule) + ? button.closest('.item') + : button + act(() => { + target.dispatchEvent(new PointerEvent('pointerdown', { bubbles: true })) + target.dispatchEvent(new PointerEvent('pointerup', { bubbles: true })) + if (!(target instanceof HTMLButtonElement && target.disabled)) { + target.dispatchEvent(new MouseEvent('click', { bubbles: true })) + } + }) +} + beforeEach(() => { localStorage.clear() mocks.exConfigSheet.mockClear() @@ -105,6 +125,23 @@ describe('routine move controls', () => { ]) }) + it('moves a standalone occurrence down with every configuration field intact', () => { + const selected = { + ...entry('c1', 10), + mode: 'reps', prog: 'double', repsMin: 4, repsMax: 12, + side: true, warmupSets: 2, + intensifier: { type: 'restpause', pauseSec: 20 } + } + setRoutine([selected, entry('c2', 20), entry('c3', 30)]) + renderRoutine() + + act(() => moveButton('setup-10', 'Move down').click()) + + expect(useStore.getState().S.routines[0].ex).toEqual([ + entry('c2', 20), selected, entry('c3', 30) + ]) + }) + it('disables unit-boundary directions without cleaning or persisting state', () => { setRoutine([ entry('c1', 10, 'orphan'), @@ -122,6 +159,27 @@ describe('routine move controls', () => { expect(localStorage.getItem('gym_state_v1')).toBeNull() }) + it('keeps pointer activation in both disabled boundary areas isolated from the routine row', () => { + setRoutine([ + entry('c1', 10, 'orphan'), + entry('c2', 20) + ]) + renderRoutine() + const before = useStore.getState().S + const firstUp = moveButton('c1', 'Move up') + const lastDown = moveButton('c2', 'Move down') + + expect(firstUp.disabled).toBe(true) + expect(lastDown.disabled).toBe(true) + pointerActivateArea(firstUp) + pointerActivateArea(lastDown) + + expect(mocks.exConfigSheet).not.toHaveBeenCalled() + expect(useStore.getState().S).toBe(before) + expect(useStore.getState().S.routines[0].ex[0].sg).toBe('orphan') + expect(localStorage.getItem('gym_state_v1')).toBeNull() + }) + it('uses localized accessible names and titles, retains button focus, and does not open config', () => { _setLangState('de', de, null, null) setRoutine([entry('c1', 10), entry('c2', 20)])