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.

Equipment: a profile no longer hides imported custom exercises

Duarte Santos0883ee15af33
diff --git a/frontend/src/lib/equipment.js b/frontend/src/lib/equipment.js
index b2087b298..a926a1e04 100644
--- a/frontend/src/lib/equipment.js
+++ b/frontend/src/lib/equipment.js
@@ -26,6 +26,9 @@ export function exAvailable(S, ex) {
const p = activeProfile(S)
if (!p) return true
if (!ex.eq || ex.eq === ALWAYS_AVAILABLE) return true
+ // Equipment no profile can tick (an imported exercise's "custom") would hide the user's own
+ // exercise under every profile, with no way to bring it back. It stays, like body weight.
+ if (!ALL_EQUIPMENT.includes(ex.eq)) return true
return (p.equipment || []).includes(ex.eq)
}
diff --git a/frontend/src/lib/equipment.test.js b/frontend/src/lib/equipment.test.js
new file mode 100644
index 000000000..679b79d0e
--- /dev/null
+++ b/frontend/src/lib/equipment.test.js
@@ -0,0 +1,27 @@
+import { describe, expect, test } from 'vitest'
+import { exAvailable, ALL_EQUIPMENT } from './equipment.js'
+
+// QA 1.3.11: an imported custom exercise is stored with eq "custom", which no profile can tick, so
+// any active profile hid it from the Library, the picker and the muscle explorer for good.
+describe('exAvailable', () => {
+ const S = { equipFilterOn: true, activeEquipId: 'home', equipProfiles: [{ id: 'home', name: 'Home', equipment: ['dumbbell'] }] }
+
+ test('the active profile decides for catalogue equipment', () => {
+ expect(exAvailable(S, { eq: 'dumbbell' })).toBe(true)
+ expect(exAvailable(S, { eq: 'barbell' })).toBe(false)
+ expect(exAvailable(S, { eq: 'body weight' })).toBe(true)
+ })
+
+ test('equipment no profile can pick never hides an exercise', () => {
+ expect(ALL_EQUIPMENT.includes('custom')).toBe(false)
+ expect(exAvailable(S, { id: 'c1', n: 'trap bar deadlift', eq: 'custom', custom: true })).toBe(true)
+ })
+
+ test('a custom exercise with real equipment is still filtered like any other', () => {
+ expect(exAvailable(S, { id: 'c2', n: 'my row', eq: 'barbell', custom: true })).toBe(false)
+ })
+
+ test('no profile, nothing hidden', () => {
+ expect(exAvailable({ ...S, equipFilterOn: false }, { eq: 'barbell' })).toBe(true)
+ })
+})