From 88ba89fc4b948290cf2099537b0d946b1141501b Mon Sep 17 00:00:00 2001 From: Ian Roberts Date: Sun, 3 Nov 2024 11:21:26 +0000 Subject: [PATCH] test: use the right "docker compose" vs "docker-compose" for migrations in e2e tests --- cypress/support/commands.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index aa9212a5..fb6b5054 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -72,10 +72,18 @@ Cypress.Commands.add("logout", () => { //Migrate integration db Cypress.Commands.add("migrate_integration_db", (fixtureName) => { - if (Cypress.env('TESTENV') == 'container') { - cy.exec(`docker-compose exec -T backend ./migrate-integration.sh -n=${fixtureName}`) - } else if (Cypress.env('TESTENV') == 'ci') { - cy.exec(`DJANGO_SETTINGS_MODULE=teamware.settings.deployment docker-compose exec -T backend ./migrate-integration.sh -n=${fixtureName}`) + + const testenv = Cypress.env('TESTENV'); + if (testenv === 'container' || testenv === 'ci') { + // find the right docker compose command + cy.exec("docker compose").then(({code}) => { + const compose = (code === 0 ? 'docker compose' : 'docker-compose') + if (testenv === 'container') { + cy.exec(`${compose} exec -T backend ./migrate-integration.sh -n=${fixtureName}`) + } else if (testenv === 'ci') { + cy.exec(`DJANGO_SETTINGS_MODULE=teamware.settings.deployment ${compose} exec -T backend ./migrate-integration.sh -n=${fixtureName}`) + } + }); } else{ cy.exec(`npm run migrate:integration -- -n=${fixtureName}`, {log:true})