Skip to content

Commit

Permalink
fix: e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rdubigny committed Mar 14, 2024
1 parent 6679d26 commit da9de6d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
1 change: 1 addition & 0 deletions e2e/.env
9 changes: 6 additions & 3 deletions e2e/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -14,21 +14,24 @@ 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);

on(
"file:preprocessor",
createBundler({
plugins: [createEsbuildPlugin(config)],
})
}),
);

return config;
Expand Down
26 changes: 9 additions & 17 deletions e2e/features/connexion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected] sur moncomptepro",
(path: string) => {
cy.origin("https://app-test.moncomptepro.beta.gouv.fr", () => {
cy.origin(Cypress.env("MCP_PROVIDER"), () => {
cy.get('[name="login"]').type("[email protected]");
cy.get('[type="submit"]').click();

cy.get('[name="password"]').type("[email protected]");
cy.get('[action="/users/sign-in"] [type="submit"]')
.contains("Se connecter")
.contains("S’identifier")
.click();
});
}
},
);

0 comments on commit da9de6d

Please sign in to comment.