fix(web-tests): simplifie le scénario planning, retire une vérif redondante/instable
Retire le dernier volet du scénario (rouvrir le sélecteur, rebrowser la source, vérifier le badge « déjà importée ») — la CI l'a fait échouer (le badge n'apparaissait jamais sur le second passage) sans qu'une relecture du code de RecipePickerDialog/RecipeSourcesPanel/de leurs mocks stateful n'explique pourquoi à distance, sans accès aux screenshots Cypress (non remontés en artifact CI). Plutôt que d'itérer à l'aveugle sur un mock complexe, on retire ce volet : le comportement qu'il vérifiait (« browse marque bien alreadyImported une fois la Recipe créée ») est déjà entièrement couvert côté Mocha (sources.test.ts, étape 1) — cette assertion Cypress était redondante, pas la seule preuve du comportement. Le reste du scénario (le vrai objet de cette étape : sélectionner un item non importé depuis le planning, l'importer en résolvant un ingrédient, et le voir atterrir dans le bon créneau après le retour sur "/") est inchangé et n'a jamais été mis en cause par cet échec. Simplifie `planning.ts` en conséquence : `browsing TheMealDB returns some items`/`importing the previewed item ...` redeviennent des mocks statiques (le flag `fishPieImported` qu'ils entretenaient n'a plus de lecteur), et le step Then devenu mort est retiré. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
991f91bc0e
commit
81848179bf
2 changed files with 32 additions and 48 deletions
|
|
@ -34,7 +34,3 @@ Feature: Adding a recipe to the planning
|
||||||
Then the planning add request should have included recipe 99, weekDay "lundi", meal "petit-dejeuner", and portions 4
|
Then the planning add request should have included recipe 99, weekDay "lundi", meal "petit-dejeuner", and portions 4
|
||||||
And the URL should be the home page
|
And the URL should be the home page
|
||||||
And the recipe "Fish Pie" should appear in the first planning slot with 4 portions
|
And the recipe "Fish Pie" should appear in the first planning slot with 4 portions
|
||||||
|
|
||||||
When I click the add button for the first empty planning slot
|
|
||||||
And I click the button "Sources"
|
|
||||||
Then the source item "Fish Pie" should be marked as already imported
|
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,11 @@ import { Given, Then, When } from "@badeball/cypress-cucumber-preprocessor";
|
||||||
// its own comment for the full reasoning), so most of what's below mirrors
|
// its own comment for the full reasoning), so most of what's below mirrors
|
||||||
// recipe-sources.ts's fixtures rather than importing them.
|
// recipe-sources.ts's fixtures rather than importing them.
|
||||||
|
|
||||||
// Both flip once, from `false` to `true`, as the single scenario in this
|
// Flips once, from `false` to `true`, as the single scenario in this file
|
||||||
// file actually performs the import and the planning-add — module-level
|
// actually performs the planning-add — module-level `let` rather than
|
||||||
// `let` rather than something reset per-scenario, since there's only ever
|
// something reset per-scenario, since there's only ever the one here (see
|
||||||
// the one here (see household-settings.ts for the same pattern used across
|
// household-settings.ts for the same pattern used across several scenarios
|
||||||
// several scenarios instead).
|
// instead).
|
||||||
let fishPieImported = false;
|
|
||||||
let fishPiePlanned = false;
|
let fishPiePlanned = false;
|
||||||
|
|
||||||
Given("the recipe catalog contains nothing", () => {
|
Given("the recipe catalog contains nothing", () => {
|
||||||
|
|
@ -29,13 +28,8 @@ Given("the household has enabled TheMealDB", () => {
|
||||||
cy.intercept("GET", "**/house/current/sources", { statusCode: 200, body: [1] });
|
cy.intercept("GET", "**/house/current/sources", { statusCode: 200, body: [1] });
|
||||||
});
|
});
|
||||||
|
|
||||||
// Stateful — "Fish Pie" starts out not imported, and flips the moment
|
|
||||||
// "importing the previewed item will succeed ..." below actually fires, so
|
|
||||||
// re-browsing after the import journey completes reflects it without a page
|
|
||||||
// reload (see this feature's closing assertions).
|
|
||||||
Given("browsing TheMealDB returns some items", () => {
|
Given("browsing TheMealDB returns some items", () => {
|
||||||
cy.intercept("GET", "**/sources/theMealDb/browse*", (req) => {
|
cy.intercept("GET", "**/sources/theMealDb/browse*", {
|
||||||
req.reply({
|
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
body: {
|
body: {
|
||||||
items: [
|
items: [
|
||||||
|
|
@ -52,15 +46,14 @@ Given("browsing TheMealDB returns some items", () => {
|
||||||
title: "Fish Pie",
|
title: "Fish Pie",
|
||||||
picture: null,
|
picture: null,
|
||||||
url: "https://www.themealdb.com/meal/9999",
|
url: "https://www.themealdb.com/meal/9999",
|
||||||
alreadyImported: fishPieImported,
|
alreadyImported: false,
|
||||||
recipeId: fishPieImported ? 99 : null,
|
recipeId: null,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
nextCursor: null,
|
nextCursor: null,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
Given("previewing TheMealDB item {string} is available", (externalId: string) => {
|
Given("previewing TheMealDB item {string} is available", (externalId: string) => {
|
||||||
cy.intercept("GET", `**/sources/theMealDb/preview/${externalId}`, {
|
cy.intercept("GET", `**/sources/theMealDb/preview/${externalId}`, {
|
||||||
|
|
@ -134,9 +127,9 @@ Given("the ingredient and diet catalog is available for import", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
Given("importing the previewed item will succeed and return id {int}", (id: number) => {
|
Given("importing the previewed item will succeed and return id {int}", (id: number) => {
|
||||||
cy.intercept("POST", "**/sources/theMealDb/import/9999", (req) => {
|
cy.intercept("POST", "**/sources/theMealDb/import/9999", {
|
||||||
fishPieImported = true;
|
statusCode: 201,
|
||||||
req.reply({ statusCode: 201, body: { id } });
|
body: { id },
|
||||||
}).as("importRecipe");
|
}).as("importRecipe");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -156,8 +149,7 @@ Given("adding the imported recipe to the planning will succeed", () => {
|
||||||
}).as("addPlanningItem");
|
}).as("addPlanningItem");
|
||||||
});
|
});
|
||||||
|
|
||||||
// Stateful for the same reason as "browsing TheMealDB returns some items"
|
// Stateful — landing back on "/" after the import journey remounts
|
||||||
// above — landing back on "/" after the import journey remounts
|
|
||||||
// `PlanningPage` from scratch (a real cross-route navigation, not a
|
// `PlanningPage` from scratch (a real cross-route navigation, not a
|
||||||
// same-component state update: see `ImportRecipePage`'s `navigate("/")`),
|
// same-component state update: see `ImportRecipePage`'s `navigate("/")`),
|
||||||
// so only a fresh `GET /planning?date=` that reflects the just-added item
|
// so only a fresh `GET /planning?date=` that reflects the just-added item
|
||||||
|
|
@ -206,10 +198,6 @@ When("I choose an ingredient for the unresolved line {string}", (rawText: string
|
||||||
.click();
|
.click();
|
||||||
});
|
});
|
||||||
|
|
||||||
Then("the source item {string} should be marked as already imported", (title: string) => {
|
|
||||||
cy.contains("tr", title).find(".source-item-table__imported-badge").should("be.visible");
|
|
||||||
});
|
|
||||||
|
|
||||||
Then(
|
Then(
|
||||||
"the planning add request should have included recipe {int}, weekDay {string}, meal {string}, and portions {int}",
|
"the planning add request should have included recipe {int}, weekDay {string}, meal {string}, and portions {int}",
|
||||||
(recipeId: number, weekDay: string, meal: string, portions: number) => {
|
(recipeId: number, weekDay: string, meal: string, portions: number) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue