Skip to content

Commit

Permalink
chore: add doc to run tests on local machine
Browse files Browse the repository at this point in the history
  • Loading branch information
achauve committed Sep 10, 2024
1 parent dd2c9af commit 78ca23c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,24 @@ Afin de conserver les données dans le cas d'une mise à jour du schéma de la b

`docker compose exec -ti postgres psql -U <PG_VAO_USER>`

### Tests end-to-end

Installer les paquets (sans passer par docker) :

`yarn`

Installer les navigateurs (headless) utilisés par Playwright :

`yarn playwright install`

Lancer les tests (attention il faut avoir démarré la stack locale via docker, cf plus haut) :

`yarn tests:e2e`

Pour débugger ou écrire de nouveaux tests, utiliser l'interface graphique de Playwright :

`yarn tests:e2e:ui`

## Kubernetes

## CI/CD
Expand Down
9 changes: 8 additions & 1 deletion e2e/register-login-organisateur.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import path from "path";

const baseUrl =
process.env.E2E_BASE_URL || "vao-main.ovh.fabrique.social.gouv.fr";
const runLocal = process.env.E2E_LOCAL === "true";

const username = process.env.E2E_USERNAME || `e2e-${randomUUID()}@test.com`;
const password = "Pizza1234567;";
Expand All @@ -12,7 +13,13 @@ const password = "Pizza1234567;";
test.describe.configure({ mode: "serial" });

function getUrl(prefix?: string) {
return `https://${prefix ? prefix + "-" : ""}${baseUrl}`;
if (runLocal) {
if (prefix === "maildev") {
return `http://localhost:1080`;
}
return `http://localhost:3000`;
}
return `${runLocal ? "http" : "https"}://${prefix ? prefix + "-" : ""}${baseUrl}`;
}

async function login(page) {
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"lint:frontend-usagers": "yarn --cwd ./packages/frontend-usagers run lint",
"lint:frontend-bo": "yarn --cwd ./packages/frontend-bo run lint",
"lint:shared": "yarn --cwd ./packages/shared run lint",
"knex": "POSTGRES_HOST=localhost POSTGRES_PORT=5436 env-cmd --no-override knex --cwd ./packages/migrations/src"
"knex": "POSTGRES_HOST=localhost POSTGRES_PORT=5436 env-cmd --no-override knex --cwd ./packages/migrations/src",
"tests:e2e": "E2E_LOCAL=true playwright test",
"tests:e2e:ui": "E2E_LOCAL=true playwright test --ui"
},
"devDependencies": {
"@commitlint/cli": "^19.0.0",
Expand Down

0 comments on commit 78ca23c

Please sign in to comment.