Repli/déploiement via le bouton dédié, labels masqués (pas retirés du DOM — restent pour le title="") mais liens toujours visibles/cliquables icône seule, persistance via localStorage vérifiée après cy.reload().
83 lines
2.9 KiB
TypeScript
83 lines
2.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");
|
|
});
|
|
|
|
it("collapses to an icon-only rail and back, persisting the choice across reloads", () => {
|
|
cy.visit("/");
|
|
|
|
cy.get(".app-sidebar").should("not.have.class", "collapsed");
|
|
cy.contains("nav a", "Planning").should("be.visible");
|
|
|
|
cy.get(".app-sidebar__collapse-toggle").click();
|
|
cy.get(".app-sidebar").should("have.class", "collapsed");
|
|
// The label text hides (not removed from the DOM — still there for the
|
|
// `title` tooltip/accessibility), while the link itself stays visible,
|
|
// icon-only.
|
|
cy.contains("span.label", "Planning").should("exist").and("not.be.visible");
|
|
cy.get("nav a[title='Planning']").should("be.visible");
|
|
|
|
cy.reload();
|
|
cy.get(".app-sidebar").should("have.class", "collapsed");
|
|
|
|
cy.get(".app-sidebar__collapse-toggle").click();
|
|
cy.get(".app-sidebar").should("not.have.class", "collapsed");
|
|
cy.contains("nav a", "Planning").should("be.visible");
|
|
});
|
|
});
|