Nouvelle app Vite/React independante (workspace apps/*), calquee sur apps/web : port 5174, sa propre image Docker (nginx statique), son propre domaine/deploiement. - AdminApiClient (VITE_ADMIN_API_URL, credentials: include) + ApiError. - AdminAuthContext / RequireAdmin : restaure la session admin via GET /admin/auth/me, garde de route (miroir de AuthContext/RequireAuth). - LoginPage (/login) : validation cliente via adminLoginSchema partage, erreurs traduites via ErrorMessageService. - AdminLayout : sidebar (Tableau de bord / Monitoring / Corrections) + deconnexion, rendu une fois autour du groupe RequireAdmin. - Pages Dashboard / Monitoring / Corrections en placeholder (remplies aux PR 3-5). - i18n fr (bloc admin.* + sous-ensemble errors.*), tokens _theme.scss copies de apps/web (extraction en package partage : suivi separe). - Dockerfile multi-stage (node build -> nginx:alpine) + nginx.conf (SPA fallback). Service admin-web dans docker-compose.yml (port ADMIN_WEB_PORT, VITE_ADMIN_API_URL en build arg). - Cypress : login.feature (KO -> message, OK -> dashboard) + admin-layout .cy.ts (redirection /login sans session, nav entre sections, logout). Job "Run admin-web E2E tests" ajoute a ci.yml. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
54 lines
1.7 KiB
TypeScript
54 lines
1.7 KiB
TypeScript
import { Given, Then, When } from "@badeball/cypress-cucumber-preprocessor";
|
|
|
|
// Steps shared across admin feature specs — navigation and generic UI
|
|
// assertions. Anything specific to one feature (its own API mocks, its own
|
|
// DOM structure) lives in that feature's own `<name>.ts` step file.
|
|
//
|
|
// Every admin API call is mocked via `cy.intercept` — the Cypress suite
|
|
// never runs a live backend; apps/api's own Mocha suite covers real
|
|
// `/admin/*` behaviour.
|
|
|
|
Given("the admin session check returns unauthenticated", () => {
|
|
cy.intercept("GET", "**/admin/auth/me", { statusCode: 401, body: { code: 4011, message: "no" } });
|
|
});
|
|
|
|
Given("I am signed in as admin {string}", (name: string) => {
|
|
cy.intercept("GET", "**/admin/auth/me", {
|
|
statusCode: 200,
|
|
body: {
|
|
id: 1,
|
|
email: `${name.toLowerCase()}@example.com`,
|
|
name,
|
|
createdAt: "2026-08-01T00:00:00.000Z",
|
|
lastLoginAt: "2026-08-28T09:00:00.000Z",
|
|
},
|
|
});
|
|
});
|
|
|
|
When("I visit {string}", (path: string) => {
|
|
cy.visit(path);
|
|
});
|
|
|
|
When("I fill in the {string} field with {string}", (fieldId: string, value: string) => {
|
|
cy.get(`#${fieldId}`).clear().type(value);
|
|
});
|
|
|
|
When("I click the button {string}", (text: string) => {
|
|
cy.contains("button", text).click();
|
|
});
|
|
|
|
Then("the URL should include {string}", (fragment: string) => {
|
|
cy.url().should("include", fragment);
|
|
});
|
|
|
|
Then("the URL should not include {string}", (fragment: string) => {
|
|
cy.url().should("not.include", fragment);
|
|
});
|
|
|
|
Then("I should see {string}", (text: string) => {
|
|
cy.contains(text).should("be.visible");
|
|
});
|
|
|
|
Then("I should see the heading {string}", (text: string) => {
|
|
cy.contains("h1", text).should("be.visible");
|
|
});
|