import { Given } from "@badeball/cypress-cucumber-preprocessor"; const adminBody = { id: 1, email: "ops@example.com", name: "Ops", createdAt: "2026-08-01T00:00:00.000Z", lastLoginAt: "2026-08-28T09:00:00.000Z", }; Given("admin login fails with invalid credentials", () => { cy.intercept("POST", "**/admin/auth/login", { statusCode: 401, body: { code: 4010, message: "Invalid email or password" }, }); }); Given("admin login succeeds as {string}", (name: string) => { const body = { ...adminBody, name, email: `${name.toLowerCase()}@example.com` }; cy.intercept("POST", "**/admin/auth/login", { statusCode: 200, body }); // After navigate("/"), RequireAdmin re-checks the session — from now on it // must report authenticated (last matching intercept wins). cy.intercept("GET", "**/admin/auth/me", { statusCode: 200, body }); });