Matériel coché dans le profil, bibliothèque « ce que mon matériel permet » (5a)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
938d6cf198
commit
72adffb613
@@ -292,9 +292,14 @@ function check(scheme, cond, msg) {
|
||||
// ---- profil et mode ----------------------------------------------------------------
|
||||
await go("#/profil");
|
||||
await page.getByLabel("Objectif").fill("Prendre de la force sans me blesser");
|
||||
await page.getByLabel("Matériel").fill("Barre\nBanc\nHaltères");
|
||||
ok(await page.getByText("Pas encore renseigné").isVisible(), "matériel : pas encore renseigné");
|
||||
await button("Salle complète").click();
|
||||
await button("Barre de traction").click();
|
||||
ok(await button("Barre de traction").getAttribute("aria-pressed") === "false" && await button("Banc", { exact: true }).getAttribute("aria-pressed") === "true", "matériel coché : salle complète sans barre de traction");
|
||||
await page.getByLabel("Autre matériel").fill("Haltères jusqu'à 30 kg");
|
||||
await button("Enregistrer le profil").click();
|
||||
ok(await page.getByText("Profil enregistré.").isVisible(), "profil enregistré");
|
||||
ok(await page.evaluate(async () => (await import("./main.js")).store.getState().profile.kit?.includes("pullup-bar")) === false, "matériel gardé dans le profil");
|
||||
await button("Maintien").click();
|
||||
ok(await button("Maintien").getAttribute("aria-pressed") === "true", "mode maintien");
|
||||
await shot("11-profil", true);
|
||||
@@ -349,6 +354,15 @@ function check(scheme, cond, msg) {
|
||||
await page.goBack();
|
||||
await settle();
|
||||
ok(page.url().endsWith("?q=pont&zone=lower&muscle=glutes"), "retour : la liste filtrée");
|
||||
// Matériel coché (lot 5a) : sans barre de traction, plus de tractions.
|
||||
await go("#/bibliotheque?q=traction");
|
||||
const before = await page.locator(".lib-results .row").count();
|
||||
await button("Seulement ce que mon matériel permet").click();
|
||||
await page.waitForTimeout(200);
|
||||
ok(page.url().endsWith("#/bibliotheque?q=traction&possible=1"), "« ce que mon matériel permet » dans l'adresse : " + page.url().split("#")[1]);
|
||||
ok(await page.locator(".lib-results .row").count() < before && await page.getByRole("link", { name: /^Traction/ }).count() === 0, "sans barre de traction : plus de tractions");
|
||||
await go("#/bibliotheque/pull-up");
|
||||
ok(await page.getByText("Il te manque : barre de traction.").isVisible(), "fiche : le matériel qui manque");
|
||||
await go("#/bibliotheque/squat");
|
||||
ok(await page.getByText(/Fait \d+ fois/).isVisible(), "fiche du squat : historique et lien vers les analyses");
|
||||
await button(/Demander à mon IA/).click();
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
// Le matériel coché (lot 5a) : ce que demande chaque exercice, ce qui manque,
|
||||
// le profil, la bibliothèque et le texte pour l'IA. Glossaire : docs/glossaire/materiel.md
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { EXERCISES } from "../../app/domain/exercises.js";
|
||||
import { KIT, canDo, isKit, kitLabels, missingKit, requiredKit } from "../../app/domain/kit.js";
|
||||
import { DEFAULT_PROFILE, validateProfile } from "../../app/domain/profile.js";
|
||||
import { filterLibrary, formatCriteria, parseCriteria } from "../../app/domain/library.js";
|
||||
import { buildEvolutionBrief, buildOnboardingBrief } from "../../app/domain/ai-brief.js";
|
||||
import { createEvent } from "../../app/domain/events.js";
|
||||
import { foldEvents } from "../../app/domain/state.js";
|
||||
import { profileFromForm } from "../../app/ui/screens/profile.js";
|
||||
|
||||
test("chaque exercice demande du matériel connu ; la catégorie et les exceptions s'additionnent", () => {
|
||||
for (const ref of Object.keys(EXERCISES)) for (const k of requiredKit(ref)) assert.ok(isKit(k), `${ref} : ${k}`);
|
||||
assert.deepEqual(requiredKit("bench-press").sort(), ["barbell", "bench", "rack"]);
|
||||
assert.deepEqual(requiredKit("pull-up"), ["pullup-bar"]);
|
||||
assert.deepEqual(requiredKit("push-up"), []);
|
||||
assert.deepEqual(requiredKit("rowing-machine"), ["rower"]);
|
||||
assert.deepEqual(requiredKit("inconnu"), [], "hors bibliothèque : on ne sait pas, rien n'est exigé");
|
||||
// Tout ce qui n'est pas au poids du corps demande quelque chose.
|
||||
for (const [ref, x] of Object.entries(EXERCISES))
|
||||
if (x.equipment !== "bodyweight") assert.ok(requiredKit(ref).length > 0, `${ref} (${x.equipment}) ne demande rien`);
|
||||
});
|
||||
|
||||
test("ce qui manque : rien tant que le matériel n'est pas renseigné", () => {
|
||||
assert.deepEqual(missingKit("bench-press", undefined), []);
|
||||
assert.deepEqual(missingKit("bench-press", ["barbell", "bench"]), ["rack"]);
|
||||
assert.equal(canDo("bench-press", ["barbell", "bench", "rack"]), true);
|
||||
assert.equal(canDo("push-up", []), true);
|
||||
assert.deepEqual(kitLabels(["bench", "barbell"]), ["Barre et disques", "Banc"], "dans l'ordre de KIT");
|
||||
});
|
||||
|
||||
test("profil : kit facultatif, clés connues, sans doublon", () => {
|
||||
assert.deepEqual(validateProfile(DEFAULT_PROFILE), []);
|
||||
assert.deepEqual(validateProfile({ ...DEFAULT_PROFILE, kit: ["barbell", "rack"] }), []);
|
||||
assert.deepEqual(validateProfile({ ...DEFAULT_PROFILE, kit: [] }), []);
|
||||
assert.match(validateProfile({ ...DEFAULT_PROFILE, kit: ["trampoline"] })[0], /'kit'/);
|
||||
assert.match(validateProfile({ ...DEFAULT_PROFILE, kit: ["bench", "bench"] })[0], /'kit'/);
|
||||
});
|
||||
|
||||
test("formulaire du profil : kit omis s'il n'a jamais été renseigné, dans l'ordre de KIT sinon", () => {
|
||||
const form = { goal: "", context: "", equipment: "", constraints: "", heightCm: "", sessionMinutes: "50" };
|
||||
assert.equal("kit" in profileFromForm(form).profile, false);
|
||||
assert.deepEqual(profileFromForm({ ...form, kit: ["bench", "barbell"] }).profile.kit, ["barbell", "bench"]);
|
||||
assert.deepEqual(profileFromForm({ ...form, kit: [] }).profile.kit, []);
|
||||
});
|
||||
|
||||
test("bibliothèque : « ce que mon matériel permet », gardé dans l'adresse", () => {
|
||||
assert.deepEqual(parseCriteria("possible=1"), { possible: true });
|
||||
assert.equal(formatCriteria({ possible: true, zone: "upper" }), "zone=upper&possible=1");
|
||||
const refs = (/** @type {any} */ c, /** @type {string[]|undefined} */ kit) => filterLibrary(c, kit).flatMap((g) => g.items.map((i) => i.ref));
|
||||
const bodyweight = refs({ possible: true }, []);
|
||||
assert.ok(bodyweight.includes("push-up") && !bodyweight.includes("pull-up") && !bodyweight.includes("squat"));
|
||||
assert.ok(refs({ possible: true }, ["pullup-bar"]).includes("pull-up"));
|
||||
assert.equal(refs({ possible: true }, undefined).length, Object.keys(EXERCISES).length, "matériel non renseigné : tout");
|
||||
});
|
||||
|
||||
test("texte pour l'IA : le format du profil liste les clés, le profil montre le matériel coché", () => {
|
||||
assert.match(buildOnboardingBrief({ baseUrl: "https://ia-fit.example" }), /kit\?: \[matériel coché, parmi "barbell", "rack"/);
|
||||
const profile = { ...DEFAULT_PROFILE, kit: /** @type {any} */ (["barbell", "bench"]) };
|
||||
const s = foldEvents([createEvent("ProfileUpdated", { profile }, { device: "d", at: "2026-11-01T10:00:00.000Z" })]);
|
||||
assert.match(buildEvolutionBrief(s, { today: "2026-11-02", baseUrl: "https://ia-fit.example" }), /Matériel coché : Barre et disques, Banc/);
|
||||
assert.match(buildEvolutionBrief(foldEvents([]), { today: "2026-11-02", baseUrl: "https://ia-fit.example" }), /Matériel coché : non renseigné/);
|
||||
assert.equal(Object.keys(KIT).length >= 20, true);
|
||||
});
|
||||
Reference in New Issue
Block a user