portal connection test

This commit is contained in:
SPRINX0\prochazka
2025-01-06 14:56:16 +01:00
parent ddcfc127b7
commit d9ca29b602
7 changed files with 82 additions and 8 deletions

View File

@@ -11,10 +11,19 @@ module.exports = defineConfig({
on('before:spec', async details => { on('before:spec', async details => {
await clearTestingData(); await clearTestingData();
// console.log('********************* DETAILS *********************', JSON.stringify(details));
if (config.isInteractive) { if (config.isInteractive) {
await killPort(3000); 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'] }); await waitOn({ resources: ['http://localhost:3000'] });
serverProcess.stdout.on('data', data => { serverProcess.stdout.on('data', data => {
console.log(data.toString()); console.log(data.toString());

View File

@@ -1,6 +1,6 @@
const path = require('path'); const path = require('path');
describe('Initialization', () => { describe('Add connection', () => {
it('successfully loads', () => { it('successfully loads', () => {
cy.visit('http://localhost:3000'); cy.visit('http://localhost:3000');
cy.contains('Database not selected'); cy.contains('Database not selected');

View File

@@ -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();
// });
});

15
e2e-tests/env/portal-ci/.env vendored Normal file
View File

@@ -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

15
e2e-tests/env/portal-local/.env vendored Normal file
View File

@@ -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

View File

@@ -8,15 +8,25 @@
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"cypress": "^13.16.1", "cypress": "^13.16.1",
"cypress-real-events": "^1.13.0", "cypress-real-events": "^1.13.0",
"env-cmd": "^10.1.0",
"kill-port": "^2.0.1", "kill-port": "^2.0.1",
"start-server-and-test": "^2.0.8" "start-server-and-test": "^2.0.8"
}, },
"scripts": { "scripts": {
"cy:open": "cypress open --config experimentalInteractiveRunEvents=true", "cy:open": "cypress open --config experimentalInteractiveRunEvents=true",
"cy:run": "cypress run",
"cy:run:ci": "cypress run --env runOnCI=true", "cy:run:add-connection:local": "cypress run --spec cypress/e2e/add-connection.cy.js",
"start": "cd .. && node packer/build/bundle.js --listen-api --run-e2e-tests", "cy:run:add-connection:ci": "cypress run --env runOnCI=true --spec cypress/e2e/add-connection.cy.js",
"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: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"
} }
} }

View File

@@ -319,6 +319,11 @@ combined-stream@^1.0.8, combined-stream@~1.0.6:
dependencies: dependencies:
delayed-stream "~1.0.0" 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: commander@^6.2.1:
version "6.2.1" version "6.2.1"
resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.1.tgz#0792eb682dfbc325999bb2b84fddddba110ac73c" 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" ansi-colors "^4.1.1"
strip-ansi "^6.0.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: es-define-property@^1.0.0:
version "1.0.0" version "1.0.0"
resolved "https://registry.yarnpkg.com/es-define-property/-/es-define-property-1.0.0.tgz#c7faefbdff8b2696cf5f46921edfb77cc4ba3845" resolved "https://registry.yarnpkg.com/es-define-property/-/es-define-property-1.0.0.tgz#c7faefbdff8b2696cf5f46921edfb77cc4ba3845"