From a7d1103b4abeebaaabccd6a3407bba8862a55359 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Wed, 19 Aug 2026 12:07:33 +0200 Subject: [PATCH] fix(web): remplace le hook Before() par un reset dans le premier step MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Même famille de bug que les 2 commits précédents : dès qu'un Before()/After() Cucumber est enregistré, le browser runtime du preprocessor lit `messages.HookType.BEFORE_TEST_CASE`/`AFTER_TEST_CASE` pour le rapporter — absent de @cucumber/messages@17.1.1 (voir l'override dans package.json). Confirmé par le run CI précédent : chaque scénario plantait sur "Cannot read properties of undefined (reading 'BEFORE_TEST_CASE')", y compris ceux n'ayant a priori rien à voir avec le profil (le seul Before() du repo vit dans common.steps.ts, partagé par toutes les features). Le seul hook du repo ne servait qu'à réinitialiser le profil "connecté" courant entre scénarios. Remplacé par un reset explicite au tout début du step "I am signed in as ...", le point d'entrée par lequel passe systématiquement toute construction de profil — équivalent fonctionnellement, sans avoir besoin d'enregistrer de hook du tout. --- .../support/step_definitions/common.steps.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/apps/web/cypress/support/step_definitions/common.steps.ts b/apps/web/cypress/support/step_definitions/common.steps.ts index 10e38bd..b428189 100644 --- a/apps/web/cypress/support/step_definitions/common.steps.ts +++ b/apps/web/cypress/support/step_definitions/common.steps.ts @@ -1,4 +1,4 @@ -import { Before, Given, Then, When } from "@badeball/cypress-cucumber-preprocessor"; +import { Given, Then, When } from "@badeball/cypress-cucumber-preprocessor"; import { buildProfile, currentProfile, resetProfile, setCurrentProfile } from "../profile"; // Steps shared across every feature — signing in/out, navigation, and @@ -13,15 +13,22 @@ import { buildProfile, currentProfile, resetProfile, setCurrentProfile } from ". // (see .github/workflows/ci.yml); apps/api's own Mocha/Cucumber suites // cover real API behavior against a real database. -Before(() => { - resetProfile(); -}); - Given("I am not signed in", () => { cy.intercept("GET", "**/auth/me", { statusCode: 401 }); }); +// No `Before()` hook for this reset (deliberately) — registering any +// Cucumber hook makes the preprocessor's browser runtime read +// `messages.HookType.{BEFORE,AFTER}_TEST_CASE` to report it, and that enum +// doesn't exist on the older, CommonJS-only `@cucumber/messages` this repo +// is pinned to (see `pnpm.overrides` in package.json, and this branch's +// commit history for why) — every scenario crashed on "Cannot read +// properties of undefined (reading 'BEFORE_TEST_CASE')" the moment this +// file registered one. Resetting right here instead, at the one step every +// profile-building chain always starts with, is equivalent for our +// purposes without needing a hook at all. Given("I am signed in as {string} {string}", (firstName: string, lastName: string) => { + resetProfile(); setCurrentProfile( buildProfile({ firstName,