test fixes

This commit is contained in:
SPRINX0\prochazka
2024-12-09 16:52:02 +01:00
parent 5405b9bf72
commit 7f367a1f84
9 changed files with 23 additions and 29 deletions

View File

@@ -1,34 +1,14 @@
const { defineConfig } = require('cypress'); const { defineConfig } = require('cypress');
const { clearDataWithBackup } = require('./e2eTestTools'); const { clearDataWithBackup } = require('./e2eTestTools');
const { exec } = require('child_process');
const waitOn = require('wait-on');
module.exports = defineConfig({ module.exports = defineConfig({
e2e: { e2e: {
setupNodeEvents(on, config) { setupNodeEvents(on, config) {
// implement node event listeners here // implement node event listeners here
let serverProcess;
on('before:spec', async details => { on('before:spec', async details => {
console.log('******** BEFORE RUN ****************');
clearDataWithBackup(); clearDataWithBackup();
// await axios.default.post('http://localhost:3000/connections/reload-connection-list', {});
serverProcess = exec('yarn start');
await waitOn({ resources: ['http://localhost:3000'] });
serverProcess.stdout.on('data', data => {
console.log(data.toString());
});
serverProcess.stderr.on('data', data => {
console.error(data.toString());
});
});
on('after:spec', () => {
console.log('******** AFTER RUN ****************', serverProcess);
if (serverProcess) {
console.log('Stopping local server...');
serverProcess.kill();
}
}); });
}, },
}, },

View File

@@ -4,6 +4,7 @@
"main": "index.js", "main": "index.js",
"license": "GPL", "license": "GPL",
"devDependencies": { "devDependencies": {
"axios": "^1.7.9",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"cypress": "^13.16.1", "cypress": "^13.16.1",
"start-server-and-test": "^2.0.8" "start-server-and-test": "^2.0.8"
@@ -12,7 +13,7 @@
"cy:open": "cypress open --config experimentalInteractiveRunEvents=true", "cy:open": "cypress open --config experimentalInteractiveRunEvents=true",
"cy:run": "cypress run", "cy:run": "cypress run",
"cy:run:ci": "cross-env CI=true cypress run", "cy:run:ci": "cross-env CI=true cypress run",
"start": "cd .. && node packer/build/bundle.js --listen-api --run-packer-build", "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:ci": "start-server-and-test start http://localhost:3000 cy:run:ci",
"test": "start-server-and-test start http://localhost:3000 cy:run" "test": "start-server-and-test start http://localhost:3000 cy:run"
} }

View File

@@ -176,7 +176,7 @@ aws4@^1.8.0:
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.13.2.tgz#0aa167216965ac9474ccfa83892cfb6b3e1e52ef" resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.13.2.tgz#0aa167216965ac9474ccfa83892cfb6b3e1e52ef"
integrity sha512-lHe62zvbTB5eEABUVi/AwVh0ZKY9rMMDhmm+eeyuuUQbQ3+J+fONVQOZyj+DdrvD4BY33uYniyRJ4UJIaSKAfw== integrity sha512-lHe62zvbTB5eEABUVi/AwVh0ZKY9rMMDhmm+eeyuuUQbQ3+J+fONVQOZyj+DdrvD4BY33uYniyRJ4UJIaSKAfw==
axios@^1.7.7: axios@^1.7.7, axios@^1.7.9:
version "1.7.9" version "1.7.9"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.9.tgz#d7d071380c132a24accda1b2cfc1535b79ec650a" resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.9.tgz#d7d071380c132a24accda1b2cfc1535b79ec650a"
integrity sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw== integrity sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==

View File

@@ -43,6 +43,7 @@ function authMiddleware(req, res, next) {
'/connections/dblogin-app', '/connections/dblogin-app',
'/connections/dblogin-auth', '/connections/dblogin-auth',
'/connections/dblogin-auth-token', '/connections/dblogin-auth-token',
'/connections/reload-connection-list',
]; ];
// console.log('********************* getAuthProvider()', getAuthProvider()); // console.log('********************* getAuthProvider()', getAuthProvider());

View File

@@ -510,4 +510,10 @@ module.exports = {
} }
return null; return null;
}, },
reloadConnectionList_meta: true,
async reloadConnectionList() {
if (portalConnections) return;
await this.datastore.unload();
},
}; };

View File

@@ -78,7 +78,7 @@ function start() {
app.use(getExpressPath('/'), express.static('/home/dbgate-docker/public')); app.use(getExpressPath('/'), express.static('/home/dbgate-docker/public'));
} else if (platformInfo.isAwsUbuntuLayout) { } else if (platformInfo.isAwsUbuntuLayout) {
app.use(getExpressPath('/'), express.static('/home/ubuntu/build/public')); app.use(getExpressPath('/'), express.static('/home/ubuntu/build/public'));
} else if (processArgs.runPackerBuild) { } else if (processArgs.runE2eTests) {
app.use(getExpressPath('/'), express.static(path.resolve('packer/build/public'))); app.use(getExpressPath('/'), express.static(path.resolve('packer/build/public')));
} else if (platformInfo.isNpmDist) { } else if (platformInfo.isNpmDist) {
app.use( app.use(

View File

@@ -23,6 +23,12 @@ class JsonLinesDatabase {
await fs.writeFile(this.filename, this.data.map(x => JSON.stringify(x)).join('\n')); await fs.writeFile(this.filename, this.data.map(x => JSON.stringify(x)).join('\n'));
} }
async unload() {
this.data = [];
this.loadedOk = false;
this.loadPerformed = false;
}
async _ensureLoaded() { async _ensureLoaded() {
if (!this.loadPerformed) { if (!this.loadPerformed) {
await lock.acquire('reader', async () => { await lock.acquire('reader', async () => {

View File

@@ -96,7 +96,7 @@ function packagedPluginsDir() {
// return path.resolve(__dirname, '../../plugins'); // return path.resolve(__dirname, '../../plugins');
// } // }
} }
if (processArgs.runPackerBuild) { if (processArgs.runE2eTests) {
return path.resolve('packer/build/plugins'); return path.resolve('packer/build/plugins');
} }
return null; return null;

View File

@@ -14,7 +14,7 @@ const workspaceDir = getNamedArg('--workspace-dir');
const processDisplayName = getNamedArg('--process-display-name'); const processDisplayName = getNamedArg('--process-display-name');
const listenApi = process.argv.includes('--listen-api'); const listenApi = process.argv.includes('--listen-api');
const listenApiChild = process.argv.includes('--listen-api-child') || listenApi; const listenApiChild = process.argv.includes('--listen-api-child') || listenApi;
const runPackerBuild = process.argv.includes('--run-packer-build'); const runE2eTests = process.argv.includes('--run-e2e-tests');
function getPassArgs() { function getPassArgs() {
const res = []; const res = [];
@@ -24,8 +24,8 @@ function getPassArgs() {
if (listenApiChild) { if (listenApiChild) {
res.push('listen-api-child'); res.push('listen-api-child');
} }
if (runPackerBuild) { if (runE2eTests) {
res.push('--run-packer-build'); res.push('--run-e2e-tests');
} }
return res; return res;
} }
@@ -40,5 +40,5 @@ module.exports = {
listenApi, listenApi,
listenApiChild, listenApiChild,
processDisplayName, processDisplayName,
runPackerBuild, runE2eTests,
}; };