Format WOD étendu : EMOM « tout à chaque intervalle », repos entre les tours ; Chelsea et Barbara (4e)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
db0b6f954c
commit
7678e580b7
@@ -570,6 +570,27 @@ function check(scheme, cond, msg) {
|
||||
ok(await button("Reprendre ce WOD").isVisible(), "pas de doublon : le WOD en attente est repris");
|
||||
await page.evaluate(() => localStorage.removeItem("ia-fit.draft"));
|
||||
|
||||
// ---- format étendu (lot 4e) : Barbara, repos entre les tours ; Chelsea, tout à chaque minute ----
|
||||
await go("#/wod/chelsea");
|
||||
ok(await page.locator(".wod-format__label").textContent() === "EMOM 30 min · tout à chaque intervalle", "Chelsea : tout à chaque intervalle");
|
||||
await go("#/wod/barbara");
|
||||
await button("Faire aujourd'hui").click();
|
||||
await settle();
|
||||
ok(await page.locator(".wod-format__label").textContent() === "5 tours · repos 3:00", "Barbara : la séance s'ouvre");
|
||||
await button("Démarrer").click();
|
||||
await page.clock.fastForward(5000 + 30000);
|
||||
await page.waitForTimeout(300);
|
||||
ok(await page.locator(".wod-clock__phase").textContent() === "Tour 1/5", "Barbara : tour 1");
|
||||
await button("Tour fini").click();
|
||||
await page.waitForTimeout(300);
|
||||
ok(await page.locator(".wod-clock__phase").textContent() === "Repos · puis tour 2/5" && /^[23]:\d\d$/.test(await page.locator(".wod-clock__time").textContent() ?? ""), "Barbara : repos de 3 min, le chrono descend");
|
||||
await shot("24b-barbara");
|
||||
await page.clock.fastForward(181000);
|
||||
await page.waitForTimeout(300);
|
||||
ok(await page.locator(".wod-clock__phase").textContent() === "Tour 2/5", "Barbara : tour 2 après le repos");
|
||||
ok(/^0:3\d$/.test(await page.locator(".wod-clock__time").textContent() ?? ""), "Barbara : le repos ne compte pas dans le temps");
|
||||
await page.evaluate(() => localStorage.removeItem("ia-fit.draft"));
|
||||
|
||||
// ---- réinitialisation --------------------------------------------------------------
|
||||
await go("#/donnees");
|
||||
await button("Tout effacer").click();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { compareScores, wodKey, clockText, currentMovement, formatLabel, formatSeconds, parseClock, scoreLabel, validateFormat, wodClock, wodResultProblem } from "../../app/domain/wod.js";
|
||||
import { compareScores, wodKey, clockText, currentMovement, formatHint, formatLabel, formatSeconds, movesInTurn, parseClock, scoreFields, scoreLabel, validateFormat, wodClock, wodResultProblem } from "../../app/domain/wod.js";
|
||||
import { phaseText } from "../../app/ui/wod-panel.js";
|
||||
import { validateProgram } from "../../app/domain/program.js";
|
||||
import { estimatedMinutes } from "../../app/domain/progression.js";
|
||||
import { buildOnboardingBrief } from "../../app/domain/ai-brief.js";
|
||||
@@ -79,3 +80,35 @@ test("comparer deux scores : RX d'abord, puis selon le format", () => {
|
||||
assert.equal(compareScores(r({ format: am, rounds: 14, reps: 3 }), r({ format: am, rounds: 14, reps: 3 })), 0);
|
||||
assert.equal(wodKey(" Frân ", { type: "fortime" }), "fran|fortime");
|
||||
});
|
||||
|
||||
test("EMOM « tout à chaque intervalle » (Chelsea) : tous les mouvements, score en intervalles réussis", () => {
|
||||
const f = /** @type {const} */ ({ type: "emom", minutes: 30, all: true });
|
||||
assert.deepEqual(validateFormat(f, "W"), []);
|
||||
assert.match(validateFormat({ type: "emom", minutes: 30, all: "oui" }, "W")[0], /'format.all' doit valoir true ou false/);
|
||||
assert.equal(formatLabel(f), "EMOM 30 min · tout à chaque intervalle");
|
||||
assert.match(formatHint(f), /fais tous les mouvements/);
|
||||
assert.equal(movesInTurn(f), false);
|
||||
assert.equal(movesInTurn({ type: "emom", minutes: 10 }), true);
|
||||
assert.deepEqual(scoreFields(f), { seconds: false, rounds: true, reps: false });
|
||||
const r = (/** @type {number} */ rounds) => ({ format: f, rx: true, seconds: null, rounds, reps: null, kg: null, capped: false });
|
||||
assert.equal(scoreLabel(r(28)), "28 intervalles · RX");
|
||||
assert.ok(compareScores(r(30), r(28)) < 0);
|
||||
});
|
||||
|
||||
test("tours avec repos entre deux (Barbara) : effort, repos, tour suivant ; le repos ne compte pas", () => {
|
||||
const f = /** @type {const} */ ({ type: "rounds", rounds: 3, rest: 180 });
|
||||
assert.deepEqual(validateFormat(f, "W"), []);
|
||||
assert.match(validateFormat({ type: "rounds", rounds: 3, rest: 2000 }, "W")[0], /'format.rest'/);
|
||||
assert.equal(formatLabel(f), "3 tours · repos 3:00");
|
||||
assert.equal(formatLabel({ type: "rounds", rounds: 3 }), "3 tours", "sans repos, comme avant");
|
||||
assert.deepEqual(wodClock(f, 100), { phase: "work", round: 1, rounds: 3, remaining: null, elapsed: 100 });
|
||||
// tour 1 fini à 240 s : repos jusqu'à 420 s
|
||||
assert.deepEqual(wodClock(f, 300, [240]), { phase: "rest", round: 2, rounds: 3, remaining: 120, elapsed: 240 });
|
||||
assert.deepEqual(wodClock(f, 500, [240]), { phase: "work", round: 2, rounds: 3, remaining: null, elapsed: 240 + 80 });
|
||||
// tour 2 fini à 700 s (280 s d'effort), tour 3 fini à 1150 s (270 s d'effort)
|
||||
assert.deepEqual(wodClock(f, 1150, [240, 700, 1150]), { phase: "done", round: 3, rounds: 3, remaining: 0, elapsed: 240 + 280 + 270 });
|
||||
assert.equal(phaseText(f, wodClock(f, 300, [240])), "Repos · puis tour 2/3");
|
||||
assert.equal(phaseText(f, wodClock(f, 500, [240])), "Tour 2/3");
|
||||
// Le Tabata garde son repos par défaut de 10 s.
|
||||
assert.equal(formatLabel({ type: "tabata" }), "Tabata 8 × 20 s / 10 s");
|
||||
});
|
||||
|
||||
@@ -254,7 +254,7 @@ test("séance WOD : horloge calée sur l'heure, score exigé selon le format, Se
|
||||
const state = foldEvents([createEvent("ProgramAdopted", { program, source: "ai" }, { device, at: "2026-11-01T10:00:00.000Z" })]);
|
||||
const d = createDraft(W, state, "2026-11-18", 0);
|
||||
const w = /** @type {NonNullable<typeof d.wod>} */ (d.wod);
|
||||
assert.deepEqual(w, { format: W.format, startedAt: null, banked: 0, rx: true, seconds: null, rounds: null, reps: null, kg: null, capped: false });
|
||||
assert.deepEqual(w, { format: W.format, startedAt: null, banked: 0, rx: true, seconds: null, rounds: null, reps: null, kg: null, capped: false, marks: [] });
|
||||
assert.ok(!draftMatches(structuredClone(d), A, 0), "pas pour une autre séance");
|
||||
assert.ok(draftMatches(structuredClone(d), W, 0));
|
||||
assert.ok(!draftMatches({ ...structuredClone(d), wod: undefined }, W, 0), "un brouillon sans WOD n'est pas repris");
|
||||
|
||||
Reference in New Issue
Block a user