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)])