-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP refactor: more independent e2e tests
- Loading branch information
Showing
12 changed files
with
117 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,13 +13,13 @@ env: | |
PGDATABASE: api-auth-test | ||
PGHOST: 127.0.0.1 | ||
PGPORT: 5432 | ||
DATABASE_URL: postgres://api-auth:[email protected]:5432/api-auth-test | ||
SENDINBLUE_API_KEY: ${{ secrets.SENDINBLUE_API_KEY }} | ||
MONCOMPTEPRO_HOST: http://localhost:3000 | ||
DO_NOT_SEND_MAIL: "False" | ||
DO_NOT_VALIDATE_MAIL: "True" | ||
DO_NOT_RATE_LIMIT: "True" | ||
DO_NOT_USE_ANNUAIRE_EMAILS: "True" | ||
TEST_CONTACT_EMAIL: "[email protected]" | ||
SESSION_COOKIE_SECRET: secret | ||
DEBOUNCE_API_KEY: | ||
SENTRY_DSN: | ||
|
@@ -31,6 +31,9 @@ env: | |
|
||
jobs: | ||
test: | ||
strategy: | ||
matrix: | ||
e2e_test: [ join_collectivite_territoriale ] | ||
runs-on: ubuntu-20.04 | ||
services: | ||
redis: | ||
|
@@ -63,21 +66,22 @@ jobs: | |
${{ runner.os }}-build- | ||
${{ runner.os }}- | ||
- run: npm ci | ||
- run: npm run load-ci-fixtures | ||
env: | ||
DATABASE_URL: postgres://${{ env.PGUSER }}:${{ env.PGPASSWORD }}@127.0.0.1:${{ env.PGPORT }}/${{ env.PGDATABASE }} | ||
- run: npm install cypress@12 | ||
- run: npm run migrate up | ||
- run: npm run load-ci-fixtures -- scripts/fixtures/${{ matrix.e2e_test }}.sql | ||
- run: npm run update-organization-info -- 2000 | ||
- name: Cypress run | ||
uses: cypress-io/github-action@v5 | ||
with: | ||
wait-on: ${{ env.MONCOMPTEPRO_HOST }}/users/start-sign-in | ||
build: npm run build | ||
start: npm start | ||
install: false | ||
spec: cypress/e2e/${{ matrix.e2e_test }}.cy.js | ||
env: | ||
NODE_ENV: production | ||
DATABASE_URL: postgres://${{ env.PGUSER }}:${{ env.PGPASSWORD }}@127.0.0.1:${{ env.PGPORT }}/${{ env.PGDATABASE }} | ||
CYPRESS_MONCOMPTEPRO_HOST: ${{ env.MONCOMPTEPRO_HOST }} | ||
TEST_CONTACT_EMAIL: "[email protected]" | ||
- run: npm run delete-database | ||
# Store tests runs in case of failure | ||
- uses: actions/upload-artifact@v3 | ||
if: failure() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ cd /opt/apps/api-auth/current | |
export $(cat /etc/api-auth.conf | xargs) | ||
export DATABASE_URL=postgres://api-auth:api-auth@localhost:5432/api-auth-test | ||
export PGDATABASE=api-auth-test | ||
npm run load-ci-fixtures | ||
npm run migrate up | ||
exit | ||
``` | ||
|
||
|
@@ -27,10 +27,10 @@ export DO_NOT_RATE_LIMIT=True | |
export DO_NOT_USE_ANNUAIRE_EMAILS=True | ||
export TEST_CONTACT_EMAIL=34c5063f-81c0-4d09-9d0b-a7502f844cdf@mailslurp.com | ||
export DATABASE_URL=postgres://api-auth:[email protected]:5432/api-auth-test | ||
|
||
export DO_NOT_SEND_MAIL=False | ||
export SENDINBLUE_API_KEY="xxx" | ||
npm run build | ||
npm run start | ||
npm run build && npm run start | ||
``` | ||
|
||
On your host, install cypress: | ||
|
@@ -48,6 +48,13 @@ export CYPRESS_MONCOMPTEPRO_HOST=https://app-development.moncomptepro.beta.gouv. | |
cypress open | ||
``` | ||
|
||
```bash | ||
export PGDATABASE=api-auth-test | ||
export DATABASE_URL=postgres://api-auth:[email protected]:5432/api-auth-test | ||
npm run delete-database | ||
npm run load-ci-fixtures scripts/fixtures/join_collectivite_territoriale.sql | ||
npm run update-organization-info 2000 | ||
``` | ||
reset user table | ||
|
||
```bash | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
const host = Cypress.env('MONCOMPTEPRO_HOST') || 'http://localhost:3000'; | ||
import { MONCOMPTEPRO_HOST } from '../../src/env'; | ||
|
||
describe('join organizations', () => { | ||
before(() => { | ||
|
@@ -20,20 +20,7 @@ describe('join organizations', () => { | |
'password123' | ||
); | ||
|
||
cy.visit(`${host}/users/join-organization`); | ||
cy.get('[name="siret"]').type('21340126800130'); | ||
cy.get('[type="submit"]').click(); | ||
|
||
cy.contains('Votre compte est créé'); | ||
}); | ||
|
||
it('following members can join the new organization if using the same email domain', function() { | ||
cy.login( | ||
'[email protected]', | ||
'password123' | ||
); | ||
|
||
cy.visit(`${host}/users/join-organization`); | ||
cy.visit(`${MONCOMPTEPRO_HOST}/users/join-organization`); | ||
cy.get('[name="siret"]').type('21340126800130'); | ||
cy.get('[type="submit"]').click(); | ||
|
||
|
@@ -46,7 +33,7 @@ describe('join organizations', () => { | |
'password123' | ||
); | ||
|
||
cy.visit(`${host}/users/join-organization`); | ||
cy.visit(`${MONCOMPTEPRO_HOST}/users/join-organization`); | ||
cy.get('[name="siret"]').type('21740056300011'); | ||
cy.get('[type="submit"]').click(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
DELETE FROM users_organizations; | ||
DELETE FROM moderations; | ||
DELETE FROM organizations; | ||
DELETE FROM users_oidc_clients; | ||
DELETE FROM users; | ||
DELETE FROM oidc_clients; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
INSERT INTO users | ||
(id, email, email_verified, email_verified_at, encrypted_password, created_at, updated_at, given_name, family_name, | ||
phone_number, job) | ||
VALUES | ||
(1, '[email protected]', true, CURRENT_TIMESTAMP, '$2a$10$kzY3LINL6..50Fy9shWCcuNlRfYq0ft5lS.KCcJ5PzrhlWfKK4NIO', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Jean', 'User1', '0123456789', 'Sbire'), | ||
(2, '[email protected]', true, CURRENT_TIMESTAMP, '$2a$10$kzY3LINL6..50Fy9shWCcuNlRfYq0ft5lS.KCcJ5PzrhlWfKK4NIO', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Jean', 'User2', '0123456789', 'Sbire'); | ||
|
||
|
||
INSERT INTO organizations | ||
(id, siret, verified_email_domains, authorized_email_domains, created_at, updated_at) | ||
VALUES | ||
-- COMMUNE DE CLAMART - Mairie | ||
(1, '21920023500014', '{}', '{}', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); | ||
|
||
-- user are already in an organization to skip organization suggestion | ||
INSERT INTO users_organizations | ||
(user_id, organization_id, verification_type, authentication_by_peers_type, has_been_greeted) | ||
VALUES | ||
(1, 1, 'verified_email_domain', 'all_members_notified', true), | ||
(2, 1, 'verified_email_domain', 'all_members_notified', true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
INSERT INTO users | ||
(id, email, email_verified, email_verified_at, encrypted_password, created_at, updated_at, given_name, family_name, | ||
phone_number, job) | ||
VALUES | ||
(1, | ||
'[email protected]', | ||
'true', | ||
CURRENT_TIMESTAMP, | ||
'$2a$10$5oxACsw3NngPAXALyB2G3u/C0Ej0CFUyPJhPtyyHP737Xn3lW1Mv.', -- password is '[email protected]' | ||
CURRENT_TIMESTAMP, | ||
CURRENT_TIMESTAMP, | ||
'Jean', | ||
'User', | ||
'0123456789', | ||
'International knowledge practice leader'), | ||
-- password for the following users is 'password123' | ||
(2, '[email protected]', 'true', CURRENT_TIMESTAMP, '$2a$10$kzY3LINL6..50Fy9shWCcuNlRfYq0ft5lS.KCcJ5PzrhlWfKK4NIO', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Jean', 'User2', '0123456789', 'Sbire'), | ||
(3, '[email protected]', 'true', CURRENT_TIMESTAMP, '$2a$10$kzY3LINL6..50Fy9shWCcuNlRfYq0ft5lS.KCcJ5PzrhlWfKK4NIO', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Jean', 'User3', '0123456789', 'Sbire'), | ||
(4, '[email protected]', 'true', CURRENT_TIMESTAMP, '$2a$10$kzY3LINL6..50Fy9shWCcuNlRfYq0ft5lS.KCcJ5PzrhlWfKK4NIO', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Jean', 'User4', '0123456789', 'Sbire'), | ||
(5, '[email protected]', 'true', CURRENT_TIMESTAMP, '$2a$10$kzY3LINL6..50Fy9shWCcuNlRfYq0ft5lS.KCcJ5PzrhlWfKK4NIO', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Jean', 'User5', '0123456789', 'Sbire'), | ||
(6, '[email protected]', 'true', CURRENT_TIMESTAMP, '$2a$10$kzY3LINL6..50Fy9shWCcuNlRfYq0ft5lS.KCcJ5PzrhlWfKK4NIO', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Jean', 'User6', '0123456789', 'Sbire'), | ||
(7, '[email protected]', 'true', CURRENT_TIMESTAMP, '$2a$10$kzY3LINL6..50Fy9shWCcuNlRfYq0ft5lS.KCcJ5PzrhlWfKK4NIO', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Jean', 'User7', '0123456789', 'Sbire'); | ||
|
||
INSERT INTO organizations | ||
(id, siret, verified_email_domains, authorized_email_domains, created_at, updated_at) | ||
VALUES | ||
-- COMMUNE DE CLAMART - Mairie | ||
(1, '21920023500014', '{"mailslurp.com"}', '{"mailslurp.com"}', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), | ||
-- COMMUNE DE CLAMART - Service assainissement | ||
(2, '21920023500394', '{}', '{"mailslurp.com"}', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), | ||
-- DIRECTION INTERMINISTERIELLE DU NUMERIQUE (DINUM) | ||
(3, '13002526500013', '{"beta.gouv.fr"}', '{"beta.gouv.fr"}', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); | ||
|
||
INSERT INTO users_organizations | ||
(user_id, organization_id, verification_type, authentication_by_peers_type, has_been_greeted) | ||
VALUES | ||
(3, 1, 'verified_email_domain', 'all_members_notified', true), | ||
(4, 1, 'verified_email_domain', 'all_members_notified', true), | ||
(5, 1, 'verified_email_domain', 'all_members_notified', true), | ||
(6, 1, 'verified_email_domain', 'all_members_notified', true), | ||
(7, 1, 'verified_email_domain', 'all_members_notified', true), | ||
(3, 2, 'verified_email_domain', 'all_members_notified', true), | ||
(4, 2, 'verified_email_domain', 'all_members_notified', true), | ||
(5, 2, 'verified_email_domain', 'all_members_notified', true), | ||
(6, 2, 'verified_email_domain', 'all_members_notified', true), | ||
(7, 2, 'verified_email_domain', 'all_members_notified', true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters