import { Given, Then } from "@badeball/cypress-cucumber-preprocessor";

// Shared across preferences.feature (dedicated autosave scenarios) and
// onboarding.feature (regime/allergies steps of the wizard) — both need the
// same diet/allergies PATCH mocks and their request-body assertions.

Given("selecting the diet will succeed", () => {
  cy.intercept("PATCH", "**/profile/diet", { statusCode: 200, body: { dietId: 1 } }).as(
    "updateDiet",
  );
});

Then("the diet update request should have been made with diet id {int}", (dietId: number) => {
  cy.wait("@updateDiet").its("request.body").should("deep.equal", { dietId });
});

Given("updating allergies will succeed", () => {
  cy.intercept("PATCH", "**/profile/allergies", { statusCode: 200, body: [2, 1] }).as(
    "updateAllergies",
  );
});
