2022-07-25 04:45:28 +00:00
|
|
|
const { defineConfig } = require("cypress");
|
2023-02-21 08:59:23 +00:00
|
|
|
const { rmdir } = require("fs");
|
2023-02-14 08:34:20 +00:00
|
|
|
const fs = require("fs");
|
|
|
|
|
const XLSX = require("node-xlsx");
|
|
|
|
|
|
2023-01-17 09:05:21 +00:00
|
|
|
const pg = require("pg");
|
2023-02-21 08:59:23 +00:00
|
|
|
const path = require("path");
|
|
|
|
|
const pdf = require("pdf-parse");
|
2022-07-25 04:45:28 +00:00
|
|
|
|
|
|
|
|
module.exports = defineConfig({
|
|
|
|
|
execTimeout: 1800000,
|
|
|
|
|
defaultCommandTimeout: 30000,
|
2025-02-17 05:00:24 +00:00
|
|
|
requestTimeout: 30000,
|
|
|
|
|
pageLoadTimeout: 30000,
|
|
|
|
|
responseTimeout: 30000,
|
2023-04-25 10:07:18 +00:00
|
|
|
viewportWidth: 1440,
|
2022-07-25 04:45:28 +00:00
|
|
|
viewportHeight: 960,
|
2022-12-09 13:12:31 +00:00
|
|
|
chromeWebSecurity: false,
|
2022-08-04 15:10:46 +00:00
|
|
|
trashAssetsBeforeRuns: true,
|
2023-01-17 10:22:31 +00:00
|
|
|
|
2022-07-25 04:45:28 +00:00
|
|
|
e2e: {
|
2025-09-18 04:46:52 +00:00
|
|
|
setupNodeEvents(on, config) {
|
2022-08-04 15:10:46 +00:00
|
|
|
on("task", {
|
2025-09-18 04:46:52 +00:00
|
|
|
readPdf(pathToPdf) {
|
2023-02-14 08:34:20 +00:00
|
|
|
return new Promise((resolve) => {
|
2023-02-21 08:59:23 +00:00
|
|
|
const pdfPath = path.resolve(pathToPdf);
|
2023-02-14 08:34:20 +00:00
|
|
|
let dataBuffer = fs.readFileSync(pdfPath);
|
|
|
|
|
pdf(dataBuffer).then(function ({ text }) {
|
2023-02-21 08:59:23 +00:00
|
|
|
resolve(text);
|
2022-08-04 15:10:46 +00:00
|
|
|
});
|
2023-02-21 08:59:23 +00:00
|
|
|
});
|
|
|
|
|
},
|
2022-08-04 15:10:46 +00:00
|
|
|
});
|
|
|
|
|
|
2022-12-09 13:12:31 +00:00
|
|
|
on("task", {
|
2025-09-18 04:46:52 +00:00
|
|
|
readXlsx(filePath) {
|
2023-02-14 08:34:20 +00:00
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
try {
|
2023-02-21 08:59:23 +00:00
|
|
|
let dataBuffer = fs.readFileSync(filePath);
|
2023-02-14 08:34:20 +00:00
|
|
|
const jsonData = XLSX.parse(dataBuffer);
|
|
|
|
|
// jsonData= jsonData[0].data
|
|
|
|
|
resolve(jsonData[0]["data"].toString());
|
|
|
|
|
} catch (e) {
|
|
|
|
|
reject(e);
|
|
|
|
|
}
|
|
|
|
|
});
|
2023-02-21 08:59:23 +00:00
|
|
|
},
|
2023-02-14 08:34:20 +00:00
|
|
|
});
|
|
|
|
|
|
2025-08-29 07:03:39 +00:00
|
|
|
on("task", {
|
|
|
|
|
deleteFile(filePath) {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
const fullPath = path.resolve(filePath);
|
|
|
|
|
if (fs.existsSync(fullPath)) {
|
|
|
|
|
fs.unlink(fullPath, (err) => {
|
|
|
|
|
if (err) {
|
|
|
|
|
console.error("Failed to delete file:", fullPath, err);
|
|
|
|
|
return reject(err);
|
|
|
|
|
}
|
|
|
|
|
console.log("Deleted file:", fullPath);
|
|
|
|
|
resolve(true);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
console.log("File not found, skipping delete:", fullPath);
|
|
|
|
|
resolve(false);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2023-02-21 08:59:23 +00:00
|
|
|
on("task", {
|
2025-09-18 04:46:52 +00:00
|
|
|
deleteFolder(folderName) {
|
2023-02-21 08:59:23 +00:00
|
|
|
return new Promise((resolve, reject) => {
|
2023-04-24 11:03:27 +00:00
|
|
|
if (fs.existsSync(folderName)) {
|
2023-04-20 04:59:50 +00:00
|
|
|
rmdir(folderName, { maxRetries: 10, recursive: true }, (err) => {
|
|
|
|
|
if (err) {
|
|
|
|
|
console.error(err);
|
|
|
|
|
return reject(err);
|
|
|
|
|
}
|
|
|
|
|
return resolve(null);
|
|
|
|
|
});
|
2023-04-24 11:03:27 +00:00
|
|
|
} else {
|
2023-04-20 04:59:50 +00:00
|
|
|
return resolve(null);
|
|
|
|
|
}
|
2023-02-14 08:34:20 +00:00
|
|
|
});
|
2023-02-21 08:59:23 +00:00
|
|
|
},
|
2023-01-17 09:05:21 +00:00
|
|
|
});
|
2022-12-09 13:12:31 +00:00
|
|
|
|
2023-02-21 08:59:23 +00:00
|
|
|
on("task", {
|
2025-09-18 04:46:52 +00:00
|
|
|
dbConnection({ dbconfig, sql }) {
|
2023-02-21 08:59:23 +00:00
|
|
|
const client = new pg.Pool(dbconfig);
|
|
|
|
|
return client.query(sql);
|
|
|
|
|
},
|
|
|
|
|
});
|
2025-01-02 08:44:42 +00:00
|
|
|
on('before:browser:launch', (browser = {}, launchOptions) => {
|
|
|
|
|
if (browser.name === 'chrome' && browser.isHeadless === false) {
|
|
|
|
|
launchOptions.args.push(
|
|
|
|
|
'--disable-features=AutofillAccountStorage,PasswordManager',
|
|
|
|
|
'--disable-save-password-bubble',
|
|
|
|
|
'--disable-password-generation',
|
|
|
|
|
'--disable-password-manager-reauthentication'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return launchOptions;
|
|
|
|
|
});
|
2023-12-28 09:46:16 +00:00
|
|
|
require("@cypress/code-coverage/task")(on, config);
|
|
|
|
|
// return config;
|
|
|
|
|
|
|
|
|
|
require("./cypress/plugins/index.js")(on, config);
|
|
|
|
|
return config;
|
2022-07-25 04:45:28 +00:00
|
|
|
},
|
2023-01-17 09:09:38 +00:00
|
|
|
experimentalRunAllSpecs: true,
|
2022-12-09 13:12:31 +00:00
|
|
|
experimentalModfyObstructiveThirdPartyCode: true,
|
2023-01-17 09:05:21 +00:00
|
|
|
experimentalRunAllSpecs: true,
|
2023-04-24 11:03:27 +00:00
|
|
|
baseUrl: "http://localhost:8082",
|
2025-04-21 14:07:35 +00:00
|
|
|
specPattern: "cypress/e2e/happyPath/**/*.cy.js",
|
2023-04-24 11:03:27 +00:00
|
|
|
downloadsFolder: "cypress/downloads",
|
2023-10-19 10:24:50 +00:00
|
|
|
numTestsKeptInMemory: 0,
|
2025-09-18 04:46:52 +00:00
|
|
|
redirectionLimit: 5,
|
2023-01-17 10:22:31 +00:00
|
|
|
experimentalRunAllSpecs: true,
|
2023-02-14 08:34:20 +00:00
|
|
|
trashAssetsBeforeRuns: true,
|
2023-02-09 11:41:50 +00:00
|
|
|
experimentalMemoryManagement: true,
|
2023-12-28 09:46:16 +00:00
|
|
|
coverage: true,
|
|
|
|
|
codeCoverageTasksRegistered: true,
|
|
|
|
|
video: false,
|
|
|
|
|
videoUploadOnPasses: false,
|
2024-08-13 07:34:54 +00:00
|
|
|
experimentalStudio: true,
|
2022-07-25 04:45:28 +00:00
|
|
|
},
|
2023-02-21 08:59:23 +00:00
|
|
|
});
|