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.
JavaScript apple-watchbodyweightdockerfitnessfitness-trackergymhealthiosmcpnodejspasskeysprogressive-web-applicationspwareactself-hostedself-hostingvitewebauthnweightliftingworkout-tracker
Routine editor: the arrows move one exercise of a superset, not all of it
Duarte Santos06d185300728
diff --git a/frontend/src/lib/history.js b/frontend/src/lib/history.jsindex 4bcf90565..a7f1eaf3d 100644--- a/frontend/src/lib/history.js+++ b/frontend/src/lib/history.js@@ -700,6 +700,34 @@ export function moveSupersetUnit(items, index, direction) {reordered[target] = selectedreturn reordered.flat().map(i => items[i])}+// The routine editor's up/down arrows (#377). A member of a superset moves inside it, past the+// next member; at the superset's edge it leaves it — its position kept, its `sg` dropped — so the+// next press moves it on as an exercise of its own. Anything else (a single exercise, a lone+// leftover `sg`) moves as a whole unit, as moveSupersetUnit does: it jumps a superset and never+// joins one (that is the link button's job). Moving a whole superset is left to drag. Returns the+// new list — entries that change are copies, the others keep their identity — or null when the+// press would do nothing. A superset left with one member is dissolved here, like cleanupSg would.+export function moveRoutineEntry(items, index, direction) {+ if (!Array.isArray(items) || (direction !== -1 && direction !== 1)) return null+ if (!Number.isInteger(index) || index < 0 || index >= items.length) return null+ const group = contiguousSgGroup(items, index)+ if (group.length < 2) return moveSupersetUnit(items, index, direction)+ const next = items.slice()+ const other = index + direction+ if (group.includes(other)) {+ next[index] = items[other]+ next[other] = items[index]+ return next+ }+ const { sg, ...left } = items[index]+ next[index] = left+ const rest = group.filter(i => i !== index)+ if (rest.length === 1) {+ const { sg: _gone, ...alone } = items[rest[0]]+ next[rest[0]] = alone+ }+ return next+}export function unitOf(units, idx) { return units.find(u => u.includes(idx)) || [idx] }export function streakWeeks(S) {diff --git a/frontend/src/lib/history.move-entry.test.js b/frontend/src/lib/history.move-entry.test.jsnew file mode 100644index 000000000..d9209a366--- /dev/null+++ b/frontend/src/lib/history.move-entry.test.js@@ -0,0 +1,64 @@+import { describe, expect, it } from 'vitest'+import { moveRoutineEntry, moveSupersetUnit } from './history.js'++// #377: the routine editor's arrows move one exercise. Inside a superset it passes the next+// member; at the edge it leaves the superset where it stands; a single exercise still jumps a+// whole superset and never joins it.+const e = (id, sg, extra = {}) => ({ id, sets: 3, reps: 8, ...(sg ? { sg } : {}), ...extra })+const ids = list => list.map(x => x.id + (x.sg ? ':' + x.sg : ''))++describe('moveRoutineEntry', () => {+ it('swaps with the next member inside a superset, configurations untouched', () => {+ const a = e('a', 'g', { w: 40, note: 'pause' }), b = e('b', 'g'), c = e('c', 'g'), d = e('d')+ const items = [a, b, c, d]+ const down = moveRoutineEntry(items, 0, 1)+ expect(ids(down)).toEqual(['b:g', 'a:g', 'c:g', 'd'])+ expect(down[1]).toBe(a) // the same object: nothing about it changed+ const up = moveRoutineEntry(items, 2, -1)+ expect(ids(up)).toEqual(['a:g', 'c:g', 'b:g', 'd'])+ expect(ids(items)).toEqual(['a:g', 'b:g', 'c:g', 'd']) // never mutated+ })++ it('leaves the superset at its top edge, where it stands', () => {+ const items = [e('x'), e('a', 'g'), e('b', 'g'), e('c', 'g')]+ const out = moveRoutineEntry(items, 1, -1)+ expect(ids(out)).toEqual(['x', 'a', 'b:g', 'c:g'])+ expect(out[1]).toEqual(e('a'))+ expect(items[1].sg).toBe('g')+ })++ it('leaves the superset at its bottom edge, where it stands', () => {+ const items = [e('a', 'g'), e('b', 'g'), e('c', 'g'), e('y')]+ expect(ids(moveRoutineEntry(items, 2, 1))).toEqual(['a:g', 'b:g', 'c', 'y'])+ })++ it('a superset of two dissolves when one leaves', () => {+ const items = [e('a', 'g'), e('b', 'g'), e('c')]+ expect(ids(moveRoutineEntry(items, 1, 1))).toEqual(['a', 'b', 'c'])+ expect(ids(moveRoutineEntry(items, 0, -1))).toEqual(['a', 'b', 'c'])+ })++ it('a member at the very top or bottom of the list can still leave', () => {+ const items = [e('a', 'g'), e('b', 'g'), e('c', 'g')]+ expect(ids(moveRoutineEntry(items, 0, -1))).toEqual(['a', 'b:g', 'c:g'])+ expect(ids(moveRoutineEntry(items, 2, 1))).toEqual(['a:g', 'b:g', 'c'])+ })++ it('a single exercise jumps a whole superset and does not join it', () => {+ const items = [e('x'), e('a', 'g'), e('b', 'g'), e('y')]+ expect(ids(moveRoutineEntry(items, 0, 1))).toEqual(['a:g', 'b:g', 'x', 'y'])+ expect(ids(moveRoutineEntry(items, 3, -1))).toEqual(['x', 'y', 'a:g', 'b:g'])+ expect(moveRoutineEntry(items, 0, 1)).toEqual(moveSupersetUnit(items, 0, 1))+ })++ it('a press that does nothing returns null and changes nothing', () => {+ const items = [e('x', 'lone'), e('a'), e('b')]+ const before = JSON.stringify(items)+ expect(moveRoutineEntry(items, 0, -1)).toBeNull() // a lone leftover sg is no superset+ expect(moveRoutineEntry(items, 2, 1)).toBeNull()+ expect(moveRoutineEntry(items, 5, 1)).toBeNull()+ expect(moveRoutineEntry(items, 1, 2)).toBeNull()+ expect(moveRoutineEntry(null, 0, 1)).toBeNull()+ expect(JSON.stringify(items)).toBe(before)+ })+})diff --git a/frontend/src/locales/ar.js b/frontend/src/locales/ar.jsindex 07697206c..73f3a70f2 100644--- a/frontend/src/locales/ar.js+++ b/frontend/src/locales/ar.js@@ -732,6 +732,7 @@ export default {'Rest-pause always trains as one warm-up set at this rep count, then one rest-pause work set — "Sets" is not used.': 'يتدرب الريست بوز دائمًا كمجموعة إحماء واحدة بهذا العدد من التكرارات، ثم مجموعة عمل ريست بوز واحدة — ولا يُستخدم خيار «المجموعات».','Move up': 'تحريك لأعلى','Move down': 'تحريك لأسفل',+ 'Move out of the superset': 'إخراج من السوبر سِت','Swap exercise': 'استبدال التمرين','Swap exercise?': 'استبدال التمرين؟','Logged sets stay with the original exercise. Choose where the replacement belongs.': 'تبقى المجموعات المسجلة مع التمرين الأصلي. اختر مكان التمرين البديل.',diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.jsindex 663a5a5bb..e85b402c0 100644--- a/frontend/src/locales/de.js+++ b/frontend/src/locales/de.js@@ -47,6 +47,7 @@ export default {'R': 'R','Move up': 'Nach oben','Move down': 'Nach unten',+ 'Move out of the superset': 'Aus dem Supersatz lösen',// --- 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.jsindex 8e1d9aa99..1da2b3700 100644--- a/frontend/src/locales/es.js+++ b/frontend/src/locales/es.js@@ -45,6 +45,7 @@ export default {'R': 'D','Move up': 'Subir','Move down': 'Bajar',+ 'Move out of the superset': 'Sacar de la superserie','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.jsindex ee904194c..acfe7d768 100644--- a/frontend/src/locales/fr.js+++ b/frontend/src/locales/fr.js@@ -45,6 +45,7 @@ export default {'R': 'D','Move up': 'Monter','Move down': 'Descendre',+ 'Move out of the superset': 'Sortir du superset','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.jsindex ccb0ca2aa..cd7c1b398 100644--- a/frontend/src/locales/hi.js+++ b/frontend/src/locales/hi.js@@ -45,6 +45,7 @@ export default {'R': 'दा','Move up': 'ऊपर ले जाएँ','Move down': 'नीचे ले जाएँ',+ 'Move out of the superset': 'सुपरसेट से बाहर ले जाएँ','Sunday': 'रविवार', 'Monday': 'सोमवार', 'Tuesday': 'मंगलवार', 'Wednesday': 'बुधवार','Thursday': 'गुरुवार', 'Friday': 'शुक्रवार', 'Saturday': 'शनिवार','Su': 'र', 'Mo': 'सो', 'Tu': 'मं', 'We': 'बु', 'Th': 'गु', 'Fr': 'शु', 'Sa': 'श',diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.jsindex 61b151edc..37c63d206 100644--- a/frontend/src/locales/hu.js+++ b/frontend/src/locales/hu.js@@ -867,6 +867,7 @@ export default {'Showing all equipment': 'Minden eszköz megjelenítve','Move up': 'Feljebb','Move down': 'Lejjebb',+ 'Move out of the superset': 'Kivétel a szuperszettből','Swap exercise': 'Gyakorlat cseréje','Swap exercise?': 'Cseréled a gyakorlatot?','Logged sets stay with the original exercise. Choose where the replacement belongs.': 'A naplózott sorozatok az eredeti gyakorlatnál maradnak. Válaszd ki, hová kerüljön a csere.',diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.jsindex 48e5dd34d..dd7557659 100644--- a/frontend/src/locales/it.js+++ b/frontend/src/locales/it.js@@ -45,6 +45,7 @@ export default {'R': 'D','Move up': 'Sposta su','Move down': 'Sposta giù',+ 'Move out of the superset': 'Togli dal superset','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.jsindex 02628fa0a..f2363bdcf 100644--- a/frontend/src/locales/ko.js+++ b/frontend/src/locales/ko.js@@ -45,6 +45,7 @@ export default {'R': '우','Move up': '위로 이동','Move down': '아래로 이동',+ 'Move out of the superset': '슈퍼세트에서 빼기','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.jsindex f5910a684..2a63ac082 100644--- a/frontend/src/locales/pl.js+++ b/frontend/src/locales/pl.js@@ -45,6 +45,7 @@ export default {'R': 'P','Move up': 'Przenieś w górę','Move down': 'Przenieś w dół',+ 'Move out of the superset': 'Wyjmij z superserii','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.jsindex 41505d76e..ba3004327 100644--- a/frontend/src/locales/pt-BR.js+++ b/frontend/src/locales/pt-BR.js@@ -1008,6 +1008,7 @@ export const PT_BR_OVERRIDES = {'Teal': 'Turquesa','Yellow': 'Amarelo','Enter how long it took — at least 1 minute.': 'Informe quanto tempo levou — pelo menos 1 minuto.',+ 'Move out of the superset': 'Tirar do superset',}export default { ...pt, ...PT_BR_OVERRIDES }diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.jsindex 65dd8ff54..71181165d 100644--- a/frontend/src/locales/pt.js+++ b/frontend/src/locales/pt.js@@ -45,6 +45,7 @@ export default {'R': 'D','Move up': 'Mover para cima','Move down': 'Mover para baixo',+ 'Move out of the superset': 'Tirar da supersérie','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.jsindex 2df1568f7..e20eeb57f 100644--- a/frontend/src/locales/ru.js+++ b/frontend/src/locales/ru.js@@ -45,6 +45,7 @@ export default {'R': 'П','Move up': 'Переместить вверх','Move down': 'Переместить вниз',+ 'Move out of the superset': 'Вынести из суперсета','Sunday': 'Воскресенье', 'Monday': 'Понедельник', 'Tuesday': 'Вторник', 'Wednesday': 'Среда','Thursday': 'Четверг', 'Friday': 'Пятница', 'Saturday': 'Суббота','Su': 'Вс', 'Mo': 'Пн', 'Tu': 'Вт', 'We': 'Ср', 'Th': 'Чт', 'Fr': 'Пт', 'Sa': 'Сб',diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.jsindex 3604d80fa..fff0b0fdf 100644--- a/frontend/src/locales/th.js+++ b/frontend/src/locales/th.js@@ -875,6 +875,7 @@ export default {'Rest-pause always trains as one warm-up set at this rep count, then one rest-pause work set — "Sets" is not used.': 'เรสต์-พอสจะฝึกเป็นเซ็ตวอร์มอัพหนึ่งเซ็ตที่จำนวนครั้งนี้ ตามด้วยเซ็ตหลักแบบเรสต์-พอสหนึ่งเซ็ตเสมอ — ไม่ใช้ค่า "เซ็ต"','Move up': 'เลื่อนขึ้น','Move down': 'เลื่อนลง',+ 'Move out of the superset': 'ย้ายออกจากซูเปอร์เซ็ต','Swap exercise': 'สลับท่าออกกำลังกาย','Swap exercise?': 'สลับท่าออกกำลังกาย?','Logged sets stay with the original exercise. Choose where the replacement belongs.': 'เซ็ตที่บันทึกแล้วจะอยู่กับท่าเดิม เลือกว่าจะวางท่าใหม่ไว้ตรงไหน',diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.jsindex 1c96ebc30..18e1ac261 100644--- a/frontend/src/locales/tr.js+++ b/frontend/src/locales/tr.js@@ -45,6 +45,7 @@ export default {'R': 'R','Move up': 'Yukarı taşı','Move down': 'Aşağı taşı',+ 'Move out of the superset': 'Süpersetten çıkar','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/uk.js b/frontend/src/locales/uk.jsindex ba239e0c8..bfac12cb0 100644--- a/frontend/src/locales/uk.js+++ b/frontend/src/locales/uk.js@@ -36,6 +36,7 @@ export default {'Next': 'Далі','Move up': 'Перемістити вгору','Move down': 'Перемістити вниз',+ 'Move out of the superset': 'Винести із суперсету','Sunday': 'Неділя', 'Monday': 'Понеділок', 'Tuesday': 'Вівторок', 'Wednesday': 'Середа','Thursday': 'Четвер', 'Friday': "П'ятниця", 'Saturday': 'Субота','Su': 'Нд', 'Mo': 'Пн', 'Tu': 'Вт', 'We': 'Ср', 'Th': 'Чт', 'Fr': 'Пт', 'Sa': 'Сб',diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.jsindex 84237894a..32313ace2 100644--- a/frontend/src/locales/zh.js+++ b/frontend/src/locales/zh.js@@ -45,6 +45,7 @@ export default {'R': '右','Move up': '上移','Move down': '下移',+ 'Move out of the superset': '移出超级组','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.jsxindex 8d82a7715..e28254f73 100644--- a/frontend/src/views/RoutineEdit.jsx+++ b/frontend/src/views/RoutineEdit.jsx@@ -6,7 +6,7 @@ import { exOr } from '../lib/exercises.js'import { activeProfile, exAvailable } from '../lib/equipment.js'import { uid, exerciseNameText } from '../lib/format.js'import { t, exerciseNameFor, exerciseNameClass } from '../lib/i18n.js'-import { supersetUnits, moveSupersetUnit, cleanupSg, exLine, defaultConfig } from '../lib/history.js'+import { supersetUnits, moveRoutineEntry, cleanupSg, exLine, defaultConfig } from '../lib/history.js'import { Thumb } from '../components/Media.jsx'import { glyphPicker, exercisePicker, exConfigSheet, confirmSheet } from '../sheets.jsx'import Icon from '../components/Icon.jsx'@@ -332,11 +332,13 @@ export default function RoutineEdit() {edit(exercises => { reorderRoutineUnit(exercises, sourceIndex, targetSlot) })})if (!r) return null+ // The arrows move one exercise (#377): inside its superset, out of it at the edge, and past a+ // whole neighbouring unit otherwise (lib/history.js moveRoutineEntry). Drag moves supersets whole.const move = (i, dir) => {// Guard before update so a stale/boundary activation cannot trigger persistence or cleanup.- if (!moveSupersetUnit(r.ex, i, dir)) return+ if (!moveRoutineEntry(r.ex, i, dir)) returnedit(ex => {- const reordered = moveSupersetUnit(ex, i, dir)+ const reordered = moveRoutineEntry(ex, i, dir)if (!reordered) returnex.splice(0, ex.length, ...reordered)cleanupSg(ex)@@ -388,7 +390,6 @@ 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)@@ -442,6 +443,9 @@ export default function RoutineEdit() {const ex = exOr(e.id)const noEquip = profile && !exAvailable(S, ex)const linkedPrev = i > 0 && e.sg && r.ex[i - 1].sg === e.sg+ // At a superset's edge an arrow takes the exercise out of it rather than past a neighbour.+ const leavesUp = inSS.has(i) && !linkedPrev+ const leavesDown = inSS.has(i) && r.ex[i + 1]?.sg !== e.sgconst isDragging = reorder.drag && i >= reorder.drag.first && i <= reorder.drag.lastreturn <div key={i} data-routine-row data-ex-index={i}className={'routine-drag-row' + (isDragging ? ' is-dragging' : '')}@@ -463,8 +467,8 @@ export default function RoutineEdit() {<div style={{ display: 'flex', flexDirection: 'column', gap: 2, flex: 'none', alignItems: 'center' }}>{i > 0 && <button className={'iconbtn' + (linkedPrev ? ' on-ss' : '')} title={t('Superset with exercise above')} style={{ width: 32, height: 28, borderRadius: 8, fontSize: 15 }} onClick={ev => { ev.stopPropagation(); toggleLink(i) }}><Icon name="link" /></button>}<div style={{ display: 'flex', gap: 2 }}>- <button className="iconbtn" aria-label={t('Move up')} title={t('Move up')} disabled={unitIndex.get(i) === 0} style={{ width: 28, height: 24, borderRadius: 7, fontSize: 12 }} onClick={ev => { ev.stopPropagation(); move(i, -1) }}><Icon name="chevronUp" /></button>- <button className="iconbtn" aria-label={t('Move down')} title={t('Move down')} disabled={unitIndex.get(i) === units.length - 1} style={{ width: 28, height: 24, borderRadius: 7, fontSize: 12 }} onClick={ev => { ev.stopPropagation(); move(i, 1) }}><Icon name="chevronDown" /></button>+ <button className="iconbtn" aria-label={t('Move up')} title={leavesUp ? t('Move out of the superset') : t('Move up')} disabled={!moveRoutineEntry(r.ex, i, -1)} style={{ width: 28, height: 24, borderRadius: 7, fontSize: 12 }} onClick={ev => { ev.stopPropagation(); move(i, -1) }}><Icon name="chevronUp" /></button>+ <button className="iconbtn" aria-label={t('Move down')} title={leavesDown ? t('Move out of the superset') : t('Move down')} disabled={!moveRoutineEntry(r.ex, i, 1)} style={{ width: 28, height: 24, borderRadius: 7, fontSize: 12 }} onClick={ev => { ev.stopPropagation(); move(i, 1) }}><Icon name="chevronDown" /></button></div></div></SwipeToDelete>diff --git a/frontend/src/views/RoutineEdit.move.test.jsx b/frontend/src/views/RoutineEdit.move.test.jsxindex c716977e9..8a4bae7c6 100644--- a/frontend/src/views/RoutineEdit.move.test.jsx+++ b/frontend/src/views/RoutineEdit.move.test.jsx@@ -90,23 +90,90 @@ afterEach(() => {})describe('routine move controls', () => {- it('moves a selected superset member as one contiguous unit and persists complete occurrences', () => {+ // #377: the arrows on a superset row move that one exercise, not the whole superset.+ it('moves a superset member inside its superset and persists complete occurrences', () => {setRoutine([entry('c1', 10, 'g'),entry('c2', 20, 'g'),- entry('c3', 30)+ entry('c3', 30, 'g'),+ entry('c4', 40)])renderRoutine()- act(() => moveButton('setup-20', 'Move down').click())+ act(() => moveButton('setup-10', 'Move down').click())const moved = useStore.getState().S.routines[0].exexpect(moved).toEqual([+ entry('c2', 20, 'g'),+ entry('c1', 10, 'g'),+ entry('c3', 30, 'g'),+ entry('c4', 40)+ ])+ expect(JSON.parse(localStorage.getItem('gym_state_v1')).routines[0].ex).toEqual(moved)+ })++ it('takes the last member out of its superset, where it stands, and the next press moves it on', () => {+ setRoutine([+ entry('c1', 10, 'g'),+ entry('c2', 20, 'g'),+ entry('c3', 30, 'g'),+ entry('c4', 40)+ ])+ renderRoutine()+ expect(moveButton('setup-30', 'Move down').title).toBe('Move out of the superset')+ expect(moveButton('setup-20', 'Move down').title).toBe('Move down')++ act(() => moveButton('setup-30', 'Move down').click())+ expect(useStore.getState().S.routines[0].ex).toEqual([+ entry('c1', 10, 'g'),+ entry('c2', 20, 'g'),+ entry('c3', 30),+ entry('c4', 40)+ ])++ act(() => moveButton('setup-30', 'Move down').click())+ expect(useStore.getState().S.routines[0].ex).toEqual([+ entry('c1', 10, 'g'),+ entry('c2', 20, 'g'),+ entry('c4', 40),+ entry('c3', 30)+ ])+ })++ it('a superset member on the first row can still leave upward; a superset of two dissolves', () => {+ setRoutine([+ entry('c1', 10, 'g'),+ entry('c2', 20, 'g'),+ entry('c3', 30)+ ])+ renderRoutine()+ const up = moveButton('setup-10', 'Move up')+ expect(up.disabled).toBe(false)+ expect(up.title).toBe('Move out of the superset')++ act(() => up.click())+ expect(useStore.getState().S.routines[0].ex).toEqual([+ entry('c1', 10),+ entry('c2', 20),+ entry('c3', 30)+ ])+ expect(moveButton('setup-10', 'Move up').disabled).toBe(true)+ })++ it('a single exercise jumps a whole superset and does not join it', () => {+ setRoutine([entry('c3', 30),entry('c1', 10, 'g'),entry('c2', 20, 'g')])- expect(JSON.parse(localStorage.getItem('gym_state_v1')).routines[0].ex).toEqual(moved)+ renderRoutine()++ act(() => moveButton('setup-30', 'Move down').click())+ expect(useStore.getState().S.routines[0].ex).toEqual([+ entry('c1', 10, 'g'),+ entry('c2', 20, 'g'),+ entry('c3', 30)+ ])})it('moves the selected duplicate occurrence without aliasing its configuration', () => {@@ -206,9 +273,9 @@ describe('routine move controls', () => {const parsed = parsePlan(JSON.stringify(buildPlanBundle(useStore.getState().S, 'Move test')))expect(parsed.routines[0].ex).toEqual([- entry('c3', 30),+ entry('c2', 20, 'g'),entry('c1', 10, 'g'),- entry('c2', 20, 'g')+ entry('c3', 30)])})})