Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(e2e): add dummy e2e tests #3

Merged
merged 7 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 [email protected] 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