2020-01-14 12:14:18 -06:00
|
|
|
/* global require */
|
2020-01-14 11:08:51 -06:00
|
|
|
|
2020-05-18 15:23:50 -05:00
|
|
|
var process = require('process');
|
2020-12-17 11:22:59 -06:00
|
|
|
var uuid = require('uuid');
|
|
|
|
|
2020-01-14 12:14:18 -06:00
|
|
|
var tasks = require('./tasks');
|
2020-06-05 09:42:23 -05:00
|
|
|
var blacklists = require('./blacklists');
|
2023-04-25 10:33:38 -05:00
|
|
|
|
|
|
|
//const registerCypressGrep = require('@cypress/grep');
|
|
|
|
//registerCypressGrep();
|
|
|
|
|
|
|
|
require('@cypress/grep/src/plugin');
|
2020-01-14 11:08:51 -06:00
|
|
|
|
2020-01-14 12:14:18 -06:00
|
|
|
function plugin(on, config) {
|
2020-06-24 05:50:29 -05:00
|
|
|
if (config.env.COVERAGE_RUN)
|
|
|
|
require('@cypress/code-coverage/task')(on, config);
|
2023-04-25 10:33:38 -05:00
|
|
|
|
2020-01-14 12:14:18 -06:00
|
|
|
on('task', {
|
2020-03-13 07:47:15 -05:00
|
|
|
copyFile: tasks.copyFile,
|
2021-06-07 04:32:53 -05:00
|
|
|
failed: require('cypress-failed-log/src/failed')(),
|
|
|
|
getSelectors: tasks.getSelectors,
|
2020-01-14 12:14:18 -06:00
|
|
|
});
|
|
|
|
|
2020-07-30 05:42:39 -05:00
|
|
|
if (process.env.ENABLE_VIDEO_REC) {
|
|
|
|
config.video = true;
|
|
|
|
}
|
|
|
|
|
2020-07-20 06:46:15 -05:00
|
|
|
if (process.env.ENABLE_CONSOLE_LOG) {
|
|
|
|
require('cypress-log-to-output').install(on, function(type, event) {
|
|
|
|
if (event.level === 'error' || event.type === 'error') {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-04-18 23:41:55 -05:00
|
|
|
on('before:browser:launch', function(browser, launchOptions) {
|
|
|
|
if (browser.family === 'chromium') {
|
|
|
|
if (process.env.ENABLE_LOGGING) {
|
2020-07-20 06:46:15 -05:00
|
|
|
launchOptions.args.push('--enable-logging=stderr');
|
|
|
|
launchOptions.args.push('--v=2');
|
|
|
|
}
|
2023-04-18 23:41:55 -05:00
|
|
|
launchOptions.args.push('--simulate-outdated-no-au=\'2099-12-31T23:59:59.000000+00:00\'');
|
|
|
|
}
|
|
|
|
|
|
|
|
return launchOptions;
|
|
|
|
});
|
2020-05-18 15:23:50 -05:00
|
|
|
|
2020-09-16 09:01:46 -05:00
|
|
|
if (process.env.CYPRESS_INTEGRATION === 'php-proxy') {
|
|
|
|
config.defaultCommandTimeout = 10000;
|
|
|
|
}
|
|
|
|
|
2021-06-07 04:32:53 -05:00
|
|
|
if (process.env.USER_INTERFACE === 'notebookbar') {
|
|
|
|
config.env.USER_INTERFACE = 'notebookbar';
|
|
|
|
}
|
|
|
|
|
2023-04-25 10:33:38 -05:00
|
|
|
/*eslint-disable-next-line*/
|
|
|
|
var onFilePreprocessor = function (file) {
|
2020-12-17 11:22:59 -06:00
|
|
|
if (file.outputPath.endsWith('support/index.js')) {
|
|
|
|
var runUuid = uuid.v4();
|
|
|
|
var truncLength = file.outputPath.length - ('index.js').length;
|
|
|
|
file.outputPath = file.outputPath.substring(0, truncLength);
|
|
|
|
file.outputPath += runUuid + 'index.js';
|
|
|
|
}
|
|
|
|
|
2023-04-25 10:33:38 -05:00
|
|
|
//return Cypress.grep(config, pickTests)(file);
|
|
|
|
pickTests(null, null);
|
|
|
|
return file;
|
|
|
|
};
|
|
|
|
|
|
|
|
//on('file:preprocessor', onFilePreprocessor);
|
2020-06-05 09:42:23 -05:00
|
|
|
|
2020-01-14 12:14:18 -06:00
|
|
|
return config;
|
|
|
|
}
|
|
|
|
|
2020-09-10 11:26:00 -05:00
|
|
|
function removeBlacklistedTest(filename, testsToRun, blackList) {
|
2020-06-05 09:42:23 -05:00
|
|
|
for (var i = 0; i < blackList.length; i++) {
|
|
|
|
if (filename.endsWith(blackList[i][0])) {
|
|
|
|
if (blackList[i][1].length === 0) // skip the whole test suite
|
|
|
|
return [];
|
2020-09-10 11:26:00 -05:00
|
|
|
return testsToRun.filter(fullTestName => !blackList[i][1].includes(fullTestName[1]));
|
2020-06-05 09:42:23 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return testsToRun;
|
|
|
|
}
|
|
|
|
|
2022-03-10 04:42:14 -06:00
|
|
|
function isNotebookbarTest(filename, notebookbarOnlyList) {
|
|
|
|
for (var i =0 ; i < notebookbarOnlyList.length; i++) {
|
|
|
|
if (filename.endsWith(notebookbarOnlyList[i])) {
|
2021-06-07 04:32:53 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-05 08:20:20 -06:00
|
|
|
function pickTests(filename, foundTests) {
|
2023-04-25 10:33:38 -05:00
|
|
|
if (true)
|
|
|
|
return;
|
|
|
|
|
2020-09-10 11:26:00 -05:00
|
|
|
var testsToRun = foundTests;
|
|
|
|
|
|
|
|
if (process.env.CYPRESS_INTEGRATION === 'nextcloud') {
|
2020-09-22 09:51:23 -05:00
|
|
|
testsToRun = removeBlacklistedTest(filename, testsToRun, blacklists.nextcloudBlackList);
|
|
|
|
} else {
|
|
|
|
testsToRun = removeBlacklistedTest(filename, testsToRun, blacklists.nextcloudOnlyList);
|
2020-09-10 11:26:00 -05:00
|
|
|
}
|
|
|
|
|
2020-09-16 07:23:54 -05:00
|
|
|
if (process.env.CYPRESS_INTEGRATION === 'php-proxy') {
|
|
|
|
var ProxyblackList = blacklists.phpProxyBlackList;
|
|
|
|
testsToRun = removeBlacklistedTest(filename, testsToRun, ProxyblackList);
|
|
|
|
}
|
|
|
|
|
2021-06-07 04:32:53 -05:00
|
|
|
if (process.env.USER_INTERFACE === 'notebookbar') {
|
2022-03-10 04:42:14 -06:00
|
|
|
if (!isNotebookbarTest(filename,blacklists.notebookbarOnlyList)) {
|
2021-06-07 04:32:53 -05:00
|
|
|
testsToRun = [];
|
|
|
|
}
|
|
|
|
}
|
2021-11-01 02:07:19 -05:00
|
|
|
|
|
|
|
if (!process.env.UPDATE_SCREENSHOT) {
|
|
|
|
testsToRun = removeBlacklistedTest(filename, testsToRun, blacklists.updateScreenshotList);
|
|
|
|
}
|
|
|
|
|
2020-09-10 11:26:00 -05:00
|
|
|
return testsToRun;
|
|
|
|
}
|
|
|
|
|
2020-01-14 12:14:18 -06:00
|
|
|
module.exports = plugin;
|