Some checks failed
Sur un vrai navigateur mobile Android (isAndroidPhoneBrowser(), déjà utilisé par le ticket #84), la ligne de CTA de la landing page affiche désormais "Ouvrir dans l'application" comme action PRIMAIRE — plus utile qu'un compte web puisque l'expérience web n'est de toute façon pas optimisée mobile (au cœur de ce chantier), et un visiteur avec l'appli déjà installée peut s'inscrire/se connecter depuis l'appli elle-même. "Créer un compte"/"Se connecter" sont rétrogradés en actions secondaires plutôt que masqués : certains visiteurs préfèrent sciemment le web. Le clic déclenche attemptOpenNativeApp (tentative d'ouverture du scheme, repli automatique après le délai) plutôt que d'afficher un second lien séparé — remplace .landing__mobile-link, ne le duplique pas. Sur desktop, comportement inchangé (CTA "Créer un compte" toujours primaire) sauf le lien Android discret, qui pointe maintenant vers /telecharger (page de repli du ticket #84) au lieu du lien direct /mobile/download — un seul point d'entrée "obtenir l'appli" pour tout le site plutôt que deux mécanismes légèrement différents à maintenir en synchro. Couverture Cypress : landing.feature étendu avec un nouveau scénario mobile (UA Android spoofée via onBeforeLoad, même chaîne que le test unitaire existant d'isAndroidPhoneBrowser dans mobile-app-redirect.cy.tsx) — vérifie l'affichage du bouton et la rétrogradation de Créer un compte/Se connecter, SANS jamais cliquer le bouton réel (son onClick appellerait un vrai window.location.href vers un scheme personnalisé, qui bloque indéfiniment le runner Cypress/ Electron — piège déjà documenté, la fonction elle-même est déjà testée unitairement avec un stub injecté). Le scénario desktop existant est mis à jour pour le nouveau href /telecharger. Suite complète : biome check, tsc -b --force, build, 145/145 e2e, 71/71 composants — tous verts. Closes #85 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
64 lines
3 KiB
TypeScript
64 lines
3 KiB
TypeScript
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");
|
|
});
|