import { Then, When } from "@badeball/cypress-cucumber-preprocessor"; // Landing-page-specific steps. Everything else this feature needs // (signing in / not, visiting a path, URL and heading assertions) comes // from the shared `cypress/support/step_definitions/common.steps.ts`. // Mocks nothing itself — the landing page makes no API calls of its own; // it renders purely from the logged-out state `I am not signed in` sets up. Then("I should see the landing call to action", () => { cy.get(".landing__hero .landing__cta--primary") .should("be.visible") .and("have.attr", "href", "/signup"); cy.get(".landing__hero .landing__cta--secondary") .should("be.visible") .and("have.attr", "href", "/login"); }); // Issue #85: desktop only now (see LandingPage.tsx) — routed through // `/telecharger` (DownloadPage.tsx, issue #84's fallback page) rather than // linking the Android build's actual `/mobile/download` redirect directly, // so "get the app" has exactly one canonical destination app-wide. Then("I should see the Android download link", () => { cy.get(".landing__hero .landing__mobile-link") .should("be.visible") .and("have.attr", "href", "/telecharger"); }); // Spoofs a real Android phone Chrome UA via `onBeforeLoad` — the one place // `isAndroidPhoneBrowser()` (`lib/mobile-app-redirect.ts`) actually reads // from, so this is the only way to reach the landing page's mobile-only // branch from a real page visit (Cypress's own Electron browser always // reports a desktop UA otherwise). Same literal UA string already used by // `mobile-app-redirect.cy.tsx`'s own `isAndroidPhoneBrowser` unit test. When("I visit {string} as an Android phone browser", (path: string) => { cy.visit(path, { onBeforeLoad(win) { Object.defineProperty(win.navigator, "userAgent", { value: "Mozilla/5.0 (Linux; Android 14; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0 Mobile Safari/537.36", configurable: true, }); }, }); }); Then("I should see the button to open the app, with sign-up demoted to secondary", () => { // Deliberately never clicked here: its `onClick` calls // `attemptOpenNativeApp()` with the real (production) `openAppUrl`, a // genuine `window.location.href` to an unrecognized custom scheme — that // hangs the Cypress/Electron runner indefinitely rather than safely // no-op'ing (see dev-environment-gotchas.md). The function itself is // already fully unit-tested with an injected stub in // mobile-app-redirect.cy.tsx; this only covers LandingPage's own // conditional rendering. cy.get(".landing__hero .landing__cta--primary") .should("be.visible") .and("contain.text", "Ouvrir dans l'application"); cy.contains(".landing__hero .landing__cta--secondary", "Créer un compte").should("be.visible"); cy.contains(".landing__hero .landing__cta--secondary", "Se connecter").should("be.visible"); }); Then("the Android download link should not be shown", () => { cy.get(".landing__hero .landing__mobile-link").should("not.exist"); });