Les tests e2e (apps/web/cypress/e2e/) étaient de simples specs Cypress (.cy.ts), sans lien avec Cucumber alors qu'apps/api utilise déjà Gherkin pour ses propres tests BDD. Intègre @badeball/cypress-cucumber-preprocessor pour écrire les scénarios utilisateurs en Gherkin des deux côtés, même vocabulaire. - cypress.config.ts : specPattern sur *.feature, wiring du préprocesseur (esbuild bundler + plugin cucumber) - Les 11 fichiers .cy.ts sont remplacés par des paires .feature/.steps.ts (co-localisées, même nom) — conversion complète, comportement équivalent (mêmes intercepts, mêmes assertions) - cypress/support/step_definitions/common.steps.ts : steps partagés entre features (connexion, navigation, assertions génériques de texte/URL/champ) — globaux à toute la suite, réutilisables tels quels - cypress/support/profile.ts : profil du compte "connecté" courant, assemblé au fil de plusieurs Given avant le premier visit/When - README : nouvelle section "Cucumber (apps/web)" (miroir de la section existante pour apps/api), mise à jour des références aux anciens noms de fichiers .cy.ts (déjà obsolètes avant ce changement) Vérification : impossible d'exécuter Cypress dans cet environnement (crash Electron/GPU au lancement, limitation déjà documentée dans le README — reproductible sur main, indépendante de ce changement). À la place : - les 447 steps Gherkin des 11 .feature ont été vérifiés programmatiquement contre les 165 patterns de step enregistrés : 0 non résolu, 0 ambigu - les 11 .feature parsent correctement avec le parser Gherkin officiel (57 scénarios au total) - tous les .steps.ts passent `biome check` (syntaxe + style) sans erreur - CYPRESS_INSTALL_BINARY déjà géré (voir PR précédente) — le binaire est bien présent localement (`cypress verify` OK), donc le blocage est spécifiquement le sandbox GPU de cet environnement, pas l'installation La vraie exécution reste à vérifier via le job `e2e` de la CI GitHub Actions sur cette PR — c'est le chemin déjà documenté dans le README pour cet environnement précis.
92 lines
2.6 KiB
TypeScript
92 lines
2.6 KiB
TypeScript
import { type DataTable, Given, Then, When } from "@badeball/cypress-cucumber-preprocessor";
|
|
|
|
Given("the current planning is empty", () => {
|
|
cy.intercept("GET", /\/planning\?/, { statusCode: 200, body: null }).as("getPlanning");
|
|
});
|
|
|
|
Given("the current planning includes:", (dataTable: DataTable) => {
|
|
const items = dataTable.hashes().map((row, index) => ({
|
|
id: index + 1,
|
|
weekDay: row.day,
|
|
meal: row.meal,
|
|
recipe: { id: index + 1, name: row.recipe },
|
|
}));
|
|
cy.intercept("GET", /\/planning\?/, {
|
|
statusCode: 200,
|
|
body: {
|
|
id: 1,
|
|
startDate: "2026-08-17T00:00:00.000Z",
|
|
finishDate: "2026-08-23T00:00:00.000Z",
|
|
items,
|
|
},
|
|
});
|
|
});
|
|
|
|
Given("the current planning request fails", () => {
|
|
cy.intercept("GET", /\/planning\?/, {
|
|
statusCode: 500,
|
|
body: { code: 5000, message: "boom" },
|
|
});
|
|
});
|
|
|
|
Then("the planning request should have been made for the week of {string}", (date: string) => {
|
|
cy.wait("@getPlanning").its("request.url").should("include", `date=${date}`);
|
|
});
|
|
|
|
Then("the grid should have {int} empty slots", (count: number) => {
|
|
cy.get(".add-recipe-btn").should("have.length", count);
|
|
});
|
|
|
|
Then("no recipe chips should be shown", () => {
|
|
cy.get(".recipe-chip").should("not.exist");
|
|
});
|
|
|
|
Then("the day column {string} should be visible", (day: string) => {
|
|
cy.contains("th", day).should("be.visible");
|
|
});
|
|
|
|
Then("the recipe chip {string} should be visible", (name: string) => {
|
|
cy.contains(".recipe-chip", name).should("be.visible");
|
|
});
|
|
|
|
Then("today's column should show the date {string}", (day: string) => {
|
|
cy.contains("th.today .day-date", day).should("be.visible");
|
|
});
|
|
|
|
When("I click the next week arrow", () => {
|
|
cy.get(".week-nav__arrow").last().click();
|
|
});
|
|
|
|
When("I click the previous week arrow", () => {
|
|
cy.get(".week-nav__arrow").first().click();
|
|
});
|
|
|
|
When("I open the week calendar", () => {
|
|
cy.contains("button", "Semaine du").click();
|
|
});
|
|
|
|
Then("the calendar popover should be visible", () => {
|
|
cy.get(".calendar-popover").should("be.visible");
|
|
});
|
|
|
|
Then("the calendar popover should be closed", () => {
|
|
cy.get(".calendar-popover").should("not.exist");
|
|
});
|
|
|
|
When("I pick day {int} in the calendar", (day: number) => {
|
|
cy.get(".calendar-grid__day")
|
|
.contains(new RegExp(`^${day}$`))
|
|
.click();
|
|
});
|
|
|
|
Then("the nav link {string} should be active", (text: string) => {
|
|
cy.contains("nav a", text).should("have.class", "active");
|
|
});
|
|
|
|
Then("the nav link {string} should not be active", (text: string) => {
|
|
cy.contains("nav a", text).should("not.have.class", "active");
|
|
});
|
|
|
|
When("I click the nav link {string}", (text: string) => {
|
|
cy.contains("nav a", text).click();
|
|
});
|