From 6823bde71364eb4fc598848b73757b988d99d5d9 Mon Sep 17 00:00:00 2001 From: schiwaa Date: Wed, 4 Dec 2024 20:59:57 +0100 Subject: [PATCH] re-seed db by running the originial init script; in the container added as a volume for now --- docker-compose.test.yml | 1 + frontend-e2e/cypress/e2e/experimental.cy.js | 30 ++++++++++++++------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/docker-compose.test.yml b/docker-compose.test.yml index 499afe7e..634b2c5d 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -42,6 +42,7 @@ services: - .env.test volumes: - ./frontend-e2e/:/app + - ./bin/init-data/stemmarest/:/app/cypress/stemmarest entrypoint: > /bin/bash -c "sleep 120 && # Waiting for other services to be ready npm install -g npm@latest && diff --git a/frontend-e2e/cypress/e2e/experimental.cy.js b/frontend-e2e/cypress/e2e/experimental.cy.js index e2b31287..93139d04 100644 --- a/frontend-e2e/cypress/e2e/experimental.cy.js +++ b/frontend-e2e/cypress/e2e/experimental.cy.js @@ -120,7 +120,7 @@ describe('delete all traditions and users in the api, re-seed the db', () => { }) }) }) - // DON'T cy.reload() > Cannot read properties of undefined (reading 'name') + // DON'T cy.reload() ==> Cannot read properties of undefined (reading 'name'). TO DO: check why cy.log('All traditions deleted.') cy.log('Delete all users:') @@ -139,15 +139,25 @@ describe('delete all traditions and users in the api, re-seed the db', () => { cy.log('All users deleted.') // re-seed the db - cy.exec('./../bin/init-data/stemmarest/init_test_data.sh', - // cy.exec('./cypress/support/init_test_data.sh', - { env: { STEMMAREST_ENDPOINT: Cypress.env('CY_STEMMAREST_ENDPOINT') } } - ).then(function(result) { - cy.log(result.code) - cy.log(result.stdout) - cy.log(result.stderr) - }) - cy.reload() + if (Cypress.env('CY_MODE') === 'headed') { // skip when in headless mode + cy.exec('./../bin/init-data/stemmarest/init_test_data.sh', + { env: { STEMMAREST_ENDPOINT: Cypress.env('CY_STEMMAREST_ENDPOINT') } } + ).then(function(result) { + cy.log(result.code) + cy.log(result.stdout) + cy.log(result.stderr) + }) + } else { + cy.exec('./cypress/stemmarest/init_test_data.sh', // currently from a volume, cf. docker-compose.test.yml + { env: { STEMMAREST_ENDPOINT: Cypress.env('CY_STEMMAREST_ENDPOINT') } } + ).then(function(result) { + cy.log(result.code) + cy.log(result.stdout) + cy.log(result.stderr) + }) + } + + cy.reload() // TO DO: assert adding a tradition in the gui leads to automatic update of listed traditions cy.log('db re-seeded') })