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
feat(measurements): support units for custom fields (#699, #718)
“zyk”30588b6486c8
diff --git a/CLAUDE.md b/CLAUDE.mdindex d89cf5140..f10fe35e2 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -93,6 +93,14 @@ machine, never in CI (see "Exercise media" below and docs/APP_STORES.md).`anim-quality.js` / `anim-packs.js` (animation sizes in the store apps).- CONTRIBUTING.md is explicit: **anything that decides what you lift next, or reads a loggedsession back, is a pure helper here with a unit test beside it.**+- **Body measurements (`lib/measurements.js`, `views/Measurements.jsx`)**: one check-in per day.+ Built-in circumferences and legacy custom fields store cm and follow the profile's cm/in+ display. Custom definitions may specify `unit: 'cm' | 'in' | '%' | 'kg' | 'lb'`; that+ display choice stays fixed when the profile switches kg/lb. Custom values store canonical cm, kg+ (to 0.001 kg so a tenth of a pound round-trips), or percent (0 to 100). Each+ custom reading also carries its unit, preserving its meaning in backups without definitions.+ Once values exist, the unit selector permits cm/in or kg/lb conversions within the recorded+ type; a different type needs a new field.- **`views/`**: one file per screen, routed by `react-router-dom` from `App.jsx`.- **`sheets.jsx`**: the bottom sheets (exercise picker, exercise config, workout detail, planimport...). It is large; a new sheet can go into `components/` as its own file.diff --git a/frontend/src/lib/measurements.js b/frontend/src/lib/measurements.jsindex 555adaaa6..d007c1d97 100644--- a/frontend/src/lib/measurements.js+++ b/frontend/src/lib/measurements.js@@ -1,6 +1,5 @@-// Body measurements are stored in centimetres, regardless of the profile's weight unit.-// Keeping one canonical unit means changing kg/lb never relabels old circumference values as-// something they are not. The UI converts at its edge: kg profiles see cm, lb profiles see in.+// Canonical storage: lengths in cm, masses in kg, percentages as-is. A custom field's unit+// selects its display unit. Legacy fields without one still follow the profile's cm/in choice.export const MEASUREMENT_FIELDS = [{ key: 'neck', label: 'Neck', group: 'Torso' },@@ -28,16 +27,39 @@ export const MEASUREMENT_KEYS = MEASUREMENT_FIELDS.map(f => f.key)export const DEFAULT_MEASUREMENT_KEYS = MEASUREMENT_FIELDS.filter(f => !f.optional).map(f => f.key)const round = n => Math.round(n * 10) / 10-const valid = v => Number.isFinite(+v) && +v > 0 ? round(+v) : null+const valid = (v, unit) => v != null && v !== '' && Number.isFinite(+v) &&+ (unit === '%' ? +v >= 0 && +v <= 100 : +v > 0)+ ? (unit === 'kg' || unit === 'lb' ? Math.round(+v * 1000) / 1000 : round(+v)) : null+const LB_PER_KG = 2.2046226218+export const CUSTOM_MEASUREMENT_UNITS = ['cm', 'in', '%', 'kg', 'lb']+const unitOf = field => CUSTOM_MEASUREMENT_UNITS.includes(field?.unit) ? field.unit : null+const withUnit = field => unitOf(field) ? { unit: field.unit } : {}+const unitKind = unit => unit === '%' ? 'percent' : unit === 'kg' || unit === 'lb' ? 'mass' : 'length'++export const measurementUnit = (unit, field) => field?.key === 'bodyFat' ? '%' : unitOf(field) || (unit === 'lb' ? 'in' : 'cm')+export const toMeasurementDisplay = (value, unit, field) => {+ if (value == null) return null+ const display = measurementUnit(unit, field)+ return round(display === 'in' ? value / 2.54 : display === 'lb' ? value * LB_PER_KG : value)+}+export const fromMeasurementDisplay = (value, unit, field) => {+ const display = measurementUnit(unit, field)+ return valid(display === 'in' && value != null ? +value * 2.54 : display === 'lb' && value != null ? +value / LB_PER_KG : value, display)+}-export const measurementUnit = unit => unit === 'lb' ? 'in' : 'cm'-export const toMeasurementDisplay = (cm, unit) => cm == null ? null : round(unit === 'lb' ? cm / 2.54 : cm)-export const fromMeasurementDisplay = (value, unit) => value == null ? null : valid(unit === 'lb' ? +value * 2.54 : +value)+// A unit change can convert cm/in or kg/lb, but cannot turn recorded lengths into percentages.+// An empty custom field may still choose any type. Readings keep a unit for orphaned backups.+export function customMeasurementUnits(field, entries = []) {+ const logged = entries.flatMap(e => e.other || []).filter(o => o.id === field.id && o.value != null)+ if (!logged.length) return CUSTOM_MEASUREMENT_UNITS+ const kinds = [...new Set(logged.map(o => unitKind(unitOf(o) || unitOf(field))))]+ return CUSTOM_MEASUREMENT_UNITS.filter(unit => kinds.every(kind => kind === unitKind(unit)))+}export function emptyMeasurement(date, custom = []) {const entry = { d: date, t: new Date(date + 'T12:00:00').getTime() }for (const key of MEASUREMENT_KEYS) entry[key] = null- entry.other = custom.map(c => ({ id: c.id, name: c.name, value: null }))+ entry.other = custom.map(c => ({ id: c.id, name: c.name, value: null, ...withUnit(c) }))return entry}@@ -46,17 +68,18 @@ export function emptyMeasurement(date, custom = []) {export function normalizeMeasurementEntry(raw = {}, custom = []) {const entry = emptyMeasurement(raw.d || '', custom)entry.t = Number.isFinite(+raw.t) ? +raw.t : entry.t- for (const key of MEASUREMENT_KEYS) entry[key] = valid(raw[key])- if (entry.bodyFat != null && entry.bodyFat > 100) entry.bodyFat = null+ for (const key of MEASUREMENT_KEYS) entry[key] = valid(raw[key], key === 'bodyFat' ? '%' : null)const known = new Map(custom.map(c => [c.id, c]))const seen = new Set()entry.other = (Array.isArray(raw.other) ? raw.other : []).map(o => {if (!o || !o.id || seen.has(o.id)) return nullseen.add(o.id)- return { id: String(o.id), name: String(known.get(o.id)?.name || o.name || 'Other'), value: valid(o.value) }+ const field = known.get(o.id)+ const unit = unitOf(o) || unitOf(field)+ return { id: String(o.id), name: String(field?.name || o.name || 'Other'), value: valid(o.value, unit), ...withUnit({ unit }) }}).filter(Boolean)- for (const c of custom) if (!seen.has(c.id)) entry.other.push({ id: c.id, name: c.name, value: null })+ for (const c of custom) if (!seen.has(c.id)) entry.other.push({ id: c.id, name: c.name, value: null, ...withUnit(c) })return entry}@@ -69,7 +92,8 @@ function mergeMeasurementEntries(a, b) {const other = new Map(a.other.map(o => [o.id, o]))for (const o of b.other) {const prev = other.get(o.id)- other.set(o.id, prev ? { ...o, value: o.value ?? prev.value } : o)+ // An empty later reading must not replace the unit attached to the value we keep.+ other.set(o.id, prev && o.value == null ? { ...prev, name: o.name } : o)}entry.other = [...other.values()]return entry@@ -81,7 +105,7 @@ export function normalizeMeasurementsState(state) {state.customMeasurements = rawCustom.map(c => {if (!c || !c.id || !String(c.name || '').trim() || ids.has(String(c.id))) return nullconst id = String(c.id); ids.add(id)- return { id, name: String(c.name).trim().slice(0, 60), enabled: c.enabled !== false }+ return { id, name: String(c.name).trim().slice(0, 60), enabled: c.enabled !== false, ...withUnit(c) }}).filter(Boolean)const enabled = Array.isArray(state.measurementEnabled) ? state.measurementEnabled : DEFAULT_MEASUREMENT_KEYS@@ -107,8 +131,9 @@ export function normalizeMeasurementsState(state) {export function measurementValue(entry, key) {if (!entry) return null- if (!key.startsWith('other:')) return valid(entry[key])- return valid((entry.other || []).find(o => o.id === key.slice(6))?.value)+ if (!key.startsWith('other:')) return valid(entry[key], key === 'bodyFat' ? '%' : null)+ const row = (entry.other || []).find(o => o.id === key.slice(6))+ return valid(row?.value, unitOf(row))}// Order comes from MEASUREMENT_FIELDS, not from measurementEnabled: that array is a set the@@ -118,19 +143,25 @@ export function enabledMeasurementFields(state) {const enabled = new Set(state.measurementEnabled || DEFAULT_MEASUREMENT_KEYS)const builtins = MEASUREMENT_FIELDS.filter(f => enabled.has(f.key))const custom = (state.customMeasurements || []).filter(c => c.enabled !== false)- .map(c => ({ key: 'other:' + c.id, label: c.name, group: 'Other', custom: true }))+ .map(c => ({ key: 'other:' + c.id, label: c.name, group: 'Other', custom: true, ...withUnit(c) }))return [...builtins, ...custom]}export function measurementSeries(state, key, range = 0, now = Date.now()) {const cutoff = range ? now - range * 86400000 : -Infinityconst unit = state.unit || 'kg'- const percent = key === 'bodyFat'+ const field = key.startsWith('other:')+ ? (state.customMeasurements || []).find(c => c.id === key.slice(6)) || { key }+ : { key }return (state.measurements || []).map(entry => {const raw = measurementValue(entry, key)const at = new Date(entry.d + 'T12:00:00').getTime()if (raw == null || at < cutoff) return null- return { t: at, d: entry.d, y: percent ? raw : toMeasurementDisplay(raw, unit) }+ const stored = key.startsWith('other:') ? entry.other?.find(o => o.id === key.slice(6)) : null+ // An incomplete backup may retain a reading without its custom definition.+ const displayField = unitOf(field) ? field : { ...field, ...withUnit(stored) }+ if (stored && unitKind(unitOf(stored) || unitOf(field)) !== unitKind(unitOf(displayField))) return null+ return { t: at, d: entry.d, y: toMeasurementDisplay(raw, unit, displayField) }}).filter(Boolean)}@@ -143,6 +174,6 @@ export function latestMeasurement(state, key) {}export function measurementEntryHasValues(entry) {- return MEASUREMENT_KEYS.some(k => valid(entry?.[k]) != null) ||- (entry?.other || []).some(o => valid(o?.value) != null)+ return MEASUREMENT_KEYS.some(k => valid(entry?.[k], k === 'bodyFat' ? '%' : null) != null) ||+ (entry?.other || []).some(o => valid(o?.value, unitOf(o)) != null)}diff --git a/frontend/src/lib/measurements.test.js b/frontend/src/lib/measurements.test.jsindex a208d6164..decfe9928 100644--- a/frontend/src/lib/measurements.test.js+++ b/frontend/src/lib/measurements.test.js@@ -3,6 +3,7 @@ import {MEASUREMENT_KEYS, DEFAULT_MEASUREMENT_KEYS, emptyMeasurement, enabledMeasurementFields,normalizeMeasurementEntry, normalizeMeasurementsState, measurementSeries,toMeasurementDisplay, fromMeasurementDisplay, measurementEntryHasValues,+ measurementUnit, measurementValue, customMeasurementUnits,} from './measurements.js'describe('body measurements', () => {@@ -81,3 +82,88 @@ describe('body measurements', () => {.toEqual([...DEFAULT_MEASUREMENT_KEYS, 'other:knee'])})})++describe('custom measurement units (#699)', () => {+ const field = unit => ({ id: 'muscle', name: 'Muscle mass', unit })+ const state = (unit, values = [40, 41.5]) => normalizeMeasurementsState({+ unit: 'lb', customMeasurements: [field(unit)], measurementEnabled: [],+ measurements: values.map((value, i) => ({ d: `2026-10-0${i + 1}`, other: [{ id: 'muscle', value }] })),+ })++ it.each(['cm', 'in', '%', 'kg', 'lb'])('preserves the selected %s unit through repeated normalization', unit => {+ const s = state(unit)+ expect(s.customMeasurements[0].unit).toBe(unit)+ expect(enabledMeasurementFields(s)[0].unit).toBe(unit)+ expect(s.measurements[0].other[0].unit).toBe(unit)+ expect(normalizeMeasurementsState(structuredClone(s))).toEqual(s)+ expect(measurementUnit('kg', field(unit))).toBe(unit)+ expect(measurementUnit('lb', field(unit))).toBe(unit)+ })++ it('never converts a custom percentage to inches on a pounds profile', () => {+ const s = state('%')+ expect(measurementSeries(s, 'other:muscle').map(p => p.y)).toEqual([40, 41.5])+ expect(measurementSeries({ ...s, unit: 'kg' }, 'other:muscle').map(p => p.y)).toEqual([40, 41.5])+ expect(fromMeasurementDisplay(41.5, 'lb', field('%'))).toBe(41.5)+ })++ it('converts explicit inches and pounds at the input/display boundary', () => {+ expect(fromMeasurementDisplay(32.5, 'kg', field('in'))).toBe(82.6)+ expect(toMeasurementDisplay(82.6, 'lb', field('cm'))).toBe(82.6)+ expect(fromMeasurementDisplay(110.2, 'kg', field('lb'))).toBe(49.986)+ expect(toMeasurementDisplay(50, 'kg', field('lb'))).toBe(110.2)+ expect(measurementSeries(state('kg'), 'other:muscle')[0].y).toBe(40)+ expect(measurementSeries(state('lb', [50]), 'other:muscle')[0].y).toBe(110.2)+ // Keep enough canonical precision that saving 110.3 lb does not come back as 110.2 lb.+ const kg = fromMeasurementDisplay(110.3, 'kg', field('lb'))+ const saved = state('lb', [kg])+ expect(measurementSeries(saved, 'other:muscle')[0].y).toBe(110.3)+ })++ it('keeps legacy custom values in cm and follows the profile display unit', () => {+ const s = state(undefined, [82.6])+ expect(s.customMeasurements[0]).not.toHaveProperty('unit')+ expect(s.measurements[0].other[0].value).toBe(82.6)+ expect(measurementSeries(s, 'other:muscle')[0].y).toBe(32.5)+ expect(measurementSeries({ ...s, unit: 'kg' }, 'other:muscle')[0].y).toBe(82.6)+ })++ it('accepts 0–100% including zero, ignores blank/invalid values, and preserves orphaned units', () => {+ const s = state('%', [0, 100, 101, -1, null, ''])+ expect(s.measurements.map(e => e.other[0].value)).toEqual([0, 100, null, null, null, null])+ expect(measurementValue(s.measurements[0], 'other:muscle')).toBe(0)+ expect(measurementEntryHasValues(s.measurements[0])).toBe(true)+ const orphaned = normalizeMeasurementsState({ ...s, customMeasurements: [] })+ expect(orphaned.measurements[0].other[0]).toMatchObject({ value: 0, unit: '%' })+ expect(measurementSeries(orphaned, 'other:muscle').map(p => p.y)).toEqual([0, 100])+ })++ it('allows changing display units within a type, without reinterpreting old readings', () => {+ const mass = state('kg')+ expect(customMeasurementUnits(mass.customMeasurements[0], mass.measurements)).toEqual(['kg', 'lb'])+ const length = state(undefined)+ expect(customMeasurementUnits(length.customMeasurements[0], length.measurements)).toEqual(['cm', 'in'])+ const percent = state('%', [0])+ expect(customMeasurementUnits(percent.customMeasurements[0], percent.measurements)).toEqual(['%'])+ expect(customMeasurementUnits(field('cm'), [])).toEqual(['cm', 'in', '%', 'kg', 'lb'])+ const before = structuredClone(mass.measurements)+ mass.customMeasurements[0].unit = 'lb'+ normalizeMeasurementsState(mass)+ expect(mass.measurements).toEqual(before)+ expect(measurementSeries(mass, 'other:muscle')[0].y).toBe(88.2)+ })++ it('falls back safely for an unknown unit without altering stored values', () => {+ const s = state('invalid', [82.6])+ expect(s.customMeasurements[0]).not.toHaveProperty('unit')+ expect(measurementSeries(s, 'other:muscle')[0].y).toBe(32.5)+ })++ it('keeps a value and its unit together when folding partial backup readings for one day', () => {+ const s = normalizeMeasurementsState({ measurements: [+ { d: '2026-10-01', t: 1, other: [{ id: 'mass', name: 'Mass', value: 60, unit: 'kg' }] },+ { d: '2026-10-01', t: 2, other: [{ id: 'mass', name: 'Mass', value: null, unit: '%' }] },+ ] })+ expect(s.measurements[0].other[0]).toEqual({ id: 'mass', name: 'Mass', value: 60, unit: 'kg' })+ })+})diff --git a/frontend/src/locales/ar.js b/frontend/src/locales/ar.jsindex f6cc67b55..d40c259e3 100644--- a/frontend/src/locales/ar.js+++ b/frontend/src/locales/ar.js@@ -2541,4 +2541,8 @@ export default {'How long a message, refinement or review note can be.': 'كم يمكن أن يطول نص رسالة أو طلب تعديل أو ملاحظة مراجعة.',// --- one set's own rest (#609) ---'Rest after this set': 'الراحة بعد هذه المجموعة',+ // --- custom measurement units (#699) ---+ "Measurement unit": "وحدة القياس",+ "Logged values keep their type. Add a new measurement to use a different type.": "تحتفظ القيم المسجلة بنوعها. أضف قياسًا جديدًا لاستخدام نوع مختلف.",+ "{0} must be between 0 and 100%.": "يجب أن تكون قيمة {0} بين 0 و100٪.",}diff --git a/frontend/src/locales/bn.js b/frontend/src/locales/bn.jsindex 9eeab9cc5..47f0b5dc2 100644--- a/frontend/src/locales/bn.js+++ b/frontend/src/locales/bn.js@@ -2565,4 +2565,8 @@ export default {'How long a message, refinement or review note can be.': 'একটি বার্তা, পরিমার্জনার অনুরোধ বা পর্যালোচনা নোট কত দীর্ঘ হতে পারে।',// --- one set's own rest (#609) ---'Rest after this set': 'এই সেটের পরে বিশ্রাম',+ // --- custom measurement units (#699) ---+ "Measurement unit": "পরিমাপের একক",+ "Logged values keep their type. Add a new measurement to use a different type.": "লগ করা মানের ধরন অপরিবর্তিত থাকে। অন্য ধরন ব্যবহার করতে নতুন পরিমাপ যোগ করুন।",+ "{0} must be between 0 and 100%.": "{0} অবশ্যই ০ থেকে ১০০%-এর মধ্যে হতে হবে।",}diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.jsindex fe32e04ed..237168a06 100644--- a/frontend/src/locales/de.js+++ b/frontend/src/locales/de.js@@ -2506,4 +2506,8 @@ export default {'How long a message, refinement or review note can be.': 'Wie lang eine Nachricht, ein Überarbeitungswunsch oder eine Analyse-Notiz sein darf.',// --- one set's own rest (#609) ---'Rest after this set': 'Pause nach diesem Satz',+ // --- custom measurement units (#699) ---+ "Measurement unit": "Maßeinheit",+ "Logged values keep their type. Add a new measurement to use a different type.": "Erfasste Werte behalten ihren Typ. Für einen anderen Typ füge ein neues Maß hinzu.",+ "{0} must be between 0 and 100%.": "{0} muss zwischen 0 und 100 % liegen.",}diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.jsindex 675a35891..fd734a6a3 100644--- a/frontend/src/locales/es.js+++ b/frontend/src/locales/es.js@@ -2486,4 +2486,8 @@ export default {'How long a message, refinement or review note can be.': 'Cuánto puede tener un mensaje, una petición de refinamiento o una nota de análisis.',// --- one set's own rest (#609) ---'Rest after this set': 'Descanso tras esta serie',+ // --- custom measurement units (#699) ---+ "Measurement unit": "Unidad de medida",+ "Logged values keep their type. Add a new measurement to use a different type.": "Los valores registrados conservan su tipo. Añade una nueva medida para usar otro tipo.",+ "{0} must be between 0 and 100%.": "{0} debe estar entre 0 y 100 %.",}diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.jsindex bb97e431d..88b334ae0 100644--- a/frontend/src/locales/fr.js+++ b/frontend/src/locales/fr.js@@ -2486,4 +2486,8 @@ export default {'How long a message, refinement or review note can be.': 'La longueur autorisée d’un message, d’une demande de révision ou d’une note d’analyse.',// --- one set's own rest (#609) ---'Rest after this set': 'Repos après cette série',+ // --- custom measurement units (#699) ---+ "Measurement unit": "Unité de mesure",+ "Logged values keep their type. Add a new measurement to use a different type.": "Les valeurs enregistrées conservent leur type. Ajoute une nouvelle mesure pour utiliser un autre type.",+ "{0} must be between 0 and 100%.": "{0} doit être compris entre 0 et 100 %.",}diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.jsindex 7676278e8..c59003db2 100644--- a/frontend/src/locales/hi.js+++ b/frontend/src/locales/hi.js@@ -2486,4 +2486,8 @@ export default {'How long a message, refinement or review note can be.': 'संदेश, सुधार अनुरोध या समीक्षा नोट कितना लंबा हो सकता है।',// --- one set's own rest (#609) ---'Rest after this set': 'इस सेट के बाद आराम',+ // --- custom measurement units (#699) ---+ "Measurement unit": "माप की इकाई",+ "Logged values keep their type. Add a new measurement to use a different type.": "दर्ज किए गए मानों का प्रकार बना रहता है। दूसरे प्रकार के लिए नया माप जोड़ें।",+ "{0} must be between 0 and 100%.": "{0} का मान 0 से 100% के बीच होना चाहिए।",}diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.jsindex 3280cb531..35e8e175b 100644--- a/frontend/src/locales/hu.js+++ b/frontend/src/locales/hu.js@@ -2489,4 +2489,8 @@ export default {'How long a message, refinement or review note can be.': 'Milyen hosszú lehet egy üzenet, finomítási kérés vagy elemzési megjegyzés.',// --- one set's own rest (#609) ---'Rest after this set': 'Pihenő e sorozat után',+ // --- custom measurement units (#699) ---+ "Measurement unit": "Mértékegység",+ "Logged values keep their type. Add a new measurement to use a different type.": "A rögzített értékek típusa megmarad. Más típushoz adj hozzá új mérést.",+ "{0} must be between 0 and 100%.": "{0} értékének 0 és 100% között kell lennie.",}diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.jsindex da2d4777d..cc3d8a9b0 100644--- a/frontend/src/locales/it.js+++ b/frontend/src/locales/it.js@@ -2486,4 +2486,8 @@ export default {'How long a message, refinement or review note can be.': 'Quanto può essere lungo un messaggio, una richiesta di revisione o una nota di analisi.',// --- one set's own rest (#609) ---'Rest after this set': 'Recupero dopo questa serie',+ // --- custom measurement units (#699) ---+ "Measurement unit": "Unità di misura",+ "Logged values keep their type. Add a new measurement to use a different type.": "I valori registrati mantengono il proprio tipo. Aggiungi una nuova misura per usare un tipo diverso.",+ "{0} must be between 0 and 100%.": "{0} deve essere tra 0 e 100%.",}diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.jsindex 3fbdd2a22..017f09cf7 100644--- a/frontend/src/locales/ko.js+++ b/frontend/src/locales/ko.js@@ -2486,4 +2486,8 @@ export default {'How long a message, refinement or review note can be.': '메시지, 수정 요청 또는 리뷰 메모의 최대 길이입니다.',// --- one set's own rest (#609) ---'Rest after this set': '이 세트 후 휴식',+ // --- custom measurement units (#699) ---+ "Measurement unit": "측정 단위",+ "Logged values keep their type. Add a new measurement to use a different type.": "기록된 값의 유형은 유지됩니다. 다른 유형을 사용하려면 새 측정 항목을 추가하세요.",+ "{0} must be between 0 and 100%.": "{0} 값은 0~100% 사이여야 합니다.",}diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.jsindex c6e92786d..b74d336ba 100644--- a/frontend/src/locales/pl.js+++ b/frontend/src/locales/pl.js@@ -2486,4 +2486,8 @@ export default {'How long a message, refinement or review note can be.': 'Jak długi może być komunikat, prośba o korektę lub notatka z analizy.',// --- one set's own rest (#609) ---'Rest after this set': 'Przerwa po tej serii',+ // --- custom measurement units (#699) ---+ "Measurement unit": "Jednostka pomiaru",+ "Logged values keep their type. Add a new measurement to use a different type.": "Zapisane wartości zachowują swój typ. Dodaj nowy pomiar, aby użyć innego typu.",+ "{0} must be between 0 and 100%.": "{0} musi mieścić się w zakresie od 0 do 100%.",}diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.jsindex 8db3cf1eb..28e5eb8da 100644--- a/frontend/src/locales/pt-BR.js+++ b/frontend/src/locales/pt-BR.js@@ -1592,6 +1592,10 @@ export const PT_BR_OVERRIDES = {'Every Coach run is one request on your provider account. 0 means no limit.': 'Cada execução do Treinador é uma requisição na sua conta do provedor. 0 significa sem limite.','Max message length': 'Comprimento máximo da mensagem','How long a message, refinement or review note can be.': 'Quanto pode ter uma mensagem, um pedido de refinamento ou uma nota de análise.',+ // --- custom measurement units (#699) ---+ "Measurement unit": "Unidade de medida",+ "Logged values keep their type. Add a new measurement to use a different type.": "Os valores salvos mantêm seu tipo. Adicione uma nova medida para usar outro tipo.",+ "{0} must be between 0 and 100%.": "{0} deve estar entre 0 e 100%.",}export default { ...pt, ...PT_BR_OVERRIDES }diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.jsindex aa79bed4b..18ed9277d 100644--- a/frontend/src/locales/pt.js+++ b/frontend/src/locales/pt.js@@ -2486,4 +2486,8 @@ export default {'How long a message, refinement or review note can be.': 'Quanto pode ter uma mensagem, um pedido de revisão ou uma nota de análise.',// --- one set's own rest (#609) ---'Rest after this set': 'Descanso depois desta série',+ // --- custom measurement units (#699) ---+ "Measurement unit": "Unidade de medida",+ "Logged values keep their type. Add a new measurement to use a different type.": "Os valores registados mantêm o seu tipo. Adiciona uma nova medida para usar outro tipo.",+ "{0} must be between 0 and 100%.": "{0} tem de estar entre 0 e 100 %.",}diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.jsindex 4935e3d6a..3cc53207d 100644--- a/frontend/src/locales/ru.js+++ b/frontend/src/locales/ru.js@@ -2490,4 +2490,8 @@ export default {'How long a message, refinement or review note can be.': 'Насколько длинным может быть сообщение, просьба о доработке или заметка к разбору.',// --- one set's own rest (#609) ---'Rest after this set': 'Отдых после этого подхода',+ // --- custom measurement units (#699) ---+ "Measurement unit": "Единица измерения",+ "Logged values keep their type. Add a new measurement to use a different type.": "Тип записанных значений сохраняется. Для другого типа добавьте новое измерение.",+ "{0} must be between 0 and 100%.": "Значение «{0}» должно быть от 0 до 100%.",}diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.jsindex d1c66712a..d08ee0b07 100644--- a/frontend/src/locales/th.js+++ b/frontend/src/locales/th.js@@ -2497,4 +2497,8 @@ export default {'How long a message, refinement or review note can be.': 'ข้อความ คำขอปรับแก้ หรือบันทึกการวิเคราะห์ยาวได้เท่าใด',// --- one set's own rest (#609) ---'Rest after this set': 'พักหลังเซ็ตนี้',+ // --- custom measurement units (#699) ---+ "Measurement unit": "หน่วยวัด",+ "Logged values keep their type. Add a new measurement to use a different type.": "ค่าที่บันทึกไว้จะคงประเภทเดิม หากต้องการประเภทอื่น ให้เพิ่มรายการวัดใหม่",+ "{0} must be between 0 and 100%.": "{0} ต้องอยู่ระหว่าง 0 ถึง 100%",}diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.jsindex c93bbb876..5d17f344e 100644--- a/frontend/src/locales/tr.js+++ b/frontend/src/locales/tr.js@@ -2486,4 +2486,8 @@ export default {'How long a message, refinement or review note can be.': 'Bir mesajın, iyileştirme isteğinin veya inceleme notunun ne kadar uzun olabileceği.',// --- one set's own rest (#609) ---'Rest after this set': 'Bu setten sonra dinlenme',+ // --- custom measurement units (#699) ---+ "Measurement unit": "Ölçü birimi",+ "Logged values keep their type. Add a new measurement to use a different type.": "Kaydedilen değerler türlerini korur. Farklı bir tür için yeni bir ölçüm ekle.",+ "{0} must be between 0 and 100%.": "{0}, %0 ile %100 arasında olmalı.",}diff --git a/frontend/src/locales/uk.js b/frontend/src/locales/uk.jsindex 20b6e1d5e..c404d062a 100644--- a/frontend/src/locales/uk.js+++ b/frontend/src/locales/uk.js@@ -2483,4 +2483,8 @@ export default {'How long a message, refinement or review note can be.': 'Наскільки довгим може бути повідомлення, прохання про доопрацювання чи нотатка до розбору.',// --- one set's own rest (#609) ---'Rest after this set': 'Відпочинок після цього підходу',+ // --- custom measurement units (#699) ---+ "Measurement unit": "Одиниця вимірювання",+ "Logged values keep their type. Add a new measurement to use a different type.": "Тип записаних значень зберігається. Для іншого типу додайте нове вимірювання.",+ "{0} must be between 0 and 100%.": "Значення «{0}» має бути від 0 до 100%.",}diff --git a/frontend/src/locales/zh-TW.js b/frontend/src/locales/zh-TW.jsindex d88672cad..d19bb48f4 100644--- a/frontend/src/locales/zh-TW.js+++ b/frontend/src/locales/zh-TW.js@@ -2479,4 +2479,8 @@ export default {'How long a message, refinement or review note can be.': '訊息、修改要求或評論備註可以有多長。',// --- one set's own rest (#609) ---'Rest after this set': '這一組後的休息',+ // --- custom measurement units (#699) ---+ "Measurement unit": "測量單位",+ "Logged values keep their type. Add a new measurement to use a different type.": "已記錄的數值會保留原有類型。如需其他類型,請新增測量項目。",+ "{0} must be between 0 and 100%.": "{0}必須介於 0% 到 100% 之間。",}diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.jsindex fcbfe56a7..8d4d62306 100644--- a/frontend/src/locales/zh.js+++ b/frontend/src/locales/zh.js@@ -2486,4 +2486,8 @@ export default {'How long a message, refinement or review note can be.': '消息、修改要求或点评备注可以有多长。',// --- one set's own rest (#609) ---'Rest after this set': '这一组后的休息',+ // --- custom measurement units (#699) ---+ "Measurement unit": "测量单位",+ "Logged values keep their type. Add a new measurement to use a different type.": "已记录的数值会保留原有类型。如需其他类型,请添加新的测量项。",+ "{0} must be between 0 and 100%.": "{0}必须在 0% 到 100% 之间。",}diff --git a/frontend/src/store/persistence.test.js b/frontend/src/store/persistence.test.jsindex c435ccc0e..93dfeece3 100644--- a/frontend/src/store/persistence.test.js+++ b/frontend/src/store/persistence.test.js@@ -81,6 +81,23 @@ describe('persistence — measurements survive the round trips', () => {expect(measurementState(after)).toEqual(measurementState(before))})+ it('keeps custom percentages and masses through backup, sync and a profile unit change', () => {+ const before = normalizeMeasurementsState({ ...profile(),+ customMeasurements: [+ { id: 'muscle', name: 'Muscle ratio', unit: '%' },+ { id: 'lean', name: 'Lean mass', unit: 'kg' },+ ],+ measurements: [{ d: '2026-10-01', other: [{ id: 'muscle', value: 40.5 }, { id: 'lean', value: 60 }] }],+ })+ const after = pullFromServer(pushToServer(importBackup(exportBackup(before))))+ expect(measurementState(after)).toEqual(measurementState(before))+ after.unit = 'lb'+ normalizeMeasurementsState(after)+ expect(after.measurements[0].other).toEqual(before.measurements[0].other)+ const stripped = importBackup(exportBackup({ ...before, customMeasurements: [] }))+ expect(stripped.measurements[0].other).toEqual(before.measurements[0].other)+ })+it('counts a measurements-only profile as data worth keeping', () => {// pullState overwrites local state when hasData() is false. Someone who has logged tape// readings but never a workout has a profile that is entirely measurements — if that readsdiff --git a/frontend/src/store/useStore.js b/frontend/src/store/useStore.jsindex bf04e0cd8..b67016ec5 100644--- a/frontend/src/store/useStore.js+++ b/frontend/src/store/useStore.js@@ -93,8 +93,8 @@ export const DEF = {// A note per day off (#261): { [iso]: { tag, text, _ts } } (lib/day-notes.js). A noted day is// excused from the missed-day nudge; each day merges on its own stamp (lib/sync-merge.js).dayNotes: {},- // Body measurements (#82): one check-in per day, values in cm whatever the weight unit- // (lib/measurements.js); merged across devices like weigh-ins (lib/sync-merge.js).+ // Body measurements (#82, #699): one check-in per day; canonical cm, kg or % according to+ // the field's unit (lib/measurements.js); merged like weigh-ins (lib/sync-merge.js).measurements: [], measurementEnabled: null, customMeasurements: [],queue: null, // a planner's floating week (lib/queue.js) — via the API, or by this rotation feature (below)// The in-app rotation's reusable definition — { id, sequence, label } (lib/rotation.js). Neverdiff --git a/frontend/src/views/Measurements.jsx b/frontend/src/views/Measurements.jsxindex d648981cb..815ea8b88 100644--- a/frontend/src/views/Measurements.jsx+++ b/frontend/src/views/Measurements.jsx@@ -6,7 +6,7 @@ import {MEASUREMENT_FIELDS, MEASUREMENT_KEYS, emptyMeasurement, enabledMeasurementFields,fromMeasurementDisplay, latestMeasurement, measurementEntryHasValues,measurementSeries, measurementUnit, measurementValue, normalizeMeasurementEntry,- toMeasurementDisplay, normalizeMeasurementsState,+ toMeasurementDisplay, normalizeMeasurementsState, CUSTOM_MEASUREMENT_UNITS, customMeasurementUnits,} from '../lib/measurements.js'import { fmtDate, fmtNum, todayISO, uid } from '../lib/format.js'import { t } from '../lib/i18n.js'@@ -19,11 +19,11 @@ import { confirmSheet } from '../sheets.jsx'const update = (fn, ...rest) => useStore.getState().update(s => { fn(s); normalizeMeasurementsState(s) }, ...rest)const toast = message => useUI.getState().toast(message)-const fieldUnit = (field, profileUnit) => field.key === 'bodyFat' ? '%' : measurementUnit(profileUnit)+const fieldUnit = (field, profileUnit) => measurementUnit(profileUnit, field)const shownValue = (entry, field, profileUnit) => {const value = measurementValue(entry, field.key)if (value == null) return null- return field.key === 'bodyFat' ? value : toMeasurementDisplay(value, profileUnit)+ return toMeasurementDisplay(value, profileUnit, field)}function MeasurementLog({ sourceDate, close }) {@@ -38,7 +38,7 @@ function MeasurementLog({ sourceDate, close }) {}for (const o of source.other || []) {if (o.value != null && !fields.some(x => x.key === 'other:' + o.id)) {- fields.push({ key: 'other:' + o.id, label: o.name, custom: true, group: 'Other' })+ fields.push({ key: 'other:' + o.id, label: o.name, unit: o.unit, custom: true, group: 'Other' })}}}@@ -55,11 +55,17 @@ function MeasurementLog({ sourceDate, close }) {base.t = source && date === source.d ? source.t : (date === todayISO() ? Date.now() : new Date(date + 'T12:00:00').getTime())for (const field of fields) {const raw = values[field.key]- const value = raw == null || raw === 0 ? null : Math.round(+raw * 10) / 10- if (field.key === 'bodyFat' && value > 100) { toast(t('Body fat must be between 0 and 100%.')); return }+ const percent = fieldUnit(field, S.unit) === '%'+ const value = raw == null || (raw === 0 && !percent) ? null : Math.round(+raw * 10) / 10+ if (percent && value != null && (value < 0 || value > 100)) {+ toast(field.key === 'bodyFat' ? t('Body fat must be between 0 and 100%.') : t('{0} must be between 0 and 100%.', field.label)); return+ }if (field.custom) {const item = base.other.find(o => o.id === field.key.slice(6))- if (item) item.value = value == null ? null : fromMeasurementDisplay(value, S.unit)+ if (item) {+ item.value = fromMeasurementDisplay(value, S.unit, field)+ if (field.unit) item.unit = field.unit+ }} else if (field.key === 'bodyFat') base.bodyFat = valueelse base[field.key] = value == null ? null : fromMeasurementDisplay(value, S.unit)}@@ -105,6 +111,7 @@ export function measurementLogSheet(sourceDate = null) {function ManageMeasurements({ close }) {const S = useStore(s => s.S)const [name, setName] = useState('')+ const [unit, setUnit] = useState(() => measurementUnit(S.unit))const groups = [...new Set(MEASUREMENT_FIELDS.map(f => f.group))]const toggleBuiltin = (key, on) => update(state => {const set = new Set(state.measurementEnabled || [])@@ -115,6 +122,10 @@ function ManageMeasurements({ close }) {const item = state.customMeasurements.find(c => c.id === id)if (item) item.enabled = on})+ const setCustomUnit = (id, value) => update(state => {+ const item = state.customMeasurements.find(c => c.id === id)+ if (item && customMeasurementUnits(item, state.measurements).includes(value)) item.unit = value+ })const add = () => {const clean = name.trim()if (!clean) return@@ -122,7 +133,7 @@ function ManageMeasurements({ close }) {MEASUREMENT_FIELDS.some(f => f.label.toLowerCase() === clean.toLowerCase())) {toast(t('A custom measurement with that name already exists.')); return}- update(state => { state.customMeasurements.push({ id: uid(), name: clean.slice(0, 60), enabled: true }) })+ update(state => { state.customMeasurements.push({ id: uid(), name: clean.slice(0, 60), enabled: true, unit }) })setName('')}return <>@@ -133,11 +144,22 @@ function ManageMeasurements({ close }) {<span className="lrow-m"><span className="lrow-t">{t(field.label)}</span></span><Switch checked={(S.measurementEnabled || []).includes(field.key)} onChange={on => toggleBuiltin(field.key, on)} /></div>)}- {group === 'Other' && S.customMeasurements.map(field => <div className="lrow" key={field.id}>- <span className="lrow-m"><span className="lrow-t">{field.name}</span><span className="lrow-s">{t('Custom')}</span></span>- <Switch checked={field.enabled !== false} onChange={on => toggleCustom(field.id, on)} />+ {group === 'Other' && S.customMeasurements.map(field => <div key={field.id}>+ <div className="lrow">+ <span className="lrow-m"><span className="lrow-t">{field.name}</span><span className="lrow-s">{t('Custom')}</span></span>+ <Switch checked={field.enabled !== false} onChange={on => toggleCustom(field.id, on)} />+ </div>+ <SelectRow title={t('Measurement unit')} value={measurementUnit(S.unit, field)}+ options={customMeasurementUnits(field, S.measurements).map(value => ({ value, label: value }))}+ onChange={value => setCustomUnit(field.id, value)} /></div>)}</Section>)}+ <div className="muted small" style={{ marginBottom: 12 }}>{t('Logged values keep their type. Add a new measurement to use a different type.')}</div>+ <h4 className="sec">{t('Custom measurement')}</h4>+ <div className="sect-b">+ <SelectRow title={t('Measurement unit')} value={unit} onChange={setUnit}+ options={CUSTOM_MEASUREMENT_UNITS.map(value => ({ value, label: value }))} />+ </div><div className="row" style={{ gap: 8, alignItems: 'stretch' }}><TextField value={name} maxLength={60} placeholder={t('Custom measurement')} onChange={e => setName(e.target.value)} onKeyDown={e => { if (e.key === 'Enter') add() }} /><Button icon="plus" onClick={add} disabled={!name.trim()}>{t('Add')}</Button>@@ -162,7 +184,7 @@ export default function Measurements() {}for (const custom of S.customMeasurements || []) {const key = 'other:' + custom.id- if (latestMeasurement(S, key) && !out.some(f => f.key === key)) out.push({ key, label: custom.name, custom: true, group: 'Other' })+ if (latestMeasurement(S, key) && !out.some(f => f.key === key)) out.push({ key, label: custom.name, unit: custom.unit, custom: true, group: 'Other' })}return out}, [S])@@ -171,7 +193,7 @@ export default function Measurements() {const key = available.some(f => f.key === selected) ? selected : fallbackconst field = available.find(f => f.key === key)const points = key ? measurementSeries(S, key, range) : []- const unit = key === 'bodyFat' ? '%' : measurementUnit(S.unit)+ const unit = fieldUnit(field, S.unit)const all = key ? measurementSeries(S, key) : []const latest = all.at(-1)const previous = all.at(-2)diff --git a/frontend/src/views/Measurements.units.test.jsx b/frontend/src/views/Measurements.units.test.jsxnew file mode 100644index 000000000..305b1d724--- /dev/null+++ b/frontend/src/views/Measurements.units.test.jsx@@ -0,0 +1,135 @@+// @vitest-environment happy-dom+import React, { act } from 'react'+import { createRoot } from 'react-dom/client'+import { MemoryRouter } from 'react-router-dom'+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import Measurements, { manageMeasurementsSheet, measurementLogSheet } from './Measurements.jsx'+import { DEF, useStore } from '../store/useStore.js'+import { useUI } from '../store/useUI.js'+import { bindUI } from '../components/ui.jsx'+import { normalizeMeasurementsState } from '../lib/measurements.js'++const mounted = []+function render(node) {+ const host = document.createElement('div')+ document.body.appendChild(host)+ const root = createRoot(host)+ mounted.push([root, host])+ act(() => root.render(node))+ return host+}+function topSheet() {+ const sheet = useUI.getState().sheets.at(-1)+ return render(sheet.render(() => useUI.getState().closeSheet(sheet.id)))+}+const buttons = host => [...host.querySelectorAll('button')]+const button = (host, text) => buttons(host).find(el => el.textContent.trim() === text)+const unitRows = host => buttons(host).filter(el => el.querySelector('.lrow-t')?.textContent === 'Measurement unit')+const field = (host, name) => [...host.querySelectorAll('.measure-field')].find(el => el.firstElementChild.textContent === name)+const type = (input, value) => act(() => {+ Object.getOwnPropertyDescriptor(input.constructor.prototype, 'value').set.call(input, value)+ input.dispatchEvent(new Event('input', { bubbles: true }))+})+const install = patch => useStore.setState({ S: normalizeMeasurementsState({ ...structuredClone(DEF), measurementEnabled: [], ...patch }), user: null })+const custom = (id, unit, enabled = true) => ({ id, name: id, unit, enabled })++beforeEach(() => {+ globalThis.IS_REACT_ACT_ENVIRONMENT = true+ vi.useFakeTimers({ toFake: ['Date'], now: new Date('2026-10-20T12:00:00Z') })+ bindUI(useUI)+ useUI.setState({ sheets: [], toast: vi.fn() })+ install({})+})+afterEach(() => {+ act(() => mounted.splice(0).forEach(([root, host]) => { root.unmount(); host.remove() }))+ vi.useRealTimers()+})++describe('custom measurement units in the app (#699)', () => {+ it.each(['%', 'kg', 'lb', 'cm', 'in'])('creates a custom field with unit %s', unit => {+ manageMeasurementsSheet()+ const host = topSheet()+ act(() => unitRows(host).at(-1).click())+ const picker = topSheet()+ act(() => button(picker, unit).click())+ type(host.querySelector('input[placeholder="Custom measurement"]'), 'Muscle mass')+ act(() => button(host, 'Add').click())+ expect(useStore.getState().S.customMeasurements).toEqual([+ expect.objectContaining({ name: 'Muscle mass', unit, enabled: true })+ ])+ })++ it('logs percentages, masses and legacy lengths with the right units on a pounds profile', () => {+ install({ unit: 'lb', customMeasurements: [custom('Muscle ratio', '%'), custom('Lean mass', 'kg'), custom('Knee', undefined)] })+ measurementLogSheet()+ const host = topSheet()+ expect(field(host, 'Muscle ratio').querySelector('i').textContent).toBe('%')+ expect(field(host, 'Lean mass').querySelector('i').textContent).toBe('kg')+ expect(field(host, 'Knee').querySelector('i').textContent).toBe('in')+ type(field(host, 'Muscle ratio').querySelector('input'), '40.5')+ type(field(host, 'Lean mass').querySelector('input'), '60')+ type(field(host, 'Knee').querySelector('input'), '15')+ act(() => button(host, 'Save').click())+ expect(useStore.getState().S.measurements[0].other).toEqual([+ { id: 'Muscle ratio', name: 'Muscle ratio', value: 40.5, unit: '%' },+ { id: 'Lean mass', name: 'Lean mass', value: 60, unit: 'kg' },+ { id: 'Knee', name: 'Knee', value: 38.1 },+ ])+ })++ it('edits a disabled percent field without converting it to a circumference', () => {+ install({ unit: 'lb', customMeasurements: [custom('Muscle ratio', '%', false)],+ measurements: [{ d: '2026-10-01', other: [{ id: 'Muscle ratio', value: 40.5 }] }],+ })+ measurementLogSheet('2026-10-01')+ const host = topSheet()+ const input = field(host, 'Muscle ratio').querySelector('input')+ expect(input.value).toBe('40.5')+ type(input, '42')+ act(() => button(host, 'Save').click())+ expect(useStore.getState().S.measurements[0].other[0]).toMatchObject({ value: 42, unit: '%' })+ })++ it('shows the same percent value, delta and history after changing the profile to pounds', () => {+ install({ customMeasurements: [custom('Muscle ratio', '%')], measurements: [+ { d: '2026-10-01', other: [{ id: 'Muscle ratio', value: 40 }] },+ { d: '2026-10-02', other: [{ id: 'Muscle ratio', value: 40.5 }] },+ ] })+ const host = render(<MemoryRouter><Measurements /></MemoryRouter>)+ expect(host.querySelector('.big').textContent).toBe('40.5 %')+ expect(host.textContent).toContain('+0.5 % since previous')+ expect(host.querySelector('.measure-preview b').textContent).toBe('40.5 %')+ expect(host.querySelector('.chart svg')).toBeTruthy()+ act(() => useStore.setState(s => ({ S: { ...s.S, unit: 'lb' } })))+ expect(host.querySelector('.big').textContent).toBe('40.5 %')+ expect(host.querySelector('.measure-preview b').textContent).toBe('40.5 %')+ })++ it('rejects a percentage above 100 without writing, and accepts zero', () => {+ install({ customMeasurements: [custom('Muscle ratio', '%')] })+ measurementLogSheet()+ const host = topSheet()+ type(field(host, 'Muscle ratio').querySelector('input'), '101')+ act(() => button(host, 'Save').click())+ expect(useStore.getState().S.measurements).toEqual([])+ expect(useUI.getState().toast).toHaveBeenCalledWith('Muscle ratio must be between 0 and 100%.')+ type(field(host, 'Muscle ratio').querySelector('input'), '0')+ act(() => button(host, 'Save').click())+ expect(useStore.getState().S.measurements[0].other[0]).toMatchObject({ value: 0, unit: '%' })+ })++ it('offers only cm/in for a field with legacy length history, keeping canonical values unchanged', () => {+ install({ customMeasurements: [custom('Knee', undefined)], measurements: [+ { d: '2026-10-01', other: [{ id: 'Knee', value: 38.1 }] },+ ] })+ manageMeasurementsSheet()+ const host = topSheet()+ act(() => unitRows(host)[0].click())+ const picker = topSheet()+ expect(button(picker, '%')).toBeUndefined()+ expect(button(picker, 'kg')).toBeUndefined()+ act(() => button(picker, 'in').click())+ expect(useStore.getState().S.customMeasurements[0].unit).toBe('in')+ expect(useStore.getState().S.measurements[0].other[0].value).toBe(38.1)+ })+})