Skip to content
Open
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
7 changes: 5 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
],
"cucumberautocomplete.syncfeatures": "public/mobile-app/tests/features/*.feature",
"cucumberautocomplete.smartSnippets": true,
"cucumber.features": ["public/mobile-app/tests/features*.feature"],
"cucumber.glue": ["public/mobile-app/tests/features/step_definitions/*.js"]
"cucumber.features": ["public/mobile-app/tests/features/*.feature"],
"cucumber.glue": ["public/mobile-app/tests/features/step_definitions/*.cjs"],
"config.webserver": {
"reuseExistingServer": true
}
}
13 changes: 9 additions & 4 deletions CONTRIBUTING-BEHAVIOR.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,16 @@ The following plugins have been tested

Don't forget to tag the language in the first line of the feature file if a language other than English is used.

To launch a Cucumber scenario from PyCharm, don't use a ~~Behave~~ configuration but a **Cucumber.js** configuration,
after having launched `npm install` if needed.

## 5. Launching Acceptance Tests

Currently, there is no automated test execution integrated into the CI/CD pipeline. However, you can manually run acceptance tests

### Install playwright browser

**Warning**: this installs the different browsers needed for playwright e2e tests, and requires 500 MiB.

Launch `npx playwright install` after having launched `npm install` in `/public/mobile-app` directory if needed.

### Launching a test
- using **PyCharm** with the Cucumber.js and Gherkin plugins installed : After having launched `npm install` if needed, simply open your feature files in PyCharm and use the provided tools to execute and debug your scenarios. Don't use a ~~Behave~~ configuration but a **Cucumber.js** configuration.
- in a **terminal** : go to directory `/public/mobile-app directory` and launch `npx cucumber-js tests/features` or `npm run test:cucumber`.
- in a **terminal** : go to directory `/public/mobile-app directory` and launch `npx cucumber-js tests/features` or `npm run test:cucumber` (the latest script is currently configured to launch only scenarios tagged as @OK).
13 changes: 12 additions & 1 deletion public/mobile-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions public/mobile-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"test:unit": "vitest",
"test": "npm run test:unit -- --run && npm run test:e2e",
"test:e2e": "playwright test",
"test:cucumber": "cucumber-js tests/features"
"test:cucumber": "cucumber-js tests/features --tags @ok"
},
"dependencies": {
"@eslint/compat": "^1.2.5",
Expand Down Expand Up @@ -45,6 +45,7 @@
"devDependencies": {
"@cucumber/cucumber": "^12.1.0",
"@vitejs/plugin-basic-ssl": "^2.1.0",
"vitest-websocket-mock": "^0.5.0"
"vitest-websocket-mock": "^0.5.0",
"cucumber-js": "^1.0.0"
}
}
49 changes: 45 additions & 4 deletions public/mobile-app/tests/features/france-connexion.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,54 @@ Fonctionnalité: France Connect et Initialisation des données usager
Quand l'usager clique sur le lien allant vers la démo
Alors l'usager va vers la démo

Scénario: enregistrement d'un usager au service de notification d'AMI via France Connect
@ok
Plan du scénario: enregistrement d'un usager au service de notification d'AMI via France Connect
Etant donné que l'usager est sur la home page non connectée de l'application AMI
Quand l'usager se connecte sur AMI via France Connect en tant que "Camille" et suit le process de france connexion
Quand l'usager se connecte sur AMI via France Connect en tant que "<login>" et suit le process de france connexion
Alors l'usager devrait arriver sur la home page connectée de l'application AMI
# Quand on aura une donnée précise (adresse particulière ?) on le précisera dans le step ci-dessous
Et les données de l'usager "Camille" récupérées depuis l'API Particulier devraient être affichées
Et l'usager "Camille" devrait être enregistrée
Et les données de l'usager "<login>" récupérées depuis l'API Particulier devraient être affichées
Et l'usager "<login>" devrait être enregistrée

Exemples:
| login |
| test |
| avec_nom_dusage |
# | nom_composé |
# | nom_50+_caractères |
# | carac_speciaux |
# | plusieurs_prénoms_2 |
# | plusieurs_prénoms_3 |
# | prénom_composé |
# | prénom_composé_avec_espace |
# | caractères_spéciaux |
# | nom_prénom_long |
# | moins_16_ans |
# | moins_18_ans |
# | moins_25_ans |
# | genre_indéfini |
# | sans_prenom |
# | sans_nom_naissance |
# | sans_nom_dusage |
# | sans_mail |
# | sans_telephone |
# | sans_mail_sans_tel |
# | sans_genre |
# | sans_birthplace |
# | test_CORSE_2A |
# | test_CORSE_2B |
# | naissance_Algérie |
# | naissance_Maroc |
# | naissance_Portugal |
# | naissance_Belgique |
# | naissance_Espagne |
# | naissance_Italie |
# | naissance_polynesie_française |
# | naissance_wallis_futuna |
# | naissance_etranger_birthplace_cog |
# | naissance_etranger_birthplace_texte |
# | étranger_présumé_né_jour |
# | étranger_présumé_né_jour_et_mois |

# Remarque : une première itération peut ignorer tout le process FC pour juste renvoyer des données en dur / aléatoire.

Expand Down
53 changes: 42 additions & 11 deletions public/mobile-app/tests/features/step_definitions/default-steps.cjs
Original file line number Diff line number Diff line change
@@ -1,23 +1,54 @@
const { Given,
Then,
// When
} = require('@cucumber/cucumber');
const { Given, When, Then, Before, After, setDefaultTimeout, context } = require("@cucumber/cucumber");

const { chromium, expect, defineConfig } = require("@playwright/test");

const { Page } = require("playwright");

setDefaultTimeout(60 * 1000);

let page, browserContext, browser;

Before(async function () {
browser = await chromium.launch(
//uncomment this line to see the tests in live
//{ headless: false, slowMo: 1500}
);
browserContext = await browser.newContext(
//{baseURL: "https://localhost:4173/", ignoreHTTPSErrors: true}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: do we need to keep this comment?

{baseURL: "https://ami-back-staging.osc-fr1.scalingo.io/"}
);
page = await browserContext.newPage();
});

After(async function () {
await browserContext.close();
await browser.close();
})

Given(
"l'usager se connecte sur AMI via France Connect en tant que {string} et suit le process de france connexion",
function (s) {
// Write code here that turns the phrase above into concrete actions
async (s) => {
await page.locator('#fr-connect-button').click()
await page.getByTestId('idp-e1e90d50-cca0-4a85-9db3-0bcc190ee6f7').click()
await page.getByLabel('Identifiant').fill(s)
await page.getByLabel('Mot de passe').fill('123')
await page.getByRole('button', {name: 'Valider'}).click()
// await page.getByRole('button', {name: 'Continuer sur AMI'}).click()
}
);

Given("l'usager est sur la home page non connectée de l'application AMI", function () {
// Write code here that turns the phrase above into concrete actions
Given("l'usager est sur la home page non connectée de l'application AMI", async () => {
await page.goto("/")
});

Then("l'usager devrait arriver sur la home page connectée de l'application AMI", async () => {
await expect(page.locator('.user-profile')).toBeVisible()
});

Then("l'usager devrait arriver sur la home page connectée de l'application AMI", function () {
// Write code here that turns the phrase above into concrete actions
Then("les données de l'usager {string} récupérées depuis l'API Particulier devraient être affichées", function (s) {
//console.log(s);
});

Then("l'usager {string} devrait être enregistré(e)", function (s) {
console.log(s);
//console.log(s);
});