// Mocks the API via cy.intercept — this job doesn't run a live backend (see // .github/workflows/ci.yml); apps/api's own Mocha suite covers real API // behavior against a real database. // // The theme-switching journey moved to user-preferences.feature — this file // now only covers the page's initial display (default/saved theme). const authenticatedProfile = { id: 1, firstName: "Alice", lastName: "Martin", email: "alice@example.com", tokenVersion: 0, houseId: null, dietId: null, }; describe("User preferences (/parametres/preferences-utilisateur)", () => { beforeEach(() => { cy.intercept("GET", "**/auth/me", { statusCode: 200, body: authenticatedProfile }); }); it("shows SYSTEM selected by default", () => { cy.intercept("GET", "**/preferences", { statusCode: 200, body: { theme: "SYSTEM" } }); cy.visit("/parametres/preferences-utilisateur"); cy.contains("label", "Système").find("input[type=radio]").should("be.checked"); cy.contains("label", "Clair").find("input[type=radio]").should("not.be.checked"); cy.contains("label", "Sombre").find("input[type=radio]").should("not.be.checked"); // SYSTEM never sets an override — the OS/browser preference decides. cy.get("html").should("not.have.attr", "data-theme"); }); it("shows the previously saved theme selected, and applies it to the document", () => { cy.intercept("GET", "**/preferences", { statusCode: 200, body: { theme: "DARK" } }); cy.visit("/parametres/preferences-utilisateur"); cy.contains("label", "Sombre").find("input[type=radio]").should("be.checked"); cy.get("html").should("have.attr", "data-theme", "dark"); }); });