fix(web): remplace le hook Before() par un reset dans le premier step
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.
This commit is contained in:
parent
a37406532b
commit
a7d1103b4a
1 changed files with 12 additions and 5 deletions
|
|
@ -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";
|
import { buildProfile, currentProfile, resetProfile, setCurrentProfile } from "../profile";
|
||||||
|
|
||||||
// Steps shared across every feature — signing in/out, navigation, and
|
// 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
|
// (see .github/workflows/ci.yml); apps/api's own Mocha/Cucumber suites
|
||||||
// cover real API behavior against a real database.
|
// cover real API behavior against a real database.
|
||||||
|
|
||||||
Before(() => {
|
|
||||||
resetProfile();
|
|
||||||
});
|
|
||||||
|
|
||||||
Given("I am not signed in", () => {
|
Given("I am not signed in", () => {
|
||||||
cy.intercept("GET", "**/auth/me", { statusCode: 401 });
|
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) => {
|
Given("I am signed in as {string} {string}", (firstName: string, lastName: string) => {
|
||||||
|
resetProfile();
|
||||||
setCurrentProfile(
|
setCurrentProfile(
|
||||||
buildProfile({
|
buildProfile({
|
||||||
firstName,
|
firstName,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue