Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

Remove-Exercise: Randfaelle abgedeckt (letzte Uebung, Zweier-Superset, cur unterhalb)

Duarte Santos3b720b0332eb
diff --git a/frontend/src/views/Workout.remove.test.jsx b/frontend/src/views/Workout.remove.test.jsx
index 1243c3934..77516cb4d 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')
+ })
+})