diff --git a/frontend/src/lib/import-csv.js b/frontend/src/lib/import-csv.js index a3a049c..1cf2402 100644 --- a/frontend/src/lib/import-csv.js +++ b/frontend/src/lib/import-csv.js @@ -62,8 +62,8 @@ const COLUMNS = [ ['endTime', ['end time']], ['workoutName', ['workout name', 'title', 'workout']], ['category', ['category', 'body part', 'muscle group']], - ['weightKg', ['weight kg', 'weight (kg)']], - ['weightLb', ['weight lbs', 'weight lb', 'weight (lb)']], + ['weightKg', ['weight kg']], + ['weightLb', ['weight lbs', 'weight lb']], ['weight', ['weight']], ['weightUnit', ['weight unit', 'unit']], ['reps', ['reps', 'repetitions']], @@ -71,11 +71,11 @@ const COLUMNS = [ // when it is there rather than dropping the column on the floor. ['rpe', ['rpe', 'rpe rating']], ['rir', ['rir', 'reps in reserve']], - ['distanceKm', ['distance km', 'distance (km)']], + ['distanceKm', ['distance km']], ['distance', ['distance']], ['distanceUnit', ['distance unit']], - ['seconds', ['seconds', 'duration seconds']], - ['time', ['time', 'duration', 'set duration (sec)']], + ['seconds', ['seconds', 'duration seconds', 'set duration sec']], + ['time', ['time', 'duration']], ['setType', ['set type']], ['note', ['comment', 'comments', 'notes', 'note', 'workout notes']], ] diff --git a/frontend/src/lib/import-csv.test.js b/frontend/src/lib/import-csv.test.js index 346c715..6f392f6 100644 --- a/frontend/src/lib/import-csv.test.js +++ b/frontend/src/lib/import-csv.test.js @@ -24,3 +24,29 @@ describe('CSV warm-up provenance', () => { expect(entry.topW).toBe(85) }) }) + +// gravl writes its units in parentheses ("Weight (kg)", "Set Duration (sec)"). Header text is +// normalised before it is matched, so the alias table has to hold the normalised form — an alias +// written with the parentheses can never match. Sample rows are from the gravl export in !21. +const GRAVL = [ + 'Date,Start Date,Workout,Source,Workout Duration (min),Energy,Exercise,Superset,Set,Set Type,Reps,Weight (kg),Distance (km),Set Duration (sec),Incline,Steps,Effort,Workout Notes', + '2026/01/01,1:11 PM,Push Day,,11,11,Chin Up,No,1,Normal,11,11,0,,,,Ideal,felt strong', + '2026/01/22,2:22 PM,External Something,APP,21,22,Walking,No,0,Normal,0,0,0,22,,,,', +].join('\n') + +describe('gravl export', () => { + it('reads slash dates, parenthesised weight and per-set duration', () => { + const parsed = parseWorkoutCSV(GRAVL, { unit: 'kg' }) + + expect(parsed.skipped).toBe(0) + expect(parsed.from).toBe('2026-01-01') + expect(parsed.to).toBe('2026-01-22') + + const [lift, cardio] = parsed.workouts + expect(lift.name).toBe('Push Day') + expect(lift.entries[0].sets).toEqual([{ w: 11, r: 11, done: true }]) + + // "Set Duration (sec)" is seconds, not minutes: read as `time` it would land as 22 minutes. + expect(cardio.entries[0].sets).toEqual([{ min: 0.4, speed: 0, done: true }]) + }) +})