diff --git a/e2e-tests/cypress.config.js b/e2e-tests/cypress.config.js index 9c0135621..0e904d24d 100644 --- a/e2e-tests/cypress.config.js +++ b/e2e-tests/cypress.config.js @@ -11,10 +11,19 @@ module.exports = defineConfig({ on('before:spec', async details => { await clearTestingData(); - + // console.log('********************* DETAILS *********************', JSON.stringify(details)); + if (config.isInteractive) { await killPort(3000); - serverProcess = exec('yarn start'); + switch (details.fileName) { + case 'add-connection': + serverProcess = exec('yarn start:add-connection'); + break; + case 'portal': + serverProcess = exec('yarn start:portal:local'); + break; + } + await waitOn({ resources: ['http://localhost:3000'] }); serverProcess.stdout.on('data', data => { console.log(data.toString()); diff --git a/e2e-tests/cypress/e2e/connect.cy.js b/e2e-tests/cypress/e2e/add-connection.cy.js similarity index 99% rename from e2e-tests/cypress/e2e/connect.cy.js rename to e2e-tests/cypress/e2e/add-connection.cy.js index 556241367..264f40f34 100644 --- a/e2e-tests/cypress/e2e/connect.cy.js +++ b/e2e-tests/cypress/e2e/add-connection.cy.js @@ -1,6 +1,6 @@ const path = require('path'); -describe('Initialization', () => { +describe('Add connection', () => { it('successfully loads', () => { cy.visit('http://localhost:3000'); cy.contains('Database not selected'); diff --git a/e2e-tests/cypress/e2e/portal.cy.js b/e2e-tests/cypress/e2e/portal.cy.js new file mode 100644 index 000000000..eae8952a8 --- /dev/null +++ b/e2e-tests/cypress/e2e/portal.cy.js @@ -0,0 +1,12 @@ +describe('Run as portal', () => { + it('successfully loads', () => { + cy.visit('http://localhost:3000'); + cy.contains('MySql'); + cy.contains('Postgres'); + }); + + // it('import chinook DB', () => { + // cy.visit('http://localhost:3000'); + // cy.get('[data-testid=ConnectionTab_buttonConnect]').click(); + // }); +}); diff --git a/e2e-tests/env/portal-ci/.env b/e2e-tests/env/portal-ci/.env new file mode 100644 index 000000000..146e085b9 --- /dev/null +++ b/e2e-tests/env/portal-ci/.env @@ -0,0 +1,15 @@ +CONNECTIONS=mysql,postgres + +LABEL_mysql=MySql +SERVER_mysql=mariadb +USER_mysql=root +PASSWORD_mysql=Pwd2020Db +PORT_mysql=3306 +ENGINE_mysql=mysql@dbgate-plugin-mysql + +LABEL_postgres=Postgres +SERVER_postgres=postgres +USER_postgres=postgres +PASSWORD_postgres=Pwd2020Db +PORT_postgres=5432 +ENGINE_postgres=postgres@dbgate-plugin-postgres diff --git a/e2e-tests/env/portal-local/.env b/e2e-tests/env/portal-local/.env new file mode 100644 index 000000000..85907f6f8 --- /dev/null +++ b/e2e-tests/env/portal-local/.env @@ -0,0 +1,15 @@ +CONNECTIONS=mysql,postgres + +LABEL_mysql=MySql +SERVER_mysql=localhost +USER_mysql=root +PASSWORD_mysql=Pwd2020Db +PORT_mysql=16004 +ENGINE_mysql=mysql@dbgate-plugin-mysql + +LABEL_postgres=Postgres +SERVER_postgres=localhost +USER_postgres=postgres +PASSWORD_postgres=Pwd2020Db +PORT_postgres=16000 +ENGINE_postgres=postgres@dbgate-plugin-postgres diff --git a/e2e-tests/package.json b/e2e-tests/package.json index 4606e5c5d..b560bd89e 100644 --- a/e2e-tests/package.json +++ b/e2e-tests/package.json @@ -8,15 +8,25 @@ "cross-env": "^7.0.3", "cypress": "^13.16.1", "cypress-real-events": "^1.13.0", + "env-cmd": "^10.1.0", "kill-port": "^2.0.1", "start-server-and-test": "^2.0.8" }, "scripts": { "cy:open": "cypress open --config experimentalInteractiveRunEvents=true", - "cy:run": "cypress run", - "cy:run:ci": "cypress run --env runOnCI=true", - "start": "cd .. && node packer/build/bundle.js --listen-api --run-e2e-tests", - "test:ci": "start-server-and-test start http://localhost:3000 cy:run:ci", - "test": "start-server-and-test start http://localhost:3000 cy:run" + + "cy:run:add-connection:local": "cypress run --spec cypress/e2e/add-connection.cy.js", + "cy:run:add-connection:ci": "cypress run --env runOnCI=true --spec cypress/e2e/add-connection.cy.js", + + "cy:run:portal:local": "cypress run --spec cypress/e2e/portal.cy.js", + "cy:run:portal:ci": "cypress run --env runOnCI=true --spec cypress/e2e/portal.cy.js", + + "start:add-connection": "cd .. && node packer/build/bundle.js --listen-api --run-e2e-tests", + + "start:portal:local": "cd .. && env-cmd -f e2e-tests/env/portal-local/.env node packer/build/bundle.js --listen-api --run-e2e-tests", + "start:portal:ci": "cd .. && env-cmd -f e2e-tests/env/portal-ci/.env node packer/build/bundle.js --listen-api --run-e2e-tests", + + "test:ci": "start-server-and-test start:add-connection http://localhost:3000 cy:run:add-connection:ci && start-server-and-test start:portal:ci http://localhost:3000 cy:run:portal:ci", + "test:local": "start-server-and-test start:add-connection http://localhost:3000 cy:run:add-connection:local && start-server-and-test start:portal:local http://localhost:3000 cy:run:portal:local" } } diff --git a/e2e-tests/yarn.lock b/e2e-tests/yarn.lock index 1c8ab226e..29aa0b706 100644 --- a/e2e-tests/yarn.lock +++ b/e2e-tests/yarn.lock @@ -319,6 +319,11 @@ combined-stream@^1.0.8, combined-stream@~1.0.6: dependencies: delayed-stream "~1.0.0" +commander@^4.0.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-4.1.1.tgz#9fd602bd936294e9e9ef46a3f4d6964044b18068" + integrity sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA== + commander@^6.2.1: version "6.2.1" resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.1.tgz#0792eb682dfbc325999bb2b84fddddba110ac73c" @@ -484,6 +489,14 @@ enquirer@^2.3.6: ansi-colors "^4.1.1" strip-ansi "^6.0.1" +env-cmd@^10.1.0: + version "10.1.0" + resolved "https://registry.yarnpkg.com/env-cmd/-/env-cmd-10.1.0.tgz#c7f5d3b550c9519f137fdac4dd8fb6866a8c8c4b" + integrity sha512-mMdWTT9XKN7yNth/6N6g2GuKuJTsKMDHlQFUDacb/heQRRWOTIZ42t1rMHnQu4jYxU1ajdTeJM+9eEETlqToMA== + dependencies: + commander "^4.0.0" + cross-spawn "^7.0.0" + es-define-property@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/es-define-property/-/es-define-property-1.0.0.tgz#c7faefbdff8b2696cf5f46921edfb77cc4ba3845"