Remanie /cuisiner : au lieu d'empiler toutes les phases, deux onglets (Recettes, Plan) et un stepper qui parcourt les phases une à une. Chaque tâche est cochable ; la progression est mémorisée par semaine dans localStorage — aucun état serveur, même parti pris que le reste de la page. - CookingSessionPage : barre d'onglets + PlanTab (stepper, nav précédent/suivant, clic direct sur un nœud) + RecipesTab (liste des recettes de la semaine, lien vers la fiche) - cooking-progress.ts : CookingProgressStore (load/save localStorage, clé batchcooking:cookingProgress:<semaine>) - cooking-session.ts : reconcileChecked / phaseProgress (helpers purs) - réutilise CheckboxOption pour les cartes de tâche cochables - i18n : cookingSession.tabs / stepper / progress / recipesTab - tests Cypress (mode layout + Gherkin) mis à jour et étendus Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
192 lines
6.1 KiB
TypeScript
192 lines
6.1 KiB
TypeScript
import { Given, Then, When } from "@badeball/cypress-cucumber-preprocessor";
|
|
|
|
/** Bare `IngredientView` — only `key` drives the page's `catalog.ingredients.*` lookup. */
|
|
function ingredient(key: string) {
|
|
return {
|
|
id: 1,
|
|
key,
|
|
icon: "VEGETABLE",
|
|
category: "freshProduce",
|
|
subcategory: "vegetables",
|
|
reproducible: false,
|
|
allergens: [],
|
|
diets: [],
|
|
};
|
|
}
|
|
|
|
Given(
|
|
"the planning for this week has recipes {string} and {string}",
|
|
(first: string, second: string) => {
|
|
cy.intercept("GET", /\/planning\?/, {
|
|
statusCode: 200,
|
|
body: {
|
|
id: 1,
|
|
startDate: "2026-08-17T00:00:00.000Z",
|
|
finishDate: "2026-08-23T00:00:00.000Z",
|
|
items: [
|
|
{
|
|
id: 1,
|
|
weekDay: "lundi",
|
|
meal: "dejeuner",
|
|
portions: 4,
|
|
recipe: { id: 1, name: first },
|
|
},
|
|
{ id: 2, weekDay: "mardi", meal: "diner", portions: 4, recipe: { id: 2, name: second } },
|
|
],
|
|
},
|
|
});
|
|
},
|
|
);
|
|
|
|
Given(
|
|
"the cooking plan for {string} pools {string} of {string} across both recipes",
|
|
(date: string, _techniqueLabel: string, _ingredientLabel: string) => {
|
|
// The page composes the headline itself from the technique/ingredient
|
|
// *keys* via i18n — `chop`→"Hacher", `onion`→"Oignon" — so the fixture
|
|
// carries keys; the `Then` step checks the rendered French labels the
|
|
// feature line names.
|
|
cy.intercept("GET", `**/cooking-session?date=${date}`, {
|
|
statusCode: 200,
|
|
body: {
|
|
startDate: `${date}T00:00:00.000Z`,
|
|
finishDate: "2026-08-23T00:00:00.000Z",
|
|
recipes: [
|
|
{ recipeId: 1, name: "Soupe à l'oignon", portions: 4 },
|
|
{ recipeId: 2, name: "Tarte à l'oignon", portions: 4 },
|
|
],
|
|
phases: [
|
|
{
|
|
index: 0,
|
|
kind: "mise-en-place",
|
|
background: [],
|
|
tasks: [
|
|
{
|
|
id: "prep:chop:onion",
|
|
kind: "merged-prep",
|
|
technique: { id: 1, key: "chop" },
|
|
description: null,
|
|
ingredients: [
|
|
{
|
|
ingredient: ingredient("onion"),
|
|
quantity: 5,
|
|
unit: { id: 2, key: "piece", type: "COUNT", toBaseFactor: 1 },
|
|
},
|
|
],
|
|
utensils: [],
|
|
sourceRecipes: [
|
|
{ recipeId: 1, name: "Soupe à l'oignon", portions: 4 },
|
|
{ recipeId: 2, name: "Tarte à l'oignon", portions: 4 },
|
|
],
|
|
originalSteps: [],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
});
|
|
},
|
|
);
|
|
|
|
Then(
|
|
"the pooled prep task should mention {string} and {string}",
|
|
(techniqueLabel: string, ingredientLabel: string) => {
|
|
cy.get(".cooking-task--merged-prep")
|
|
.should("contain.text", techniqueLabel)
|
|
.and("contain.text", ingredientLabel);
|
|
},
|
|
);
|
|
|
|
Then("the pooled prep task should be flagged as shared", () => {
|
|
cy.get(".cooking-task--merged-prep").contains("Mutualisé").should("be.visible");
|
|
});
|
|
|
|
Given("the cooking plan for {string} has a mise en place then a cooking step", (date: string) => {
|
|
// Two phases so the stepper actually has somewhere to step to: the
|
|
// pooled `chop onion` prep, then a `simmer` cooking step.
|
|
cy.intercept("GET", `**/cooking-session?date=${date}`, {
|
|
statusCode: 200,
|
|
body: {
|
|
startDate: `${date}T00:00:00.000Z`,
|
|
finishDate: "2026-08-23T00:00:00.000Z",
|
|
recipes: [
|
|
{ recipeId: 1, name: "Soupe à l'oignon", portions: 4 },
|
|
{ recipeId: 2, name: "Tarte à l'oignon", portions: 6 },
|
|
],
|
|
phases: [
|
|
{
|
|
index: 0,
|
|
kind: "mise-en-place",
|
|
background: [],
|
|
tasks: [
|
|
{
|
|
id: "prep:chop:onion",
|
|
kind: "merged-prep",
|
|
technique: { id: 1, key: "chop" },
|
|
description: null,
|
|
ingredients: [
|
|
{
|
|
ingredient: ingredient("onion"),
|
|
quantity: 5,
|
|
unit: { id: 2, key: "piece", type: "COUNT", toBaseFactor: 1 },
|
|
},
|
|
],
|
|
utensils: [],
|
|
sourceRecipes: [
|
|
{ recipeId: 1, name: "Soupe à l'oignon", portions: 4 },
|
|
{ recipeId: 2, name: "Tarte à l'oignon", portions: 6 },
|
|
],
|
|
originalSteps: [],
|
|
},
|
|
],
|
|
},
|
|
{
|
|
index: 1,
|
|
kind: "cooking",
|
|
background: [],
|
|
tasks: [
|
|
{
|
|
id: "step:0:1",
|
|
kind: "step",
|
|
technique: { id: 5, key: "simmer" },
|
|
description: "Faire mijoter le bouillon",
|
|
ingredients: [],
|
|
utensils: [],
|
|
sourceRecipes: [{ recipeId: 1, name: "Soupe à l'oignon", portions: 4 }],
|
|
originalSteps: [],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
});
|
|
});
|
|
|
|
When("I open the {string} cooking tab", (label: string) => {
|
|
cy.contains(".cooking-session-page__tab", label).click();
|
|
});
|
|
|
|
// The task card is a `<label>` wrapping a visually-hidden checkbox — click
|
|
// the card, same approach as common.steps.ts's "I click the radio".
|
|
When("I tick the cooking task {string}", (headline: string) => {
|
|
cy.contains(".cooking-task", headline).click();
|
|
});
|
|
|
|
Then("the cooking task {string} should be done", (headline: string) => {
|
|
cy.contains(".cooking-task", headline).should("have.class", "cooking-task--done");
|
|
});
|
|
|
|
When("I go to the next cooking step", () => {
|
|
cy.contains(".cooking-plan__nav-btn", "Étape suivante").click();
|
|
});
|
|
|
|
When("I go to the previous cooking step", () => {
|
|
cy.contains(".cooking-plan__nav-btn", "Étape précédente").click();
|
|
});
|
|
|
|
Then("the current cooking step should be {string}", (position: string) => {
|
|
cy.contains(".cooking-plan__position", position).should("be.visible");
|
|
});
|
|
|
|
Then("the recipe {string} should link to {string}", (name: string, href: string) => {
|
|
cy.contains(".cooking-recipes__item", name).find("a").should("have.attr", "href", href);
|
|
});
|