- apps/web/cypress/e2e/onboarding.cy.ts — parcours complet (rempli et entièrement skippé) signup → 3 étapes → home, mêmes conventions cy.intercept que le reste. - apps/web/cypress/e2e/household.cy.ts — /foyer : préremplissage, et sauvegarde indépendante de chacune des 3 sections. - specs/frontend-architecture.md : nouvelle section "Parcours profil — foyer, régime, allergènes" (diagramme mermaid, les deux bugs de state trouvés en testant dans le navigateur), arborescence et namespaces i18n à jour. - README.md : nouvelle section "Parcours profil — foyer, régime, allergènes", section sidebar mise à jour (Foyer & profil n'est plus un stub). Cypress lui-même ne peut pas tourner en local dans ce sandbox (voir la note existante dans le README) — vérifié via `tsc --noEmit` sur les specs + parcours manuel complet dans le navigateur (les deux à travers les 5 commits précédents de cette feature). Clôt la feature profil/foyer/régime/allergènes (6 commits, cette PR) : seed+référence -> endpoints foyer/profil -> composants partagés -> wizard d'inscription -> page /foyer -> ce commit.
94 lines
3 KiB
TypeScript
94 lines
3 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: 1,
|
|
dietId: 2,
|
|
};
|
|
|
|
describe("Household & profile settings (/foyer)", () => {
|
|
beforeEach(() => {
|
|
cy.intercept("GET", "**/auth/me", { statusCode: 200, body: authenticatedProfile });
|
|
cy.intercept("GET", "**/house/current", {
|
|
statusCode: 200,
|
|
body: { id: 1, name: "Chez Alice" },
|
|
});
|
|
cy.intercept("GET", "**/reference/diets", {
|
|
statusCode: 200,
|
|
body: [
|
|
{ id: 1, name: "Omnivore" },
|
|
{ id: 2, name: "Végétarien" },
|
|
],
|
|
});
|
|
cy.intercept("GET", "**/reference/allergies", {
|
|
statusCode: 200,
|
|
body: [
|
|
{ id: 1, name: "Arachides" },
|
|
{ id: 2, name: "Gluten" },
|
|
],
|
|
});
|
|
cy.intercept("GET", "**/profile/allergies", { statusCode: 200, body: [2] });
|
|
});
|
|
|
|
it("loads the current household name, regime and allergens", () => {
|
|
cy.visit("/foyer");
|
|
|
|
cy.get("#houseName").should("have.value", "Chez Alice");
|
|
cy.get("#diet").should("have.value", "2");
|
|
cy.contains("label", "Gluten").find("input[type=checkbox]").should("be.checked");
|
|
cy.contains("label", "Arachides").find("input[type=checkbox]").should("not.be.checked");
|
|
});
|
|
|
|
it("saves the household name independently of the other sections", () => {
|
|
cy.intercept("PATCH", "**/house/current", {
|
|
statusCode: 200,
|
|
body: { id: 1, name: "Chez les Martin" },
|
|
}).as("renameHouse");
|
|
|
|
cy.visit("/foyer");
|
|
cy.get("#houseName").clear();
|
|
cy.get("#houseName").type("Chez les Martin");
|
|
cy.get("#houseName")
|
|
.closest("form")
|
|
.within(() => cy.contains("button", "Enregistrer").click());
|
|
|
|
cy.wait("@renameHouse").its("request.body").should("deep.equal", { name: "Chez les Martin" });
|
|
cy.get("#houseName").closest("form").contains("Enregistré ✓").should("be.visible");
|
|
});
|
|
|
|
it("saves the regime independently of the other sections", () => {
|
|
cy.intercept("PATCH", "**/profile/diet", {
|
|
statusCode: 200,
|
|
body: { ...authenticatedProfile, dietId: 1 },
|
|
}).as("updateDiet");
|
|
|
|
cy.visit("/foyer");
|
|
cy.get("#diet").select("Omnivore");
|
|
cy.get("#diet")
|
|
.closest("form")
|
|
.within(() => cy.contains("button", "Enregistrer").click());
|
|
|
|
cy.wait("@updateDiet").its("request.body").should("deep.equal", { dietId: 1 });
|
|
cy.get("#diet").closest("form").contains("Enregistré ✓").should("be.visible");
|
|
});
|
|
|
|
it("saves the allergen selection independently of the other sections", () => {
|
|
cy.intercept("PATCH", "**/profile/allergies", { statusCode: 200, body: [1, 2] }).as(
|
|
"updateAllergies",
|
|
);
|
|
|
|
cy.visit("/foyer");
|
|
cy.contains("label", "Arachides").find("input[type=checkbox]").check();
|
|
cy.contains("fieldset", "Allergies").within(() => {
|
|
cy.contains("button", "Enregistrer").click();
|
|
});
|
|
|
|
cy.wait("@updateAllergies")
|
|
.its("request.body")
|
|
.should("deep.equal", { allergyIds: [2, 1] });
|
|
});
|
|
});
|