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-01-14 12:14:18 -06:00
|
|
|
var tasks = require('./tasks');
|
2020-06-05 09:42:23 -05:00
|
|
|
var blacklists = require('./blacklists');
|
|
|
|
var selectTests = require('cypress-select-tests');
|
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);
|
2020-01-14 12:14:18 -06:00
|
|
|
on('task', {
|
2020-03-13 07:47:15 -05:00
|
|
|
copyFile: tasks.copyFile,
|
|
|
|
failed: require('cypress-failed-log/src/failed')()
|
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;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (process.env.ENABLE_LOGGING) {
|
|
|
|
on('before:browser:launch', function(browser, launchOptions) {
|
|
|
|
if (browser.family === 'chromium') {
|
|
|
|
launchOptions.args.push('--enable-logging=stderr');
|
|
|
|
launchOptions.args.push('--v=2');
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-06-05 09:42:23 -05:00
|
|
|
on('file:preprocessor', selectTests(config, pickTests));
|
|
|
|
|
2020-01-14 12:14:18 -06:00
|
|
|
return config;
|
|
|
|
}
|
|
|
|
|
2020-06-05 09:42:23 -05:00
|
|
|
function getLOVersion(config) {
|
|
|
|
var versionString = config.env.LO_CORE_VERSION;
|
|
|
|
if (versionString.includes('Collabora')) {
|
2020-07-24 07:56:55 -05:00
|
|
|
if (versionString.includes('_6.2.')) {
|
2020-06-05 09:42:23 -05:00
|
|
|
return 'cp-6-2';
|
2020-07-24 07:56:55 -05:00
|
|
|
} else if (versionString.includes('_6.4.')) {
|
2020-06-05 09:42:23 -05:00
|
|
|
return 'cp-6-4';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 'master';
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-09-10 11:26:00 -05:00
|
|
|
function pickTests(filename, foundTests, config) {
|
|
|
|
var coreVersion = getLOVersion(config);
|
|
|
|
var testsToRun = foundTests;
|
|
|
|
if (!(coreVersion in blacklists.coreBlackLists))
|
|
|
|
return testsToRun;
|
|
|
|
|
|
|
|
var coreblackList = blacklists.coreBlackLists[coreVersion];
|
|
|
|
testsToRun = removeBlacklistedTest(filename, testsToRun, coreblackList);
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2020-09-10 11:26:00 -05:00
|
|
|
return testsToRun;
|
|
|
|
}
|
|
|
|
|
2020-01-14 12:14:18 -06:00
|
|
|
module.exports = plugin;
|