batchCooking/apps/web/cypress/e2e/planning-page.feature
Nicolas 20d52aee2d feat(web): migre les specs Cypress vers Cucumber/Gherkin
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.
2026-08-19 09:42:29 +02:00

102 lines
4.7 KiB
Gherkin
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Feature: Planning page — sidebar navigation and weekly grid
As a signed-in user
I want to navigate between sections and see my household's weekly planning
So that I know what meals are planned this week
Background:
Given I am signed in as "Alice" "Martin"
And my household id is 1
# The Foyer/Compte/Préférences links — behind the sidebar's "Paramètres"
# toggle, not the main nav tested here — are covered by sidebar.feature.
Scenario: Highlights the current section and navigates between stub pages
Given the planning request returns nothing
When I visit "/"
Then the nav link "Planning" should be active
When I click the nav link "Recettes"
Then the URL should include "/recettes"
And I should see the heading "Recettes"
And the nav link "Recettes" should be active
And the nav link "Planning" should not be active
When I click the nav link "Liste de courses"
Then the URL should include "/liste-de-courses"
And I should see the heading "Liste de courses"
When I click the nav link "Planning"
Then the URL should be the home page
And I should see the heading "Planning de la semaine"
Scenario: Shows the signed-in user's name and lets them log out from the account menu
Given the planning request returns nothing
And the logout request will succeed
When I visit "/"
And I open the account menu
And I click the button "Se déconnecter"
Then the logout request should have been made
And the URL should include "/login"
# Desktop-only design (see the plan/PR description) — wider than Cypress's
# default 1000×660 so all 7 day columns fit without the grid's horizontal
# scroll hiding the later ones from visibility assertions.
Scenario: Shows an empty grid when the household has no planning yet
Given the viewport is 1600 by 900
And today is frozen at "2026-08-17T09:00:00Z"
And the current planning is empty
When I visit "/"
Then the planning request should have been made for the week of "2026-08-17"
And I should see the heading "Planning de la semaine"
And the grid should have 35 empty slots
And no recipe chips should be shown
Scenario: Renders each recipe in its (day, meal) cell, and highlights today's column
Given the viewport is 1600 by 900
And today is frozen at "2026-08-17T09:00:00Z"
And the current planning includes:
| day | meal | recipe |
| mardi | diner | Ratatouille |
| mercredi | dejeuner | Curry de lentilles |
When I visit "/"
Then the day column "Lundi" should be visible
And the day column "Dimanche" should be visible
And the recipe chip "Ratatouille" should be visible
And the recipe chip "Curry de lentilles" should be visible
And today's column should show the date "17"
Scenario: Shows a loading state, then an error state when the request fails
Given the viewport is 1600 by 900
And today is frozen at "2026-08-17T09:00:00Z"
And the current planning request fails
When I visit "/"
Then I should see "Impossible de charger le planning, réessayez plus tard"
# Assertions below check the rendered week label/badge, not the intercepted
# request count — React StrictMode (see main.tsx) double-invokes effects in
# dev, so the `GET /planning` mount effect can fire twice per navigation;
# counting exact `cy.wait` calls against that would be flaky, but the
# rendered result is the same either way.
Scenario: Navigates to the next/previous week, re-fetching each time
Given the viewport is 1600 by 900
And today is frozen at "2026-08-17T09:00:00Z"
And the current planning is empty
When I visit "/"
Then the planning request should have been made for the week of "2026-08-17"
And I should see "Semaine du 17 au 23 août 2026"
And I should see "Cette semaine"
When I click the next week arrow
Then I should see "Semaine du 24 au 30 août 2026"
And I should not see "Cette semaine"
When I click the previous week arrow
Then I should see "Semaine du 17 au 23 août 2026"
When I click the previous week arrow
Then I should see "Semaine du 10 au 16 août 2026"
Scenario: Jumps to an arbitrary week by picking a day in the calendar popover
Given the viewport is 1600 by 900
And today is frozen at "2026-08-17T09:00:00Z"
And the current planning is empty
When I visit "/"
Then the planning request should have been made for the week of "2026-08-17"
When I open the week calendar
Then the calendar popover should be visible
When I pick day 25 in the calendar
Then I should see "Semaine du 24 au 30 août 2026"
And the calendar popover should be closed