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.

test: fixtures and expectations for the v1.4 catalogue

Duarte Santosa4326a096cec
diff --git a/frontend/src/lib/bar.test.js b/frontend/src/lib/bar.test.js
index b91cd9e12..5f4b2cca0 100644
--- a/frontend/src/lib/bar.test.js
+++ b/frontend/src/lib/bar.test.js
@@ -1,13 +1,17 @@
import { describe, expect, test } from 'vitest'
import { BAR_EQ, DEFAULT_BAR_KG, DEFAULT_BAR_LB, usesBar, defaultBarWeight, barWeightFor, hasBarOverride, plateSplit } from './bar.js'
import { EXDB } from './exercises-data.js'
+import V13_IDS from './catalogue-v13-ids.json' with { type: 'json' }
const idOf = eq => EXDB.find(e => e.eq === eq).id
describe('bar equipment', () => {
- test('covers the five bar types and the 228 catalogue exercises they carry', () => {
+ // 228 is the v1.3 catalogue's count; the v1.4 additions only add to it.
+ test('covers the five bar types and the 228 v1.3 catalogue exercises they carry', () => {
expect([...BAR_EQ].sort()).toEqual(['barbell', 'ez barbell', 'olympic barbell', 'smith machine', 'trap bar'])
- expect(EXDB.filter(e => BAR_EQ.has(e.eq)).length).toBe(228)
+ const legacy = new Set(V13_IDS)
+ expect(EXDB.filter(e => legacy.has(e.id) && BAR_EQ.has(e.eq)).length).toBe(228)
+ for (const eq of BAR_EQ) expect(EXDB.some(e => e.eq === eq), eq).toBe(true)
})
test('usesBar answers for ids and exercise objects alike', () => {
diff --git a/frontend/src/lib/import-match.test.js b/frontend/src/lib/import-match.test.js
index c726ab854..def559355 100644
--- a/frontend/src/lib/import-match.test.js
+++ b/frontend/src/lib/import-match.test.js
@@ -127,8 +127,9 @@ describe('Hevy CSV uses the generated title map', () => {
expect(matchHevyTitle('Bulgarian Split Squat (Dumbbell)')).toBe('0410')
expect(matchHevyTitle('Lat Pulldown - Close Grip (Cable)')).toBe('2616')
expect(matchHevyTitle('Reverse Lunge (Dumbbell)')).toBe('0381')
- // Word-bag alone still misses these — the title map is what makes CSV work.
- expect(matchExercise('Bulgarian Split Squat (Dumbbell)')).toBeNull()
+ // Since v1.4 the word-bag finds the new "dumbbell bulgarian split squat" on its own; the
+ // map still wins, so a Hevy history keeps landing on the id earlier imports used.
+ expect(matchExercise('Bulgarian Split Squat (Dumbbell)')).toBe('2290')
})
it('imports a Hevy CSV onto catalogue ids, not customs', () => {
diff --git a/frontend/src/lib/recovery.test.js b/frontend/src/lib/recovery.test.js
index e3f19026a..a684a0972 100644
--- a/frontend/src/lib/recovery.test.js
+++ b/frontend/src/lib/recovery.test.js
@@ -26,13 +26,16 @@ const DAY = 24 * HOUR
const NOW = Date.UTC(2026, 0, 1, 12)
// Keep fixtures tied to the shipped catalogue while making the expected stimulus explicit.
+// Drawable only: a cardio drill's primary is the "cardiovascular system" pseudo-muscle, which
+// carries no fatigue, and since v1.4 such drills also sit outside the cardio body part.
+const drawable = ex => ex.bp !== 'cardio' && Object.keys(musclesOf(ex)).every(slug => MUSCLES.includes(slug))
const SINGLE = EXDB.find(ex => {
const weights = musclesOf(ex)
- return ex.bp !== 'cardio' && Object.keys(weights).length === 1 && Object.values(weights)[0] === 1
+ return drawable(ex) && Object.keys(weights).length === 1 && Object.values(weights)[0] === 1
})
const WEIGHTED = EXDB.find(ex => {
const weights = musclesOf(ex)
- return ex.bp !== 'cardio' && Object.values(weights).includes(0.4)
+ return drawable(ex) && Object.values(weights).includes(0.4)
})
if (!SINGLE || !WEIGHTED) throw new Error('recovery tests require single- and secondary-weight fixtures')
@@ -363,7 +366,7 @@ describe('causal fatigue reference', () => {
})
it('uses the last registered bodyweight for bodyweight exercises', () => {
- const bwEx = EXDB.find(ex => ex.eq === 'body weight' && ex.bp !== 'cardio')
+ const bwEx = EXDB.find(ex => ex.eq === 'body weight' && drawable(ex))
if (!bwEx) throw new Error('test requires a bodyweight exercise fixture')
const slug = Object.keys(musclesOf(bwEx))[0]
const workout = { d: new Date(NOW).toISOString(), start: NOW, entries: [{ id: bwEx.id, sets: [{ done: true, r: 10 }] }] }
@@ -503,10 +506,10 @@ describe('a rest-pause row\'s clusters add no extra fatigue tonnage', () => {
describe('canonical loads and configured bodyweight', () => {
const loaded = EXDB.find(ex => {
const weights = musclesOf(ex)
- return ex.bp !== 'cardio' && ex.eq !== 'body weight'
+ return drawable(ex) && ex.eq !== 'body weight'
&& Object.keys(weights).length === 1 && Object.values(weights)[0] === 1
})
- const bodyweight = EXDB.find(ex => ex.bp !== 'cardio' && ex.eq === 'body weight')
+ const bodyweight = EXDB.find(ex => drawable(ex) && ex.eq === 'body weight')
if (!loaded || !bodyweight) throw new Error('recovery tests require loaded and bodyweight fixtures')
const loadedSlug = Object.keys(musclesOf(loaded))[0]
const bodyweightSlug = Object.keys(musclesOf(bodyweight))[0]
diff --git a/frontend/src/views/Library.test.jsx b/frontend/src/views/Library.test.jsx
index fe7838a04..6e40f6b19 100644
--- a/frontend/src/views/Library.test.jsx
+++ b/frontend/src/views/Library.test.jsx
@@ -96,6 +96,8 @@ describe('Library exercise-name casing per language', () => {
it(`${lang}: every translated row is ${CASED_NAME_LANGS.includes(lang) ? 'left in its own casing' : 'title-cased'}`, () => {
const pack = packs[`../exercise-names/${lang}.js`]
_setLangState(lang, {}, null, pack)
+ // Starred so they render on the first page: a partial pack may not cover the first rows.
+ mocks.S.favEx = Object.keys(pack).slice(0, 3)
const rows = [...render().querySelectorAll('.item .tt')].slice(1) // drop "Create your own"
expect(rows.length).toBeGreaterThan(0)
const translated = rows.filter(el => Object.values(pack).some(n => el.textContent.startsWith(n)))