Skip to content

Commit

Permalink
test(e2e): group test in folders (#656)
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasduteil authored Aug 14, 2024
1 parent 32bc23f commit 7c0ef58
Show file tree
Hide file tree
Showing 82 changed files with 29 additions and 32 deletions.
30 changes: 15 additions & 15 deletions .github/workflows/end-to-end.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,32 @@ jobs:
fail-fast: false
matrix:
e2e_test:
- activate_totp
- check_email_deliverability
- delete_account
- delete_totp
- join_collectivite_territoriale_official_contact_domain
- join_org_with_verified_domain
- join_must_confirm
- join_org_with_gouv_fr_domain
- join_org_with_trackdechets_domain
- join_org_with_verified_domain
- join_with_code_sent_to_official_contact_email
- join_with_code_sent_to_official_educ_nat_contact_email
- join_with_official_contact_email
- join_with_sponsorship
- reauthenticate_on_admin_page
- redirect_after_session_expiration
- reset_password
- set_info_after_account_provisioning
- signin_from_agentconnect_client
- signin_from_legacy_client
- signin_from_standard_client
- signin_with_email_verification_renewal
- signin_with_magic_link
- signup_entreprise_unipersonnelle
- redirect_after_session_expiration
- reset_password
- join_must_confirm
- set_info_after_account_provisioning
- signin_with_totp
- reauthenticate_on_admin_page
- check_email_deliverability
- delete_account
- delete_totp
- update_totp_application
- activate_totp
- signup_entreprise_unipersonnelle
- update_personal_information
- update_totp_application
runs-on: ubuntu-22.04
services:
moncomptepro-standard-client:
Expand Down Expand Up @@ -129,16 +129,16 @@ jobs:
node-version-file: package.json
- run: npm ci --include=dev
- run: npm run migrate up
- run: npm run fixtures:load-ci -- cypress/fixtures/${{ matrix.e2e_test }}.sql
- run: npm run fixtures:load-ci -- cypress/e2e/${{ matrix.e2e_test }}/fixtures.sql
- run: npm run update-organization-info -- 500
- name: Cypress run
uses: cypress-io/[email protected]
with:
wait-on: ${{ env.MONCOMPTEPRO_HOST }}/users/start-sign-in
build: npm run build:assets
start: npx dotenvx run -f cypress/env/${{ matrix.e2e_test }}.conf --overload -- npm start
start: npx dotenvx run -f cypress/e2e/${{ matrix.e2e_test }}/env.conf --overload -- npm start
install: false
spec: cypress/e2e/${{ matrix.e2e_test }}.cy.js
spec: cypress/e2e/${{ matrix.e2e_test }}/index.cy.js
env:
NODE_ENV: production
# Store tests runs in case of failure
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ moncomptepro.conf
.idea
.vscode

cypress/downloads
cypress/screenshots
cypress/videos
!cypress/e2e/*/fixtures.sql

/build/*
!/build/.keep
Expand Down
14 changes: 3 additions & 11 deletions cypress/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
# Run cypress locally

## Fast with a script

You can use `./scripts/test.sh` to run tests locally. Run it to get usage help. You can either let the script run cypress tests by itself, or just use it to quickly prepare your local env with test-specific env/fixtures and do manual tests.

The script will error out if it doesn’t find the necessary env vars. Ask a teammate for specific env vars and put the values in your `.env`.

:information_source: By default, the script runs the test node server on port 3002. This is done so that you can keep your default local dev instance up while running the tests.

## Step by step with command lines

### Setup env vars
Expand All @@ -28,15 +20,15 @@ DO_NOT_RATE_LIMIT=True
Note that this will delete your database. Load the specific fixtures in the database:

```bash
ENABLE_DATABASE_DELETION=True npx run-s delete-database "migrate up" "fixtures:load-ci cypress/fixtures/redirect_after_session_expiration.sql" "update-organization-info 2000"
ENABLE_DATABASE_DELETION=True npm run delete-database ; npx run-s "migrate up" "fixtures:load-ci cypress/e2e/redirect_after_session_expiration/fixtures.sql" "update-organization-info 2000"
```

### Start MonComptePro with the test configuration

Then run the app with the specific env vars:

```bash
npx dotenvx run -f cypress/env/redirect_after_session_expiration.conf -- npm run dev
npx dotenvx run -f cypress/e2e/redirect_after_session_expiration/env.conf -- npm run dev
```

## Run Cypress
Expand All @@ -45,7 +37,7 @@ On your host, run the tests

```bash
export CYPRESS_MAILSLURP_API_KEY=ask_a_teammate
npx cypress run --headed --spec "cypress/e2e/redirect_after_session_expiration.cy.js"
npx cypress run --headed --spec "cypress/e2e/redirect_after_session_expiration/index.cy.js"
```

## About test client used in e2e test
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//

import { getVerificationWordsFromEmail } from "../support/get-from-email.js";
import { getVerificationWordsFromEmail } from "#cypress/support/get-from-email.js";

describe("join organizations", () => {
before(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//

import { getVerificationWordsFromEmail } from "../support/get-from-email.js";
import { getVerificationWordsFromEmail } from "#cypress/support/get-from-email.js";

describe("join organizations", () => {
before(() => {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//

import { getVerificationCodeFromEmail } from "../support/get-from-email.js";
import { getVerificationCodeFromEmail } from "#cypress/support/get-from-email.js";

describe("set info after account provisioning", () => {
before(() => {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//

import { getVerificationCodeFromEmail } from "../support/get-from-email.js";
import { getVerificationCodeFromEmail } from "#cypress/support/get-from-email.js";

describe("sign-in with email verification renewal", () => {
before(() => {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import {
getMagicLinkFromEmail,
getVerificationCodeFromEmail,
} from "../support/get-from-email.js";
} from "#cypress/support/get-from-email.js";

describe("sign-in with magic link", () => {
before(() => {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//

import { getVerificationCodeFromEmail } from "../support/get-from-email.js";
import { getVerificationCodeFromEmail } from "#cypress/support/get-from-email.js";

describe("Signup into new entreprise unipersonnelle", () => {
before(() => {
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"version": "1.0.0",
"license": "AGPL-3.0",
"type": "module",
"imports": {
"#cypress/*": "./cypress/*"
},
"main": "src/index.js",
"scripts": {
"build": "run-s build:**",
Expand Down

0 comments on commit 7c0ef58

Please sign in to comment.