// 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. // // Cypress always runs as a plain web browser — `Capacitor.isNativePlatform()` // is never true here, so only this page's web-side content (the build // version + the "stay on web" preference) is reachable from this spec. The // native-only half (App.getInfo()/checkNow's actual version-comparison // network call) has no seam to fake native from a web run — same // untested-on-purpose posture already accepted for `useAppUpdateCheck`'s // background check and `UpdateBanner` (neither has e2e coverage either); // the underlying comparison logic itself is unit-tested in // version-compare.cy.tsx, unchanged by this ticket. const authenticatedProfile = { id: 1, firstName: "Alice", lastName: "Martin", email: "alice@example.com", tokenVersion: 0, houseId: null, dietId: null, }; const STAY_ON_WEB_KEY = "batchcooking:stayOnWeb"; describe("App settings (/parametres/application)", () => { beforeEach(() => { cy.intercept("GET", "**/auth/me", { statusCode: 200, body: authenticatedProfile }); }); it("shows the web build version, and the update-check section only on native", () => { cy.visit("/parametres/application"); cy.contains("h1", "Paramètres d'application").should("be.visible"); // The exact build number isn't asserted (would couple this test to // package.json's version, bumped independently of this page) — just // that a "Version X" line rendered at all, proving `useInstalledVersion` // resolved something rather than being stuck empty. cy.contains(".app-settings__version", "Version").should("be.visible"); cy.contains("button", "Vérifier les mises à jour").should("not.exist"); cy.contains( "La vérification des mises à jour n'est disponible que dans l'application mobile", ).should("be.visible"); }); it("defaults 'stay on web' to unchecked, and persists a toggle across a reload", () => { cy.visit("/parametres/application"); cy.contains("label", "Toujours rester sur le site web") .find('input[type="checkbox"]') .should("not.be.checked"); cy.contains("label", "Toujours rester sur le site web").click(); cy.contains("label", "Toujours rester sur le site web") .find('input[type="checkbox"]') .should("be.checked"); cy.window().then((win) => { expect(win.localStorage.getItem(STAY_ON_WEB_KEY)).to.equal("true"); }); cy.reload(); cy.contains("label", "Toujours rester sur le site web") .find('input[type="checkbox"]') .should("be.checked"); }); });