From 3b720b0332ebbf157168303ccea0b27080c7116a Mon Sep 17 00:00:00 2001 From: Duarte Santos Date: Tue, 18 Aug 2026 12:03:31 +0200 Subject: [PATCH] Remove-Exercise: Randfaelle abgedeckt (letzte Uebung, Zweier-Superset, cur unterhalb) --- frontend/src/views/Workout.remove.test.jsx | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/frontend/src/views/Workout.remove.test.jsx b/frontend/src/views/Workout.remove.test.jsx index 1243c39..77516cb 100644 --- a/frontend/src/views/Workout.remove.test.jsx +++ b/frontend/src/views/Workout.remove.test.jsx @@ -117,3 +117,30 @@ describe('remove-exercise locale coverage', () => { }) }) }) + +describe('remove-exercise edge cases', () => { + it('removing the last remaining exercise leaves an empty, coherent session', () => { + setActive([entry('a')], 0) + act(() => { removeActiveExercise(0) }) + const A = useStore.getState().S.active + expect(A.entries).toHaveLength(0) + expect(A.cur).toBe(0) + }) + + it('removing one half of a two-member superset dissolves the group', () => { + setActive([entry('a', 'g1'), entry('b', 'g1'), entry('c')], 0) + act(() => { removeActiveExercise(1) }) + const A = useStore.getState().S.active + expect(A.entries.map(e => e.id)).toEqual(['a', 'c']) + // A superset of one is not a superset. + expect(A.entries[0].sg).toBeUndefined() + }) + + it('removing an entry below the active one keeps cur on the same exercise', () => { + setActive([entry('a'), entry('b'), entry('c')], 2) + act(() => { removeActiveExercise(0) }) + const A = useStore.getState().S.active + expect(A.entries.map(e => e.id)).toEqual(['b', 'c']) + expect(A.entries[A.cur].id).toBe('c') + }) +})