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-05-18 15:23:50 -05:00
|
|
|
on('before:browser:launch', function(browser, launchOptions) {
|
|
|
|
if (browser.family === 'chromium' && process.env.ENABLE_LOGGING) {
|
|
|
|
launchOptions.args.push('--enable-logging=stderr');
|
|
|
|
launchOptions.args.push('--v=2');
|
|
|
|
return launchOptions;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
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')) {
|
|
|
|
if (versionString.includes(' 6.2.')) {
|
|
|
|
return 'cp-6-2';
|
|
|
|
} else if (versionString.includes(' 6.4.')) {
|
|
|
|
return 'cp-6-4';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 'master';
|
|
|
|
}
|
|
|
|
|
|
|
|
function pickTests(filename, foundTests, config) {
|
|
|
|
|
|
|
|
var coreVersion = getLOVersion(config);
|
|
|
|
var testsToRun = foundTests;
|
|
|
|
if (!(coreVersion in blacklists.testBlackLists))
|
|
|
|
return testsToRun;
|
|
|
|
|
|
|
|
var blackList = blacklists.testBlackLists[coreVersion];
|
|
|
|
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 [];
|
|
|
|
testsToRun = testsToRun.filter(fullTestName => !blackList[i][1].includes(fullTestName[1]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return testsToRun;
|
|
|
|
}
|
|
|
|
|
2020-01-14 12:14:18 -06:00
|
|
|
module.exports = plugin;
|