mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-21 19:56:02 +00:00
e2e test config
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
const { defineConfig } = require('cypress');
|
const { defineConfig } = require('cypress');
|
||||||
const killPort = require('kill-port');
|
const killPort = require('kill-port');
|
||||||
const { clearDataWithBackup } = require('./e2eTestTools');
|
const { clearTestingData } = require('./e2eTestTools');
|
||||||
const waitOn = require('wait-on');
|
const waitOn = require('wait-on');
|
||||||
const { exec } = require('child_process');
|
const { exec } = require('child_process');
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ module.exports = defineConfig({
|
|||||||
// implement node event listeners here
|
// implement node event listeners here
|
||||||
|
|
||||||
on('before:spec', async details => {
|
on('before:spec', async details => {
|
||||||
await clearDataWithBackup();
|
await clearTestingData();
|
||||||
|
|
||||||
if (config.isInteractive) {
|
if (config.isInteractive) {
|
||||||
await killPort(3000);
|
await killPort(3000);
|
||||||
|
|||||||
@@ -4,29 +4,26 @@ const fs = require('fs');
|
|||||||
|
|
||||||
const baseDir = path.join(os.homedir(), '.dbgate');
|
const baseDir = path.join(os.homedir(), '.dbgate');
|
||||||
|
|
||||||
function createTimeStamp() {
|
// function createTimeStamp() {
|
||||||
const now = new Date();
|
// const now = new Date();
|
||||||
const year = now.getFullYear();
|
// const year = now.getFullYear();
|
||||||
const month = String(now.getMonth() + 1).padStart(2, '0'); // měsíc je 0-indexovaný
|
// const month = String(now.getMonth() + 1).padStart(2, '0'); // měsíc je 0-indexovaný
|
||||||
const day = String(now.getDate()).padStart(2, '0');
|
// const day = String(now.getDate()).padStart(2, '0');
|
||||||
const hours = String(now.getHours()).padStart(2, '0');
|
// const hours = String(now.getHours()).padStart(2, '0');
|
||||||
const minutes = String(now.getMinutes()).padStart(2, '0');
|
// const minutes = String(now.getMinutes()).padStart(2, '0');
|
||||||
const seconds = String(now.getSeconds()).padStart(2, '0');
|
// const seconds = String(now.getSeconds()).padStart(2, '0');
|
||||||
|
|
||||||
// Poskládáme datum a čas do názvu souboru
|
// // Poskládáme datum a čas do názvu souboru
|
||||||
const ts = `${year}-${month}-${day}_${hours}-${minutes}-${seconds}`;
|
// const ts = `${year}-${month}-${day}_${hours}-${minutes}-${seconds}`;
|
||||||
return ts;
|
// return ts;
|
||||||
}
|
// }
|
||||||
|
|
||||||
function clearDataWithBackup() {
|
function clearTestingData() {
|
||||||
if (fs.existsSync(path.join(baseDir, 'connections.jsonl'))) {
|
if (fs.existsSync(path.join(baseDir, 'connections-e2etests.jsonl'))) {
|
||||||
fs.renameSync(
|
fs.unlinkSync(path.join(baseDir, 'connections-e2etests.jsonl'));
|
||||||
path.join(baseDir, 'connections.jsonl'),
|
|
||||||
path.join(baseDir, `connections-${createTimeStamp()}.jsonl.bak`)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
clearDataWithBackup,
|
clearTestingData,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ const _ = require('lodash');
|
|||||||
const AsyncLock = require('async-lock');
|
const AsyncLock = require('async-lock');
|
||||||
const jwt = require('jsonwebtoken');
|
const jwt = require('jsonwebtoken');
|
||||||
|
|
||||||
|
const processArgs = require('../utility/processArgs');
|
||||||
const currentVersion = require('../currentVersion');
|
const currentVersion = require('../currentVersion');
|
||||||
const platformInfo = require('../utility/platformInfo');
|
const platformInfo = require('../utility/platformInfo');
|
||||||
const connections = require('../controllers/connections');
|
const connections = require('../controllers/connections');
|
||||||
@@ -83,7 +84,8 @@ module.exports = {
|
|||||||
isElectron: platformInfo.isElectron,
|
isElectron: platformInfo.isElectron,
|
||||||
isLicenseValid,
|
isLicenseValid,
|
||||||
isLicenseExpired: checkedLicense?.isExpired,
|
isLicenseExpired: checkedLicense?.isExpired,
|
||||||
trialDaysLeft: checkedLicense?.licenseTypeObj?.isTrial && !checkedLicense?.isExpired ? checkedLicense?.daysLeft : null,
|
trialDaysLeft:
|
||||||
|
checkedLicense?.licenseTypeObj?.isTrial && !checkedLicense?.isExpired ? checkedLicense?.daysLeft : null,
|
||||||
checkedLicense,
|
checkedLicense,
|
||||||
configurationError,
|
configurationError,
|
||||||
logoutUrl,
|
logoutUrl,
|
||||||
@@ -101,7 +103,10 @@ module.exports = {
|
|||||||
adminPasswordState: adminConfig?.adminPasswordState,
|
adminPasswordState: adminConfig?.adminPasswordState,
|
||||||
storageDatabase: process.env.STORAGE_DATABASE,
|
storageDatabase: process.env.STORAGE_DATABASE,
|
||||||
logsFilePath: getLogsFilePath(),
|
logsFilePath: getLogsFilePath(),
|
||||||
connectionsFilePath: path.join(datadir(), 'connections.jsonl'),
|
connectionsFilePath: path.join(
|
||||||
|
datadir(),
|
||||||
|
processArgs.runE2eTests ? 'connections-e2etests.jsonl' : 'connections.jsonl'
|
||||||
|
),
|
||||||
...currentVersion,
|
...currentVersion,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -199,7 +199,9 @@ module.exports = {
|
|||||||
const dir = datadir();
|
const dir = datadir();
|
||||||
if (!portalConnections) {
|
if (!portalConnections) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.datastore = new JsonLinesDatabase(path.join(dir, 'connections.jsonl'));
|
this.datastore = new JsonLinesDatabase(
|
||||||
|
path.join(dir, processArgs.runE2eTests ? 'connections-e2etests.jsonl' : 'connections.jsonl')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
await this.checkUnsavedConnectionsLimit();
|
await this.checkUnsavedConnectionsLimit();
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user