// 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 household-management journey (create, join, rename, remove a member, // delete, leave) moved to household-settings.feature — this file now only // covers what's left: passive display of each screen's initial state. const adminProfile = { id: 1, firstName: "Alice", lastName: "Martin", email: "alice@example.com", tokenVersion: 0, houseId: null as number | null, dietId: null, }; const houseWithTwoMembers = { id: 1, name: "Chez Alice", adminId: 1, inviteCode: "ABCD2345", members: [ { id: 1, firstName: "Alice", lastName: "Martin" }, { id: 2, firstName: "Bob", lastName: "Dupont" }, ], }; describe("Household settings (/parametres/foyer) — no household yet", () => { beforeEach(() => { cy.intercept("GET", "**/auth/me", { statusCode: 200, body: adminProfile }); cy.intercept("GET", "**/house/current", { statusCode: 200, body: null }); }); it("offers to create or join a household", () => { cy.visit("/parametres/foyer"); cy.contains("Créer un foyer").should("be.visible"); cy.contains("Rejoindre un foyer").should("be.visible"); }); }); describe("Household settings (/parametres/foyer) — as the admin", () => { beforeEach(() => { cy.intercept("GET", "**/auth/me", { statusCode: 200, body: { ...adminProfile, houseId: 1 } }); cy.intercept("GET", "**/house/current", { statusCode: 200, body: houseWithTwoMembers }); }); it("shows the household's name, invite code, and members with an admin badge", () => { cy.visit("/parametres/foyer"); cy.get("#houseName").should("have.value", "Chez Alice"); cy.contains("ABCD2345").should("be.visible"); cy.contains("Bob Dupont").should("be.visible"); cy.contains("Alice Martin").parent().contains("Admin"); }); }); describe("Household settings (/parametres/foyer) — as a non-admin member", () => { beforeEach(() => { cy.intercept("GET", "**/auth/me", { statusCode: 200, body: { ...adminProfile, id: 2, firstName: "Bob", lastName: "Dupont", houseId: 1 }, }); cy.intercept("GET", "**/house/current", { statusCode: 200, body: houseWithTwoMembers }); }); it("offers to leave the household instead of deleting it", () => { cy.visit("/parametres/foyer"); cy.contains("button", "Quitter le foyer").should("be.visible"); cy.contains("button", "Supprimer le foyer").should("not.exist"); }); });