import { Given, Then } from "@badeball/cypress-cucumber-preprocessor"; // Contact-form-specific steps (issue #80). Signing in and the generic // select/type/click/see steps come from support/step_definitions/. // Mocks the API via cy.intercept — this job runs no live backend (see // .github/workflows/ci.yml); apps/api's Mocha suite covers `POST /contact` // against a real database. Given("submitting a contact message will succeed", () => { // 204, matching the real route — the client's `_request` treats only 204 // as a bodyless success (a 201 with no body makes its `.json()` throw). cy.intercept("POST", "**/contact", { statusCode: 204 }).as("submitContact"); }); Then("the contact request should have been sent with type {string}", (type: string) => { cy.wait("@submitContact").its("request.body.type").should("equal", type); }); Then("the contact request body should carry the current page URL and app version", () => { cy.get("@submitContact.all").should("have.length", 1); cy.get("@submitContact") .its("request.body") .should((body: Record) => { expect(body.pageUrl).to.equal("/parametres/contact"); expect(body.appVersion).to.be.a("string").and.not.equal(""); }); }); Then("no contact request should have been sent", () => { cy.get("@submitContact.all").should("have.length", 0); });