hevy-shared 1.0.960 → 1.0.962

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc +21 -0
  3. package/.github/workflows/ci.yml +15 -0
  4. package/.github/workflows/npm-publish.yml +59 -0
  5. package/.github/workflows/pr-auto-assign.yml +15 -0
  6. package/.prettierrc.js +5 -0
  7. package/README.md +2 -17
  8. package/built/chat.d.ts +23 -25
  9. package/built/coachPlans.d.ts +1 -2
  10. package/built/coachPlans.js +2 -2
  11. package/built/filterExercises.d.ts +3 -19
  12. package/built/filterExercises.js +60 -72
  13. package/built/index.d.ts +304 -1140
  14. package/built/index.js +75 -269
  15. package/built/setIndicatorUtils.d.ts +3 -4
  16. package/built/setIndicatorUtils.js +1 -15
  17. package/built/tests/utils.test.js +0 -748
  18. package/built/tests/workoutVolume.test.js +49 -165
  19. package/built/units.d.ts +7 -14
  20. package/built/units.js +14 -24
  21. package/built/utils.d.ts +5 -192
  22. package/built/utils.js +85 -598
  23. package/built/websocket.d.ts +2 -14
  24. package/built/workoutVolume.d.ts +5 -24
  25. package/built/workoutVolume.js +34 -25
  26. package/jest.config.js +4 -0
  27. package/package.json +10 -32
  28. package/src/chat.ts +130 -0
  29. package/src/coachPlans.ts +57 -0
  30. package/src/constants.ts +14 -0
  31. package/src/filterExercises.ts +222 -0
  32. package/src/index.ts +1576 -0
  33. package/src/setIndicatorUtils.ts +137 -0
  34. package/src/tests/utils.test.ts +156 -0
  35. package/src/tests/workoutVolume.test.ts +93 -0
  36. package/src/units.ts +41 -0
  37. package/src/utils.ts +516 -0
  38. package/src/websocket.ts +36 -0
  39. package/src/workoutVolume.ts +175 -0
  40. package/tsconfig.json +70 -0
  41. package/built/API/APIClient.d.ts +0 -157
  42. package/built/API/APIClient.js +0 -381
  43. package/built/API/index.d.ts +0 -2
  44. package/built/API/index.js +0 -18
  45. package/built/API/types.d.ts +0 -38
  46. package/built/API/types.js +0 -18
  47. package/built/adjustEventTokens.d.ts +0 -16
  48. package/built/adjustEventTokens.js +0 -18
  49. package/built/adminPermissions.d.ts +0 -4
  50. package/built/adminPermissions.js +0 -22
  51. package/built/async.d.ts +0 -50
  52. package/built/async.js +0 -170
  53. package/built/cue.d.ts +0 -12
  54. package/built/cue.js +0 -22
  55. package/built/exerciseLocaleUtils.d.ts +0 -17
  56. package/built/exerciseLocaleUtils.js +0 -62
  57. package/built/hevyTrainer.d.ts +0 -250
  58. package/built/hevyTrainer.js +0 -676
  59. package/built/muscleHeatmaps.d.ts +0 -31
  60. package/built/muscleHeatmaps.js +0 -68
  61. package/built/muscleSplits.d.ts +0 -36
  62. package/built/muscleSplits.js +0 -100
  63. package/built/normalizedWorkoutUtils.d.ts +0 -88
  64. package/built/normalizedWorkoutUtils.js +0 -112
  65. package/built/notifications.d.ts +0 -215
  66. package/built/notifications.js +0 -9
  67. package/built/routineUtils.d.ts +0 -14
  68. package/built/routineUtils.js +0 -186
  69. package/built/schemas.d.ts +0 -6
  70. package/built/schemas.js +0 -12
  71. package/built/tests/async.test.d.ts +0 -1
  72. package/built/tests/async.test.js +0 -49
  73. package/built/tests/hevyTrainer.test.d.ts +0 -1
  74. package/built/tests/hevyTrainer.test.js +0 -1199
  75. package/built/tests/muscleSplit.test.d.ts +0 -1
  76. package/built/tests/muscleSplit.test.js +0 -153
  77. package/built/tests/routineUtils.test.d.ts +0 -1
  78. package/built/tests/routineUtils.test.js +0 -745
  79. package/built/tests/testUtils.d.ts +0 -85
  80. package/built/tests/testUtils.js +0 -319
  81. package/built/translations/index.d.ts +0 -2
  82. package/built/translations/index.js +0 -18
  83. package/built/translations/translationUtils.d.ts +0 -2
  84. package/built/translations/translationUtils.js +0 -61
  85. package/built/translations/types.d.ts +0 -8
  86. package/built/translations/types.js +0 -20
  87. package/built/typeUtils.d.ts +0 -70
  88. package/built/typeUtils.js +0 -55
