diff --git a/apps/web/cypress.config.ts b/apps/web/cypress.config.ts index 4efc7f8..20fd5f4 100644 --- a/apps/web/cypress.config.ts +++ b/apps/web/cypress.config.ts @@ -1,9 +1,18 @@ +import { addCucumberPreprocessorPlugin } from "@badeball/cypress-cucumber-preprocessor"; +import { createEsbuildPlugin } from "@badeball/cypress-cucumber-preprocessor/esbuild"; +import createBundler from "@bahmutov/cypress-esbuild-preprocessor"; import { defineConfig } from "cypress"; export default defineConfig({ e2e: { baseUrl: "http://localhost:5173", - setupNodeEvents(on) { + // Experimental — testing whether real Gherkin .feature files work with + // this preprocessor version (see experiment/cucumber-cypress). Only one + // throwaway feature exists right now (login.feature); the rest of the + // suite is still plain .cy.ts, matched by the default `**/*.cy.ts` + // pattern alongside `**/*.feature`. + specPattern: ["cypress/e2e/**/*.cy.ts", "cypress/e2e/**/*.feature"], + async setupNodeEvents(on, config) { // Disable GPU for headless/sandboxed environments (e.g. CI containers) // where no GPU device is available. on("before:browser:launch", (browser, launchOptions) => { @@ -12,6 +21,16 @@ export default defineConfig({ } return launchOptions; }); + + await addCucumberPreprocessorPlugin(on, config); + on( + "file:preprocessor", + createBundler({ + plugins: [createEsbuildPlugin(config)], + }), + ); + + return config; }, }, }); diff --git a/apps/web/cypress/e2e/login-smoke.feature b/apps/web/cypress/e2e/login-smoke.feature new file mode 100644 index 0000000..0d0ef5c --- /dev/null +++ b/apps/web/cypress/e2e/login-smoke.feature @@ -0,0 +1,12 @@ +Feature: Login screen (throwaway smoke test) + Just checking that Gherkin + Cypress actually work end to end with the + currently installed preprocessor version — not meant to stay in the + suite long-term. + + Scenario: A visitor can type their credentials into the login screen + Given I am not signed in + When I visit "/login" + And I fill in the "email" field with "alice@example.com" + And I fill in the "password" field with "correct-horse-battery-staple" + Then the "email" field should have the value "alice@example.com" + And the "password" field should have the value "correct-horse-battery-staple" diff --git a/apps/web/cypress/e2e/login-smoke.steps.ts b/apps/web/cypress/e2e/login-smoke.steps.ts new file mode 100644 index 0000000..edcf30f --- /dev/null +++ b/apps/web/cypress/e2e/login-smoke.steps.ts @@ -0,0 +1,21 @@ +import { Given, Then, When } from "@badeball/cypress-cucumber-preprocessor"; + +// Throwaway smoke test — see login-smoke.feature. Steps are deliberately +// minimal/self-contained here rather than shared, since this whole file is +// meant to be deleted once it's proven the preprocessor works. + +Given("I am not signed in", () => { + cy.intercept("GET", "**/auth/me", { statusCode: 401 }); +}); + +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}`).type(value); +}); + +Then("the {string} field should have the value {string}", (fieldId: string, value: string) => { + cy.get(`#${fieldId}`).should("have.value", value); +});