diff --git a/apps/web/cypress/e2e/planning.feature b/apps/web/cypress/e2e/planning.feature index 215bcef..3b3b30a 100644 --- a/apps/web/cypress/e2e/planning.feature +++ b/apps/web/cypress/e2e/planning.feature @@ -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 And the URL should be the home page 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 diff --git a/apps/web/cypress/e2e/planning.ts b/apps/web/cypress/e2e/planning.ts index 8a4505f..dd078bb 100644 --- a/apps/web/cypress/e2e/planning.ts +++ b/apps/web/cypress/e2e/planning.ts @@ -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 // recipe-sources.ts's fixtures rather than importing them. -// Both flip once, from `false` to `true`, as the single scenario in this -// file actually performs the import and the planning-add — module-level -// `let` rather than something reset per-scenario, since there's only ever -// the one here (see household-settings.ts for the same pattern used across -// several scenarios instead). -let fishPieImported = false; +// Flips once, from `false` to `true`, as the single scenario in this file +// actually performs the planning-add — module-level `let` rather than +// something reset per-scenario, since there's only ever the one here (see +// household-settings.ts for the same pattern used across several scenarios +// instead). let fishPiePlanned = false; Given("the recipe catalog contains nothing", () => { @@ -29,36 +28,30 @@ Given("the household has enabled TheMealDB", () => { 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", () => { - cy.intercept("GET", "**/sources/theMealDb/browse*", (req) => { - req.reply({ - statusCode: 200, - body: { - items: [ - { - externalId: "52795", - title: "Chicken Handi", - picture: null, - url: "https://www.themealdb.com/meal/52795", - alreadyImported: true, - recipeId: 2, - }, - { - externalId: "9999", - title: "Fish Pie", - picture: null, - url: "https://www.themealdb.com/meal/9999", - alreadyImported: fishPieImported, - recipeId: fishPieImported ? 99 : null, - }, - ], - nextCursor: null, - }, - }); + cy.intercept("GET", "**/sources/theMealDb/browse*", { + statusCode: 200, + body: { + items: [ + { + externalId: "52795", + title: "Chicken Handi", + picture: null, + url: "https://www.themealdb.com/meal/52795", + alreadyImported: true, + recipeId: 2, + }, + { + externalId: "9999", + title: "Fish Pie", + picture: null, + url: "https://www.themealdb.com/meal/9999", + alreadyImported: false, + recipeId: null, + }, + ], + nextCursor: null, + }, }); }); @@ -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) => { - cy.intercept("POST", "**/sources/theMealDb/import/9999", (req) => { - fishPieImported = true; - req.reply({ statusCode: 201, body: { id } }); + cy.intercept("POST", "**/sources/theMealDb/import/9999", { + statusCode: 201, + body: { id }, }).as("importRecipe"); }); @@ -156,8 +149,7 @@ Given("adding the imported recipe to the planning will succeed", () => { }).as("addPlanningItem"); }); -// Stateful for the same reason as "browsing TheMealDB returns some items" -// above — landing back on "/" after the import journey remounts +// Stateful — landing back on "/" after the import journey remounts // `PlanningPage` from scratch (a real cross-route navigation, not a // same-component state update: see `ImportRecipePage`'s `navigate("/")`), // 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(); }); -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( "the planning add request should have included recipe {int}, weekDay {string}, meal {string}, and portions {int}", (recipeId: number, weekDay: string, meal: string, portions: number) => {