import { Given, Then } from "@badeball/cypress-cucumber-preprocessor"; const signupResponse = { id: 1, firstName: "Alice", lastName: "Martin", email: "alice@example.com", tokenVersion: 0, houseId: null as number | null, dietId: null, }; Given("the diets reference list has options", () => { cy.intercept("GET", "**/reference/diets", { statusCode: 200, body: [ { id: 1, key: "omnivore" }, { id: 2, key: "vegetarian" }, ], }); }); Given("the allergies reference list has options", () => { cy.intercept("GET", "**/reference/allergies", { statusCode: 200, body: [ { id: 1, key: "peanuts", kind: "ALLERGY" }, { id: 2, key: "gluten", kind: "INTOLERANCE" }, ], }); }); Given("the allergies reference list is empty", () => { cy.intercept("GET", "**/reference/allergies", { statusCode: 200, body: [] }); }); // Signs up and lands on the wizard's first step (regime) — shared setup for // every scenario in this feature, mirroring `signupAndReachOnboarding` from // the pre-conversion spec. Given("I have signed up", () => { cy.intercept("GET", "**/auth/me", { statusCode: 401 }); cy.intercept("POST", "**/auth/signup", { statusCode: 201, body: signupResponse }).as("signup"); cy.visit("/signup"); cy.get("#firstName").type("Alice"); cy.get("#lastName").type("Martin"); cy.get("#email").type("alice@example.com"); cy.get("#password").type("correct-horse-battery-staple"); cy.contains("button", "Créer mon profil").click(); cy.wait("@signup"); }); Then("the diet update request should have been made with no diet id", () => { cy.wait("@updateDiet").its("request.body").should("deep.equal", { dietId: null }); }); Then("the allergies update request should have been made with allergy id {int}", (id: number) => { cy.wait("@updateAllergies") .its("request.body") .should("deep.equal", { allergyIds: [id] }); }); Then("the allergies update request should have been made with no allergy ids", () => { cy.wait("@updateAllergies").its("request.body").should("deep.equal", { allergyIds: [] }); });