@@ -1,745 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const routineUtils_1 = require("../routineUtils");
4
- const testUtils_1 = require("./testUtils");
5
- describe('majorRoutineUpdate', () => {
6
- it('takes a routine and a workout, and generates a list of routine exercise updates from the workout', () => {
7
- const routine = new testUtils_1.RoutineBuilder()
8
- .addExercise((it) => it
9
- .setProps({
10
- exerciseTemplateId: 'Warmup',
11
- exerciseType: 'duration',
12
- })
13
- .addDurationSet('normal', 10000))
14
- .addExercise((it) => it
15
- .setProps({
16
- exerciseTemplateId: 'Push ups',
17
- exerciseType: 'reps_only',
18
- })
19
- .addRepsSet('warmup', 5)
20
- .addRepsSet('normal', 10)
21
- .addRepsSet('normal', 10)
22
- .addRepsSet('normal', 5))
23
- .addExercise((it) => it
24
- .setProps({
25
- exerciseTemplateId: 'Pull ups',
26
- exerciseType: 'reps_only',
27
- })
28
- .addRepsSet('warmup', 5)
29
- .addRepsSet('normal', 10)
30
- .addRepsSet('normal', null) // no value in routine
31
- .addRepsSet('normal', null) // no value in routine
32
- .addRepsSet('normal', null))
33
- .addExercise((it) => it
34
- .setProps({
35
- exerciseTemplateId: 'Running',
36
- exerciseType: 'distance_duration',
37
- })
38
- .addDistanceDurationSet('normal', 3000, 1000))
39
- .addExercise((it) => it
40
- .setProps({
41
- exerciseTemplateId: 'Farmer Walk',
42
- exerciseType: 'short_distance_weight',
43
- })
44
- .addShortDistanceWeightSet('normal', 100, 100)
45
- .addShortDistanceWeightSet('normal', 200, 200))
46
- .build();
47
- /**
48
- * This workout should generate the following routine updates:
49
- * - Add a new exercise: Deadlift, after the first exercise
50
- * - Switch the order of the Pull ups and Push ups exercises
51
- * - Add a new set to the Push ups exercise, of type 'dropset'
52
- * - Delete 1 set from the Pull ups exercise
53
- * - Change the 3rd set type of Push Ups from 'normal' to 'failure'
54
- * - Update various set values in multiple exercises
55
- */
56
- const workout = new testUtils_1.WorkoutBuilder()
57
- .addExercise((it) => it
58
- .setProps({
59
- id: 'Warmup',
60
- })
61
- .addDurationSet('normal', 15000))
62
- .addExercise((it) => it
63
- .setProps({
64
- id: 'Deadlift',
65
- })
66
- .addWeightRepsSet('warmup', 10, 5)
67
- .addWeightRepsSet('normal', 10, 10)
68
- .addWeightRepsSet('normal', 10, 10, undefined, false))
69
- .addExercise((it) => it
70
- .setProps({
71
- id: 'Pull ups',
72
- })
73
- .addRepsSet('warmup', 5)
74
- .addRepsSet('normal', 10)
75
- .addRepsSet('normal', 15)
76
- .addRepsSet('normal', 0, undefined, false))
77
- .addExercise((it) => it
78
- .setProps({
79
- id: 'Push ups',
80
- })
81
- .addRepsSet('warmup', 5)
82
- .addRepsSet('normal', 10)
83
- .addRepsSet('failure', 8) // set type and value updated
84
- .addRepsSet('dropset', 10, undefined, false) // set exists in routine but isn't completed in workout
85
- .addRepsSet('dropset', 5, undefined, false))
86
- .addExercise((it) => it
87
- .setProps({
88
- id: 'Running',
89
- })
90
- .addDistanceDurationSet('normal', 3000, 1000)
91
- .addDistanceDurationSet('normal', 4000, 4000))
92
- .addExercise((it) => it
93
- .setProps({
94
- id: 'Farmer Walk',
95
- })
96
- .addShortDistanceWeightSet('normal', 300, 300)
97
- .addShortDistanceWeightSet('normal', 400, 400))
98
- .build();
99
- const routineUpdate = (0, routineUtils_1.majorRoutineUpdate)(routine, workout);
100
- const expectedRoutineUpdate = new testUtils_1.RoutineUpdateBuilder()
101
- .addExercise((it) => it
102
- .setProps({
103
- exerciseTemplateId: 'Warmup',
104
- })
105
- .addDurationSet('normal', 15000))
106
- .addExercise((it) => it
107
- .setProps({
108
- exerciseTemplateId: 'Deadlift',
109
- inputModifier: undefined,
110
- })
111
- .addWeightRepsSet('warmup', 10, 5)
112
- .addWeightRepsSet('normal', 10, 10)
113
- .addWeightRepsSet('normal', 10, 10))
114
- .addExercise((it) => it
115
- .setProps({
116
- exerciseTemplateId: 'Pull ups',
117
- inputModifier: undefined,
118
- })
119
- .addRepsSet('warmup', 5)
120
- .addRepsSet('normal', 10)
121
- .addRepsSet('normal', 15)
122
- .addRepsSet('normal', null))
123
- .addExercise((it) => it
124
- .setProps({
125
- exerciseTemplateId: 'Push ups',
126
- inputModifier: undefined,
127
- })
128
- .addRepsSet('warmup', 5)
129
- .addRepsSet('normal', 10)
130
- .addRepsSet('failure', 8)
131
- .addRepsSet('dropset', 10) // the set wasn't completed in the workout, but we should still update it
132
- .addRepsSet('dropset', 5))
133
- .addExercise((it) => it
134
- .setProps({
135
- exerciseTemplateId: 'Running',
136
- inputModifier: undefined,
137
- })
138
- .addDistanceDurationSet('normal', 3000, 1000)
139
- .addDistanceDurationSet('normal', 4000, 4000))
140
- .addExercise((it) => it
141
- .setProps({
142
- exerciseTemplateId: 'Farmer Walk',
143
- inputModifier: undefined,
144
- })
145
- .addShortDistanceWeightSet('normal', 300, 300)
146
- .addShortDistanceWeightSet('normal', 400, 400))
147
- .build();
148
- expect(routineUpdate).toEqual(expectedRoutineUpdate);
149
- });
150
- it('adds the reps value to the start of the rep range if the rep range is empty (null - null)', () => {
151
- const routine = new testUtils_1.RoutineBuilder()
152
- .addExercise((it) => it
153
- .setProps({
154
- exerciseTemplateId: 'Push ups',
155
- exerciseType: 'reps_only',
156
- inputModifier: 'rep-range',
157
- })
158
- .addRepRangeSet('normal', { start: null, end: 5 })
159
- .addRepRangeSet('normal', { start: null, end: null }))
160
- .build();
161
- const workout = new testUtils_1.WorkoutBuilder()
162
- .addExercise((it) => it
163
- .setProps({
164
- id: 'Push ups',
165
- })
166
- .addRepsSet('normal', 1)
167
- .addRepsSet('normal', 2)
168
- .addRepsSet('normal', 3))
169
- .build();
170
- const routineUpdate = (0, routineUtils_1.majorRoutineUpdate)(routine, workout);
171
- const expectedRoutineUpdate = new testUtils_1.RoutineUpdateBuilder()
172
- .addExercise((it) => it
173
- .setProps({
174
- exerciseTemplateId: 'Push ups',
175
- inputModifier: 'rep-range',
176
- })
177
- .addRepRangeSet('normal', { start: null, end: 5 })
178
- .addRepRangeSet('normal', { start: 2, end: null })
179
- .addRepRangeSet('normal', { start: 3, end: null }))
180
- .build();
181
- expect(routineUpdate).toEqual(expectedRoutineUpdate);
182
- });
183
- it('Preserves rep ranges correctly', () => {
184
- const routine = new testUtils_1.RoutineBuilder()
185
- .addExercise((it) => it
186
- .setProps({
187
- exerciseTemplateId: 'Bench Press',
188
- exerciseType: 'weight_reps',
189
- inputModifier: 'rep-range',
190
- })
191
- .addWeightRepRangeSet('normal', 71, { start: 8, end: 12 })
192
- .addWeightRepRangeSet('normal', 72, { start: null, end: null })
193
- .addWeightRepRangeSet('normal', 73, { start: 8, end: null })
194
- .addWeightRepRangeSet('normal', 74, { start: null, end: 12 }))
195
- .build();
196
- const workout = new testUtils_1.WorkoutBuilder()
197
- .addExercise((it) => it
198
- .setProps({
199
- id: 'Bench Press',
200
- })
201
- .addWeightRepsSet('normal', 61, 10)
202
- .addWeightRepsSet('normal', 62, 10)
203
- .addWeightRepsSet('normal', 63, 10)
204
- .addWeightRepsSet('normal', 64, 10)
205
- .addWeightRepsSet('normal', 65, 10))
206
- .build();
207
- const routineUpdate = (0, routineUtils_1.majorRoutineUpdate)(routine, workout);
208
- const expectedRoutineUpdate = new testUtils_1.RoutineUpdateBuilder()
209
- .addExercise((it) => it
210
- .setProps({
211
- exerciseTemplateId: 'Bench Press',
212
- inputModifier: 'rep-range',
213
- })
214
- .addWeightRepRangeSet('normal', 61, { start: 8, end: 12 })
215
- .addWeightRepRangeSet('normal', 62, { start: 10, end: null })
216
- .addWeightRepRangeSet('normal', 63, { start: 8, end: null })
217
- .addWeightRepRangeSet('normal', 64, { start: null, end: 12 })
218
- .addWeightRepRangeSet('normal', 65, { start: 10, end: null }))
219
- .build();
220
- expect(routineUpdate).toEqual(expectedRoutineUpdate);
221
- });
222
- it('Handles target rpe correctly', () => {
223
- const routine = new testUtils_1.RoutineBuilder()
224
- .addExercise((it) => it
225
- .setProps({
226
- exerciseTemplateId: 'Push ups',
227
- exerciseType: 'reps_only',
228
- })
229
- .addRepsSet('warmup', 6) // 6 reps, NO RPE
230
- .addRepsSet('normal', 7, 9) // 7 reps, 9 RPE
231
- .addRepsSet('normal', 8, 10))
232
- .build();
233
- // Add a new set to the workout, and logged the RPEs
234
- const workout = new testUtils_1.WorkoutBuilder()
235
- .addExercise((it) => it
236
- .setProps({
237
- id: 'Push ups',
238
- })
239
- .addRepsSet('warmup', 1, 7) // 1 rep, 7 RPE
240
- .addRepsSet('normal', 2) // 2 reps, NO RPE
241
- .addRepsSet('dropset', 3, 8) // 3 reps, 8 RPE
242
- .addRepsSet('failure', 4, 8.5))
243
- .build();
244
- const routineUpdate = (0, routineUtils_1.majorRoutineUpdate)(routine, workout);
245
- const expectedRoutineUpdate = new testUtils_1.RoutineUpdateBuilder()
246
- .addExercise((it) => it
247
- .setProps({
248
- exerciseTemplateId: 'Push ups',
249
- })
250
- .addRepsSet('warmup', 1) // Logged RPE is not included in the routine update
251
- .addRepsSet('normal', 2, 9)
252
- .addRepsSet('dropset', 3, 10)
253
- .addRepsSet('failure', 4))
254
- .build();
255
- expect(routineUpdate).toEqual(expectedRoutineUpdate);
256
- });
257
- it('Handles rpe, rep range and weight correctly at the same time', () => {
258
- const routine = new testUtils_1.RoutineBuilder()
259
- .addExercise((it) => it
260
- .setProps({
261
- exerciseTemplateId: 'Bench Press',
262
- exerciseType: 'weight_reps',
263
- inputModifier: 'rep-range',
264
- })
265
- .addWeightRepRangeSet('normal', 100, { start: 3, end: 5 }, 7) // 100kg, 3-5 reps, @7 RPE
266
- .addWeightRepRangeSet('normal', 100, { start: 3, end: 5 })
267
- .addWeightRepRangeSet('normal', 100, { start: null, end: 5 }, 7)
268
- .addWeightRepRangeSet('normal', 100, { start: 3, end: null }, 7)
269
- .addWeightRepRangeSet('normal', 100, { start: null, end: null }, 7)
270
- .addWeightRepRangeSet('normal', 100, { start: null, end: null })
271
- .addWeightRepRangeSet('normal', 100, { start: 5, end: 6 }, 7))
272
- .build();
273
- const workout = new testUtils_1.WorkoutBuilder()
274
- .addExercise((it) => it
275
- .setProps({
276
- id: 'Bench Press',
277
- })
278
- .addWeightRepsSet('normal', 100, 2, 10)
279
- .addWeightRepsSet('normal', 97, 3, 9)
280
- .addWeightRepsSet('normal', 95, 2, 8)
281
- .addWeightRepsSet('normal', 100, 4, 7)
282
- .addWeightRepsSet('normal', 100, 5, 6)
283
- .addWeightRepsSet('normal', 100, 6, 7.5))
284
- .build();
285
- const routineUpdate = (0, routineUtils_1.majorRoutineUpdate)(routine, workout);
286
- const expectedRoutineUpdate = new testUtils_1.RoutineUpdateBuilder()
287
- .addExercise((it) => it
288
- .setProps({
289
- exerciseTemplateId: 'Bench Press',
290
- inputModifier: 'rep-range',
291
- })
292
- .addWeightRepRangeSet('normal', 100, { start: 3, end: 5 }, 7) // 100kg, 3-5 reps, @7 RPE
293
- .addWeightRepRangeSet('normal', 97, { start: 3, end: 5 })
294
- .addWeightRepRangeSet('normal', 95, { start: null, end: 5 }, 7)
295
- .addWeightRepRangeSet('normal', 100, { start: 3, end: null }, 7)
296
- .addWeightRepRangeSet('normal', 100, { start: 5, end: null }, 7)
297
- .addWeightRepRangeSet('normal', 100, { start: 6, end: null }))
298
- .build();
299
- expect(routineUpdate).toEqual(expectedRoutineUpdate);
300
- });
301
- });
302
- describe('minorRoutineUpdate', () => {
303
- it('Calculates routine exercise set values to update after a workout', () => {
304
- const routine = new testUtils_1.RoutineBuilder()
305
- .addExercise((it) => it
306
- .setProps({
307
- exerciseTemplateId: 'a',
308
- exerciseType: 'weight_reps',
309
- supersetId: null,
310
- restSeconds: 5,
311
- })
312
- .addWeightRepsSet('warmup', 10, 10)
313
- .addWeightRepsSet('normal', 15, 10)
314
- .addWeightRepsSet('dropset', 20, 10)
315
- .addWeightRepsSet('failure', 25, 10))
316
- .addExercise((it) => it
317
- .setProps({
318
- exerciseTemplateId: 'b',
319
- exerciseType: 'weight_reps',
320
- supersetId: 0,
321
- restSeconds: 10,
322
- })
323
- .addWeightRepsSet('warmup', 20, 10)
324
- .addWeightRepsSet('normal', 25, 10)
325
- .addWeightRepsSet('normal', 30, 10)
326
- .addWeightRepsSet('normal', 35, 10))
327
- .addExercise((it) => it
328
- .setProps({
329
- exerciseTemplateId: 'c',
330
- exerciseType: 'weight_reps',
331
- supersetId: 0,
332
- restSeconds: 15,
333
- })
334
- .addWeightRepsSet('warmup', 30, 10)
335
- .addWeightRepsSet('normal', 35, 10)
336
- .addWeightRepsSet('normal', 40, 10)
337
- .addWeightRepsSet('normal', 45, 10))
338
- .build();
339
- const workout = new testUtils_1.WorkoutBuilder()
340
- .addExercise((it) => it
341
- .setProps({
342
- id: 'a',
343
- supersetId: 0,
344
- autoRestTimerSeconds: 1,
345
- })
346
- .addWeightRepsSet('warmup', 1, 2)
347
- .addWeightRepsSet('normal', 3, 4)
348
- .addWeightRepsSet('dropset', 5, 6)
349
- .addWeightRepsSet('failure', 7, 8))
350
- .addExercise((it) => it
351
- .setProps({
352
- id: 'b',
353
- supersetId: 0,
354
- autoRestTimerSeconds: undefined,
355
- })
356
- .addWeightRepsSet('warmup', 9, 10)
357
- .addWeightRepsSet('failure', 11, 12)
358
- .addWeightRepsSet('dropset', 13, 14)
359
- .addWeightRepsSet('normal', 15, 16))
360
- .addExercise((it) => it
361
- .setProps({
362
- id: 'c',
363
- supersetId: undefined,
364
- autoRestTimerSeconds: 2,
365
- })
366
- .addWeightRepsSet('warmup', 17, 18)
367
- .addWeightRepsSet('normal', 19, 20)
368
- .addWeightRepsSet('normal', 21, 22)
369
- .addWeightRepsSet('normal', 23, 24))
370
- .addExercise((it) => it
371
- .setProps({
372
- id: 'd',
373
- supersetId: undefined,
374
- autoRestTimerSeconds: undefined,
375
- })
376
- .addWeightRepsSet('warmup', 25, 26)
377
- .addWeightRepsSet('normal', 27, 28)
378
- .addWeightRepsSet('normal', 29, 30)
379
- .addWeightRepsSet('normal', 31, 32))
380
- .build();
381
- const routineUpdate = (0, routineUtils_1.minorRoutineUpdate)(routine, workout);
382
- const expectedRoutineUpdate = new testUtils_1.RoutineUpdateBuilder()
383
- .addExercise((it) => it
384
- .setProps({
385
- exerciseTemplateId: 'a',
386
- supersetId: 0,
387
- restSeconds: 1,
388
- })
389
- .addWeightRepsSet('warmup', 1, 2)
390
- .addWeightRepsSet('normal', 3, 4)
391
- .addWeightRepsSet('dropset', 5, 6)
392
- .addWeightRepsSet('failure', 7, 8))
393
- .addExercise((it) => it
394
- .setProps({
395
- exerciseTemplateId: 'b',
396
- supersetId: 0,
397
- restSeconds: undefined,
398
- })
399
- .addWeightRepsSet('warmup', 9, 10)
400
- .addWeightRepsSet('normal', 11, 12)
401
- .addWeightRepsSet('normal', 15, 16)
402
- .addWeightRepsSet('normal', 35, 10))
403
- .addExercise((it) => it
404
- .setProps({
405
- exerciseTemplateId: 'c',
406
- supersetId: undefined,
407
- restSeconds: 2,
408
- })
409
- .addWeightRepsSet('warmup', 17, 18)
410
- .addWeightRepsSet('normal', 19, 20)
411
- .addWeightRepsSet('normal', 21, 22)
412
- .addWeightRepsSet('normal', 23, 24))
413
- .build();
414
- expect(routineUpdate).toEqual(expectedRoutineUpdate);
415
- });
416
- it('Handles reordering exercises in the workout', () => {
417
- const routine = new testUtils_1.RoutineBuilder()
418
- .addExercise((it) => it
419
- .setProps({
420
- exerciseTemplateId: 'a',
421
- exerciseType: 'weight_reps',
422
- })
423
- .addWeightRepsSet('warmup')
424
- .addWeightRepsSet('normal')
425
- .addWeightRepsSet('normal')
426
- .addWeightRepsSet('normal'))
427
- .addExercise((it) => it
428
- .setProps({
429
- exerciseTemplateId: 'b',
430
- exerciseType: 'weight_reps',
431
- })
432
- .addWeightRepsSet('warmup')
433
- .addWeightRepsSet('normal')
434
- .addWeightRepsSet('normal')
435
- .addWeightRepsSet('normal'))
436
- .addExercise((it) => it
437
- .setProps({
438
- exerciseTemplateId: 'c',
439
- exerciseType: 'weight_reps',
440
- })
441
- .addWeightRepsSet('warmup')
442
- .addWeightRepsSet('normal')
443
- .addWeightRepsSet('normal')
444
- .addWeightRepsSet('normal'))
445
- .build();
446
- const workout = new testUtils_1.WorkoutBuilder()
447
- .addExercise((it) => it
448
- .setProps({
449
- id: 'b',
450
- supersetId: 0,
451
- autoRestTimerSeconds: 2,
452
- })
453
- .addWeightRepsSet('warmup', 9, 10)
454
- .addWeightRepsSet('normal', 11, 12)
455
- .addWeightRepsSet('normal', 13, 14)
456
- .addWeightRepsSet('normal', 15, 16))
457
- .addExercise((it) => it
458
- .setProps({
459
- id: 'c',
460
- supersetId: undefined,
461
- autoRestTimerSeconds: 3,
462
- })
463
- .addWeightRepsSet('warmup', 17, 18)
464
- .addWeightRepsSet('normal', 19, 20)
465
- .addWeightRepsSet('normal', 21, 22)
466
- .addWeightRepsSet('normal', 23, 24))
467
- .addExercise((it) => it
468
- .setProps({
469
- id: 'a',
470
- supersetId: 0,
471
- autoRestTimerSeconds: 1,
472
- })
473
- .addWeightRepsSet('warmup', 1, 2)
474
- .addWeightRepsSet('normal', 3, 4)
475
- .addWeightRepsSet('normal', 5, 6)
476
- .addWeightRepsSet('normal', 7, 8))
477
- .addExercise((it) => it
478
- .setProps({
479
- id: 'd',
480
- supersetId: undefined,
481
- autoRestTimerSeconds: undefined,
482
- })
483
- .addWeightRepsSet('warmup', 25, 26)
484
- .addWeightRepsSet('normal', 27, 28)
485
- .addWeightRepsSet('normal', 29, 29)
486
- .addWeightRepsSet('normal', 31, 32))
487
- .build();
488
- const routineUpdate = (0, routineUtils_1.minorRoutineUpdate)(routine, workout);
489
- const expectedRoutineUpdate = new testUtils_1.RoutineUpdateBuilder()
490
- .addExercise((it) => it
491
- .setProps({
492
- exerciseTemplateId: 'a',
493
- supersetId: 0,
494
- restSeconds: 1,
495
- })
496
- .addWeightRepsSet('warmup', 1, 2)
497
- .addWeightRepsSet('normal', 3, 4)
498
- .addWeightRepsSet('normal', 5, 6)
499
- .addWeightRepsSet('normal', 7, 8))
500
- .addExercise((it) => it
501
- .setProps({
502
- exerciseTemplateId: 'b',
503
- supersetId: 0,
504
- restSeconds: 2,
505
- })
506
- .addWeightRepsSet('warmup', 9, 10)
507
- .addWeightRepsSet('normal', 11, 12)
508
- .addWeightRepsSet('normal', 13, 14)
509
- .addWeightRepsSet('normal', 15, 16))
510
- .addExercise((it) => it
511
- .setProps({
512
- exerciseTemplateId: 'c',
513
- supersetId: undefined,
514
- restSeconds: 3,
515
- })
516
- .addWeightRepsSet('warmup', 17, 18)
517
- .addWeightRepsSet('normal', 19, 20)
518
- .addWeightRepsSet('normal', 21, 22)
519
- .addWeightRepsSet('normal', 23, 24))
520
- .build();
521
- expect(routineUpdate).toEqual(expectedRoutineUpdate);
522
- });
523
- it('Handles multiple occurrences of the same exercise', () => {
524
- const routine = new testUtils_1.RoutineBuilder()
525
- .addExercise((it) => it
526
- .setProps({
527
- exerciseTemplateId: 'a',
528
- exerciseType: 'weight_reps',
529
- })
530
- .addWeightRepsSet('warmup')
531
- .addWeightRepsSet('normal')
532
- .addWeightRepsSet('normal')
533
- .addWeightRepsSet('normal'))
534
- .addExercise((it) => it
535
- .setProps({
536
- exerciseTemplateId: 'b',
537
- exerciseType: 'weight_reps',
538
- })
539
- .addWeightRepsSet('warmup')
540
- .addWeightRepsSet('normal')
541
- .addWeightRepsSet('normal')
542
- .addWeightRepsSet('normal'))
543
- .addExercise((it) => it
544
- .setProps({
545
- exerciseTemplateId: 'a',
546
- exerciseType: 'weight_reps',
547
- })
548
- .addWeightRepsSet('warmup')
549
- .addWeightRepsSet('normal')
550
- .addWeightRepsSet('normal')
551
- .addWeightRepsSet('normal'))
552
- .build();
553
- const workout = new testUtils_1.WorkoutBuilder()
554
- .addExercise((it) => it
555
- .setProps({
556
- id: 'b',
557
- supersetId: 0,
558
- autoRestTimerSeconds: 2,
559
- })
560
- .addWeightRepsSet('warmup', 9, 10)
561
- .addWeightRepsSet('normal', 11, 12)
562
- .addWeightRepsSet('normal', 13, 14)
563
- .addWeightRepsSet('normal', 15, 16))
564
- .addExercise((it) => it
565
- .setProps({
566
- id: 'a',
567
- supersetId: undefined,
568
- autoRestTimerSeconds: 3,
569
- })
570
- .addWeightRepsSet('warmup', 1, 2)
571
- .addWeightRepsSet('normal', 3, 4)
572
- .addWeightRepsSet('normal', 5, 6)
573
- .addWeightRepsSet('normal', 7, 8))
574
- .addExercise((it) => it
575
- .setProps({
576
- id: 'a',
577
- supersetId: 0,
578
- autoRestTimerSeconds: 1,
579
- })
580
- .addWeightRepsSet('warmup', 17, 18)
581
- .addWeightRepsSet('normal', 19, 20)
582
- .addWeightRepsSet('normal', 21, 22)
583
- .addWeightRepsSet('normal', 23, 24))
584
- .addExercise((it) => it
585
- .setProps({
586
- id: 'd',
587
- supersetId: undefined,
588
- autoRestTimerSeconds: undefined,
589
- })
590
- .addWeightRepsSet('warmup', 25, 26)
591
- .addWeightRepsSet('normal', 27, 28)
592
- .addWeightRepsSet('normal', 29, 29)
593
- .addWeightRepsSet('normal', 31, 32))
594
- .build();
595
- const routineUpdate = (0, routineUtils_1.minorRoutineUpdate)(routine, workout);
596
- const expectedRoutineUpdate = new testUtils_1.RoutineUpdateBuilder()
597
- .addExercise((it) => it
598
- .setProps({
599
- exerciseTemplateId: 'a',
600
- supersetId: undefined,
601
- restSeconds: 3,
602
- })
603
- .addWeightRepsSet('warmup', 1, 2)
604
- .addWeightRepsSet('normal', 3, 4)
605
- .addWeightRepsSet('normal', 5, 6)
606
- .addWeightRepsSet('normal', 7, 8))
607
- .addExercise((it) => it
608
- .setProps({
609
- exerciseTemplateId: 'b',
610
- supersetId: 0,
611
- restSeconds: 2,
612
- })
613
- .addWeightRepsSet('warmup', 9, 10)
614
- .addWeightRepsSet('normal', 11, 12)
615
- .addWeightRepsSet('normal', 13, 14)
616
- .addWeightRepsSet('normal', 15, 16))
617
- .addExercise((it) => it
618
- .setProps({
619
- exerciseTemplateId: 'a',
620
- supersetId: 0,
621
- restSeconds: 1,
622
- })
623
- .addWeightRepsSet('warmup', 17, 18)
624
- .addWeightRepsSet('normal', 19, 20)
625
- .addWeightRepsSet('normal', 21, 22)
626
- .addWeightRepsSet('normal', 23, 24))
627
- .build();
628
- expect(routineUpdate).toEqual(expectedRoutineUpdate);
629
- });
630
- it('Handles rep ranges correctly', () => {
631
- const routine = new testUtils_1.RoutineBuilder()
632
- .addExercise((it) => it
633
- .setProps({
634
- exerciseTemplateId: 'Push ups',
635
- exerciseType: 'reps_only',
636
- inputModifier: 'rep-range',
637
- })
638
- .addRepRangeSet('normal', { start: null, end: 5 })
639
- .addRepRangeSet('normal', { start: null, end: null }) // blank to blank rep range
640
- .addRepRangeSet('normal', { start: 2, end: 2 })
641
- .addRepRangeSet('normal', { start: 3, end: 2 })
642
- .addRepRangeSet('normal', { start: null, end: 2 }))
643
- .build();
644
- const workout = new testUtils_1.WorkoutBuilder()
645
- .addExercise((it) => it
646
- .setProps({
647
- id: 'Push ups',
648
- })
649
- .addRepsSet('normal', 1)
650
- .addRepsSet('normal', 2)
651
- .addRepsSet('normal', 3))
652
- .build();
653
- const routineUpdate = (0, routineUtils_1.minorRoutineUpdate)(routine, workout);
654
- const expectedRoutineUpdate = new testUtils_1.RoutineUpdateBuilder()
655
- .addExercise((it) => it
656
- .setProps({
657
- exerciseTemplateId: 'Push ups',
658
- inputModifier: 'rep-range',
659
- })
660
- .addRepRangeSet('normal', { start: null, end: 5 })
661
- .addRepRangeSet('normal', { start: 2, end: null }) // add logged reps to the start of the rep range, if rep range is blank to blank
662
- .addRepRangeSet('normal', { start: 2, end: 2 })
663
- .addRepRangeSet('normal', { start: 3, end: 2 })
664
- .addRepRangeSet('normal', { start: null, end: 2 }))
665
- .build();
666
- expect(routineUpdate).toEqual(expectedRoutineUpdate);
667
- });
668
- it('Handles target rpe correctly', () => {
669
- const routine = new testUtils_1.RoutineBuilder()
670
- .addExercise((it) => it
671
- .setProps({
672
- exerciseTemplateId: 'Push ups',
673
- exerciseType: 'reps_only',
674
- })
675
- .addRepsSet('normal', 6) // 6 reps, NO RPE
676
- .addRepsSet('normal', 7, 9) // 7 reps, 9 RPE
677
- .addRepsSet('normal', 8, 10))
678
- .build();
679
- const workout = new testUtils_1.WorkoutBuilder()
680
- .addExercise((it) => it
681
- .setProps({
682
- id: 'Push ups',
683
- })
684
- .addRepsSet('normal', 1, 7) // 1 rep, 7 RPE
685
- .addRepsSet('normal', 2) // 2 reps, NO RPE
686
- .addRepsSet('normal', 3, 8) // 3 reps, 8 RPE
687
- .addRepsSet('normal', 4, 8.5))
688
- .build();
689
- const routineUpdate = (0, routineUtils_1.minorRoutineUpdate)(routine, workout);
690
- // Logged RPE is not included in the routine update and preserved the target RPE
691
- const expectedRoutineUpdate = new testUtils_1.RoutineUpdateBuilder()
692
- .addExercise((it) => it
693
- .setProps({
694
- exerciseTemplateId: 'Push ups',
695
- })
696
- .addRepsSet('normal', 1)
697
- .addRepsSet('normal', 2, 9)
698
- .addRepsSet('normal', 3, 10))
699
- .build();
700
- expect(routineUpdate).toEqual(expectedRoutineUpdate);
701
- });
702
- it('Handles rpe, rep range and weight correctly at the same time', () => {
703
- const routine = new testUtils_1.RoutineBuilder()
704
- .addExercise((it) => it
705
- .setProps({
706
- exerciseTemplateId: 'Bench Press',
707
- exerciseType: 'weight_reps',
708
- inputModifier: 'rep-range',
709
- })
710
- .addWeightRepRangeSet('normal', 100, { start: 3, end: 5 }, 7) // 100kg, 3-5 reps, @7 RPE
711
- .addWeightRepRangeSet('normal', 100, { start: 3, end: 5 })
712
- .addWeightRepRangeSet('normal', 100, { start: null, end: 5 }, 7)
713
- .addWeightRepRangeSet('normal', 100, { start: 3, end: null }, 7)
714
- .addWeightRepRangeSet('normal', 100, { start: null, end: null }, 7)
715
- .addWeightRepRangeSet('normal', 100, { start: null, end: null }))
716
- .build();
717
- const workout = new testUtils_1.WorkoutBuilder()
718
- .addExercise((it) => it
719
- .setProps({
720
- id: 'Bench Press',
721
- })
722
- .addWeightRepsSet('normal', 100, 2, 10)
723
- .addWeightRepsSet('normal', 97, 3, 9)
724
- .addWeightRepsSet('normal', 95, 2, 8)
725
- .addWeightRepsSet('normal', 100, 4, 7)
726
- .addWeightRepsSet('normal', 100, 5, 6)
727
- .addWeightRepsSet('normal', 100, 6, 7.5))
728
- .build();
729
- const routineUpdate = (0, routineUtils_1.minorRoutineUpdate)(routine, workout);
730
- const expectedRoutineUpdate = new testUtils_1.RoutineUpdateBuilder()
731
- .addExercise((it) => it
732
- .setProps({
733
- exerciseTemplateId: 'Bench Press',
734
- inputModifier: 'rep-range',
735
- })
736
- .addWeightRepRangeSet('normal', 100, { start: 3, end: 5 }, 7) // 100kg, 3-5 reps, @7 RPE
737
- .addWeightRepRangeSet('normal', 97, { start: 3, end: 5 })
738
- .addWeightRepRangeSet('normal', 95, { start: null, end: 5 }, 7)
739
- .addWeightRepRangeSet('normal', 100, { start: 3, end: null }, 7)
740
- .addWeightRepRangeSet('normal', 100, { start: 5, end: null }, 7)
741
- .addWeightRepRangeSet('normal', 100, { start: 6, end: null }))
742
- .build();
743
- expect(routineUpdate).toEqual(expectedRoutineUpdate);
744
- });
745
- });