batchCooking/apps/web/cypress/e2e/sidebar.cy.ts
Nicolas a8d897dfab Tests: couverture Cypress pour les préférences utilisateur (step 4/4)
- user-preferences.cy.ts: défaut SYSTEM, thème sauvegardé restitué et
  appliqué au document, autosave sans bouton "Enregistrer"
- sidebar.cy.ts: 4 pages de paramètres (libellé "Préférences
  alimentaires" renommé + nouvelle entrée "Préférences utilisateur")
- auth.cy.ts/onboarding.cy.ts: corrige un intercept **/planning/current
  périmé (route supprimée dans la PR précédente) — masqué jusqu'ici car
  aucune assertion n'en dépendait directement, mais provoquait un appel
  réseau non mocké
2026-08-17 15:56:36 +02:00

61 lines
1.9 KiB
TypeScript

// Mocks the API via cy.intercept — see auth.cy.ts for the rationale.
const authenticatedProfile = {
id: 1,
firstName: "Alice",
lastName: "Martin",
email: "alice@example.com",
tokenVersion: 0,
houseId: null,
dietId: null,
};
describe("Sidebar — settings menu and account menu", () => {
beforeEach(() => {
cy.intercept("GET", "**/auth/me", { statusCode: 200, body: authenticatedProfile });
// Not "**/planning*" — that glob also matches the Vite dev request for
// planning-page.scss (see planning-page.cy.ts for the same gotcha).
cy.intercept("GET", /\/planning\?/, { statusCode: 200, body: null });
});
it("no longer lists Foyer in the main nav", () => {
cy.visit("/");
cy.get(".app-sidebar__nav a").should("not.contain", "Foyer");
});
it("reveals the four settings pages behind the Paramètres toggle", () => {
cy.visit("/");
cy.contains("a", "Compte").should("not.exist");
cy.contains("button", "Paramètres").click();
cy.contains("a", "Compte").should("have.attr", "href", "/parametres/compte");
cy.contains("a", "Préférences alimentaires").should(
"have.attr",
"href",
"/parametres/preferences",
);
cy.contains("a", "Foyer").should("have.attr", "href", "/parametres/foyer");
cy.contains("a", "Préférences utilisateur").should(
"have.attr",
"href",
"/parametres/preferences-utilisateur",
);
});
it("opens the account menu from the greeting and links to Mon compte", () => {
cy.visit("/");
cy.contains("a", "Mon compte").should("not.exist");
cy.contains("button", "Bonjour Alice").click();
cy.contains("a", "Mon compte").click();
cy.url().should("include", "/parametres/compte");
});
it("redirects the old /foyer path to /parametres/foyer", () => {
cy.intercept("GET", "**/house/current", { statusCode: 200, body: null });
cy.visit("/foyer");
cy.url().should("include", "/parametres/foyer");
});
});