diff --git a/README.md b/README.md index f5b1fd8..34eeb43 100644 --- a/README.md +++ b/README.md @@ -78,3 +78,11 @@ authorized_scopes: openid email profile organization ``` More clients are available at: https://github.com/betagouv/moncomptepro/blob/master/scripts/fixtures.sql + +## Run Cypress test + +``` +cd e2e +npm i +npm test +``` diff --git a/e2e/.env b/e2e/.env new file mode 120000 index 0000000..4a82335 --- /dev/null +++ b/e2e/.env @@ -0,0 +1 @@ +../.env \ No newline at end of file diff --git a/e2e/cypress.config.ts b/e2e/cypress.config.ts index 596f0be..ccdb22d 100644 --- a/e2e/cypress.config.ts +++ b/e2e/cypress.config.ts @@ -4,7 +4,7 @@ import { addCucumberPreprocessorPlugin } from "@badeball/cypress-cucumber-prepro import { createEsbuildPlugin } from "@badeball/cypress-cucumber-preprocessor/esbuild"; import createBundler from "@bahmutov/cypress-esbuild-preprocessor"; import { defineConfig } from "cypress"; - +import "dotenv/config"; // export default defineConfig({ @@ -14,13 +14,16 @@ export default defineConfig({ setupNodeEvents, supportFile: false, }, + env: { + MCP_PROVIDER: process.env.MCP_PROVIDER, + }, }); // async function setupNodeEvents( on: Cypress.PluginEvents, - config: Cypress.PluginConfigOptions + config: Cypress.PluginConfigOptions, ) { await addCucumberPreprocessorPlugin(on, config); @@ -28,7 +31,7 @@ async function setupNodeEvents( "file:preprocessor", createBundler({ plugins: [createEsbuildPlugin(config)], - }) + }), ); return config; diff --git a/e2e/features/connexion.ts b/e2e/features/connexion.ts index 149d3d4..6ebf8ea 100644 --- a/e2e/features/connexion.ts +++ b/e2e/features/connexion.ts @@ -23,36 +23,28 @@ Then("je vois {string}", function (text: string) { // When("je vois {string} sur moncomptepro", (_text: string) => { - cy.origin( - "https://app-test.moncomptepro.beta.gouv.fr", - { args: _text }, - (text) => { - cy.contains(text); - } - ); + cy.origin(Cypress.env("MCP_PROVIDER"), { args: _text }, (text) => { + cy.contains(text); + }); }); When("je click sur {string} sur moncomptepro", (_text: string) => { - cy.origin( - "https://app-test.moncomptepro.beta.gouv.fr", - { args: _text }, - (text) => { - cy.contains(text).click(); - } - ); + cy.origin(Cypress.env("MCP_PROVIDER"), { args: _text }, (text) => { + cy.contains(text).click(); + }); }); When( "je me connecte en tant que user@yopmail.com sur moncomptepro", (path: string) => { - cy.origin("https://app-test.moncomptepro.beta.gouv.fr", () => { + cy.origin(Cypress.env("MCP_PROVIDER"), () => { cy.get('[name="login"]').type("user@yopmail.com"); cy.get('[type="submit"]').click(); cy.get('[name="password"]').type("user@yopmail.com"); cy.get('[action="/users/sign-in"] [type="submit"]') - .contains("Se connecter") + .contains("S’identifier") .click(); }); - } + }, );