WOD ponctuel proposé par l'IA et records par WOD (lot 4c)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
06bd91d797
commit
7dc106837b
@@ -101,3 +101,23 @@ test("trackingFor : choix de l'utilisateur, puis programme, puis déduction", ()
|
||||
assert.equal(targetSeconds("8 squats"), null);
|
||||
assert.equal(exerciseKey("A", { ref: "squat", sets: 4, reps: "8", rest: 120 }), "A-squat");
|
||||
});
|
||||
|
||||
test("séances ponctuelles : hors rotation, en attente tant qu'elles ne sont pas faites, retirées une fois faites", async () => {
|
||||
const { rotationSessions, pendingOneOffs, withOneOff } = await import("../../app/domain/program.js");
|
||||
const wod = { name: "Cindy", format: /** @type {const} */ ({ type: "amrap", minutes: 20 }), exercises: [{ ref: "push-up", sets: 1, reps: "10", rest: 0 }] };
|
||||
const logged = [{ kind: "strength", ref: "A" }];
|
||||
const first = withOneOff(EXAMPLE_PROGRAM, wod, logged);
|
||||
assert.equal(first.key, "J1");
|
||||
assert.deepEqual(validateProgram(first.program), []);
|
||||
assert.deepEqual(rotationSessions(first.program).map((s) => s.key), EXAMPLE_PROGRAM.sessions.map((s) => s.key));
|
||||
assert.deepEqual(pendingOneOffs(first.program, logged).map((s) => s.key), ["J1"]);
|
||||
const done = [...logged, { kind: "strength", ref: "J1" }];
|
||||
assert.deepEqual(pendingOneOffs(first.program, done), []);
|
||||
const second = withOneOff(first.program, wod, done);
|
||||
assert.equal(second.key, "J2");
|
||||
assert.deepEqual(second.program.sessions.filter((s) => s.oneOff).map((s) => s.key), ["J2"], "J1, faite, est retirée");
|
||||
assert.equal(EXAMPLE_PROGRAM.sessions.some((s) => s.oneOff), false, "l'original n'est pas touché");
|
||||
const bad = structuredClone(first.program);
|
||||
/** @type {any} */ (bad.sessions.at(-1)).oneOff = "oui";
|
||||
assert.match(validateProgram(bad)[0], /'oneOff' doit valoir true ou false/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user