Skip to content

Commit

Permalink
test(e2e): connexion testing
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasduteil committed Dec 13, 2023
1 parent fc00658 commit da8ce30
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 22 deletions.
2 changes: 1 addition & 1 deletion e2e/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { defineConfig } from "cypress";

export default defineConfig({
e2e: {
baseUrl: "https://duckduckgo.com",
baseUrl: "http://localhost:3000",
specPattern: "**/*.feature",
setupNodeEvents,
supportFile: false,
Expand Down
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();
});
}
);
4 changes: 0 additions & 4 deletions e2e/features/duckduckgo.feature

This file was deleted.

16 changes: 0 additions & 16 deletions e2e/features/duckduckgo.ts

This file was deleted.

2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ app.use(
cookieSession({
name: "mcp_session",
keys: ["key1", "key2"],
}),
})
);
app.use(morgan("combined"));

Expand Down

0 comments on commit da8ce30

Please sign in to comment.