La CI de la refonte précédente (commitaaace15) a échoué : la découverte par défaut du préprocesseur ne charge, pour un fichier `foo.feature`, QUE `foo.ts` (co-localisé, même basename) et `cypress/support/step_definitions/**` — pas les autres `.ts` du dossier `cypress/e2e/`. onboarding.feature référençait donc des steps qui ne vivaient que dans preferences.ts, household-settings.ts et auth.ts, introuvables lors de son propre run. Déplace les steps réellement partagés entre plusieurs .feature vers cypress/support/step_definitions/ (chargé pour toutes les features) : - reference-data.steps.ts : mocks des listes de référence régimes/ allergies (options ou vides) — partagé entre auth.feature et onboarding.feature - household-mutations.steps.ts : création/adhésion à un foyer et leurs assertions — partagé entre household-settings.feature et onboarding.feature - profile-mutations.steps.ts : sélection du régime, mise à jour des allergies et leur assertion — partagé entre preferences.feature et onboarding.feature Les définitions d'origine sont retirées de auth.ts/household- settings.ts/onboarding.ts/preferences.ts pour éviter un step "Ambiguous" (chargé deux fois pour la feature qui les définissait déjà elle-même). Corrige aussi un second bug distinct révélé par la même CI : "the ingredient/diet catalog is available" (recipe-form.feature) contient un "/" non échappé — en syntaxe Cucumber Expression, "/" hors d'un paramètre {..} signifie une alternative de texte ("ingredient" OU "diet catalog is available"), jamais le caractère littéral. Le texte du .feature ne pouvait donc jamais matcher. Renommé sans "/" : "the ingredient and diet catalog is available". Le script de vérification statique utilisé pour valideraaace15avant push donnait une fausse confiance : il regroupait tous les steps de tous les fichiers comme disponibles globalement pour chaque feature, sans respecter ce scoping réel. Réécrit pour ne charger, par feature, que son fichier co-localisé + step_definitions/ — et pour détecter les patterns contenant un "/" non échappé. Résultat : toujours 246 steps, 0 non résolu, 0 ambigu, 0 pattern à slash non échappé, cette fois avec un modèle de résolution fidèle au comportement réel du préprocesseur.
40 lines
1.6 KiB
TypeScript
40 lines
1.6 KiB
TypeScript
import { Given, Then } from "@badeball/cypress-cucumber-preprocessor";
|
|
|
|
// The page also loads the reference ingredient list + the profile's
|
|
// disliked-ingredients selection for `DislikedIngredientsField` — added
|
|
// alongside diets/allergies in the same `Promise.all` (see
|
|
// PreferencesPage.tsx), so both need mocking here too or that `Promise.all`
|
|
// rejects and the whole page renders its error state instead of the form,
|
|
// taking `#diet`/the allergy checkboxes down with it.
|
|
Given("the dietary preferences reference data is ready", () => {
|
|
cy.intercept("GET", "**/reference/diets", {
|
|
statusCode: 200,
|
|
body: [
|
|
{ id: 1, key: "omnivore" },
|
|
{ id: 2, key: "vegetarian" },
|
|
],
|
|
});
|
|
cy.intercept("GET", "**/reference/allergies", {
|
|
statusCode: 200,
|
|
body: [
|
|
{ id: 1, key: "peanuts", kind: "ALLERGY" },
|
|
{ id: 2, key: "gluten", kind: "INTOLERANCE" },
|
|
],
|
|
});
|
|
cy.intercept("GET", "**/profile/allergies", { statusCode: 200, body: [2] });
|
|
cy.intercept("GET", "**/reference/ingredients", { statusCode: 200, body: [] });
|
|
cy.intercept("GET", "**/profile/disliked-ingredients", { statusCode: 200, body: [] });
|
|
});
|
|
|
|
// Selecting the diet, updating allergies, and asserting on the diet update
|
|
// request are shared with onboarding.feature's regime/allergies steps — see
|
|
// cypress/support/step_definitions/profile-mutations.steps.ts.
|
|
|
|
Then(
|
|
"the allergies update request should have been made with allergy ids {int} and {int}",
|
|
(first: number, second: number) => {
|
|
cy.wait("@updateAllergies")
|
|
.its("request.body")
|
|
.should("deep.equal", { allergyIds: [first, second] });
|
|
},
|
|
);
|