Skip to content

Commit

Permalink
test(e2e): add dummy e2e tests (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasduteil authored Dec 13, 2023
1 parent 035f259 commit acd9938
Show file tree
Hide file tree
Showing 8 changed files with 5,275 additions and 2 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,21 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
cache: "npm"
node-version-file: package.json
- run: npm ci

e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci
- name: Cypress run
uses: cypress-io/github-action@v6
with:
working-directory: ./e2e
start: npm start
wait-on: http://localhost:3000
35 changes: 35 additions & 0 deletions e2e/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//

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:3000",
specPattern: "**/*.feature",
setupNodeEvents,
supportFile: false,
},
});

//

async function setupNodeEvents(
on: Cypress.PluginEvents,
config: Cypress.PluginConfigOptions
) {
await addCucumberPreprocessorPlugin(on, config);

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

return config;
}
16 changes: 16 additions & 0 deletions e2e/features/connexion.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#language: fr
Fonctionnalité: Connexion de [email protected]

Scénario: Connexion d'un utilisateur
Etant donné que je navigue sur la page
Alors je vois "Bonjour monde !"
Quand je clique sur le bouton MonComptePro

Quand je me connecte en tant que user@yopmail.com sur moncomptepro
Et je vois "Votre organisation de rattachement" sur moncomptepro
Et je click sur "Continuer" sur moncomptepro

Alors je suis redirigé sur "/"
Et je vois "Information utilisateur"
Et je vois "[email protected]"
Et je vois "International knowledge practice leader"
58 changes: 58 additions & 0 deletions e2e/features/connexion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//

import { Given, Then, When } from "@badeball/cypress-cucumber-preprocessor";

//

Given("je navigue sur la page", () => {
cy.visit("/");
});

When("je clique sur le bouton MonComptePro", () => {
cy.get(".moncomptepro-button").click();
});

When("je suis redirigé sur {string}", (path: string) => {
cy.url().should("contain", path);
});

Then("je vois {string}", function (text: string) {
cy.contains(text);
});

//

When("je vois {string} sur moncomptepro", (_text: string) => {
cy.origin(
"https://app-test.moncomptepro.beta.gouv.fr",
{ 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();
}
);
});

When(
"je me connecte en tant que [email protected] sur moncomptepro",
(path: string) => {
cy.origin("https://app-test.moncomptepro.beta.gouv.fr", () => {
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")
.click();
});
}
);
Loading

0 comments on commit acd9938

Please sign in to comment.