From 99bb9fcfb2747f29627d4a205488537b7389a390 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Wed, 19 Aug 2026 12:55:44 +0200 Subject: [PATCH] test(web): feature Gherkin jetable pour valider le pipeline preprocessor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Étape 2 de l'expérimentation — un seul scénario minimal (remplir email/password sur l'écran de connexion) pour vérifier que addCucumberPreprocessorPlugin@22.2.0 + l'esbuild plugin fonctionnent de bout en bout, pas juste au chargement. Steps volontairement autonomes dans login-smoke.steps.ts (pas de fichier partagé) — tout ce fichier est prévu pour être supprimé une fois validé. cypress.config.ts : specPattern couvre maintenant *.cy.ts ET *.feature en parallèle (le reste de la suite reste en .cy.ts classique pour l'instant). Testé en local jusqu'au mur GPU/Electron habituel de cet environnement (chargement de la config + bundling esbuild passent, pas d'ERR_REQUIRE_ESM) — la vraie exécution du scénario reste à vérifier via la CI. --- apps/web/cypress.config.ts | 21 ++++++++++++++++++++- apps/web/cypress/e2e/login-smoke.feature | 12 ++++++++++++ apps/web/cypress/e2e/login-smoke.steps.ts | 21 +++++++++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 apps/web/cypress/e2e/login-smoke.feature create mode 100644 apps/web/cypress/e2e/login-smoke.steps.ts diff --git a/apps/web/cypress.config.ts b/apps/web/cypress.config.ts index 4efc7f8..20fd5f4 100644 --- a/apps/web/cypress.config.ts +++ b/apps/web/cypress.config.ts @@ -1,9 +1,18 @@ +import { addCucumberPreprocessorPlugin } from "@badeball/cypress-cucumber-preprocessor"; +import { createEsbuildPlugin } from "@badeball/cypress-cucumber-preprocessor/esbuild"; +import createBundler from "@bahmutov/cypress-esbuild-preprocessor"; import { defineConfig } from "cypress"; export default defineConfig({ e2e: { baseUrl: "http://localhost:5173", - setupNodeEvents(on) { + // Experimental — testing whether real Gherkin .feature files work with + // this preprocessor version (see experiment/cucumber-cypress). Only one + // throwaway feature exists right now (login.feature); the rest of the + // suite is still plain .cy.ts, matched by the default `**/*.cy.ts` + // pattern alongside `**/*.feature`. + specPattern: ["cypress/e2e/**/*.cy.ts", "cypress/e2e/**/*.feature"], + async setupNodeEvents(on, config) { // Disable GPU for headless/sandboxed environments (e.g. CI containers) // where no GPU device is available. on("before:browser:launch", (browser, launchOptions) => { @@ -12,6 +21,16 @@ export default defineConfig({ } return launchOptions; }); + + await addCucumberPreprocessorPlugin(on, config); + on( + "file:preprocessor", + createBundler({ + plugins: [createEsbuildPlugin(config)], + }), + ); + + return config; }, }, }); diff --git a/apps/web/cypress/e2e/login-smoke.feature b/apps/web/cypress/e2e/login-smoke.feature new file mode 100644 index 0000000..0d0ef5c --- /dev/null +++ b/apps/web/cypress/e2e/login-smoke.feature @@ -0,0 +1,12 @@ +Feature: Login screen (throwaway smoke test) + Just checking that Gherkin + Cypress actually work end to end with the + currently installed preprocessor version — not meant to stay in the + suite long-term. + + Scenario: A visitor can type their credentials into the login screen + Given I am not signed in + When I visit "/login" + And I fill in the "email" field with "alice@example.com" + And I fill in the "password" field with "correct-horse-battery-staple" + Then the "email" field should have the value "alice@example.com" + And the "password" field should have the value "correct-horse-battery-staple" diff --git a/apps/web/cypress/e2e/login-smoke.steps.ts b/apps/web/cypress/e2e/login-smoke.steps.ts new file mode 100644 index 0000000..edcf30f --- /dev/null +++ b/apps/web/cypress/e2e/login-smoke.steps.ts @@ -0,0 +1,21 @@ +import { Given, Then, When } from "@badeball/cypress-cucumber-preprocessor"; + +// Throwaway smoke test — see login-smoke.feature. Steps are deliberately +// minimal/self-contained here rather than shared, since this whole file is +// meant to be deleted once it's proven the preprocessor works. + +Given("I am not signed in", () => { + cy.intercept("GET", "**/auth/me", { statusCode: 401 }); +}); + +When("I visit {string}", (path: string) => { + cy.visit(path); +}); + +When("I fill in the {string} field with {string}", (fieldId: string, value: string) => { + cy.get(`#${fieldId}`).type(value); +}); + +Then("the {string} field should have the value {string}", (fieldId: string, value: string) => { + cy.get(`#${fieldId}`).should("have.value", value); +});