mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
* remove useless module * upgrade to angular 8 * upgrade material to v8 * upgrade adf libs * migrate demo shell to v8 * upgrade to angular 9 * upgrade material to v9 * remove hammer * upgrade nx * upgrade datetime picker * upgrade flex layout * update core api * remove entry components * code fixes * upgrade testbed usage * code fixes * remove unnecessary core-js from tests * upgrade CLI * ts config fixes * fix builds * fix testing config * compile fixes * fix demo shell dev setup * fix core tests * fix card view import * upgrade nx * disable smart builds for now * remove fdescribe * restore smart builds * fix issues * unify tsconfigs and fix newly found issues * fix configuration and cleanup package scripts * improved production build from the same config * use ADF libs directly instead of node_modules * disable smart build * single app configuration (angular) * fix core build * fix build scripts * lint fixes * fix linting setup * fix linting rules * various fixes * disable affected libs for unit tests * cleanup insights package.json * simplify smart-build * fix content tests * fix tests * test fixes * fix tests * fix test * fix tests * disable AppExtensionsModule (monaco example) * remove monaco extension module * upgrade bundle check rules * fix insights tests and karma config * fix protractor config * e2e workaround * upgrade puppeteer and split linting and build * reusable resources config * update protractor config * fix after rebase * fix protractor config * fix e2e tsconfig * update e2e setup * Save demoshell artifact on S3 and remove travis cache * Push the libs on S3 and fetch before releasing it * Add deps * Add dependencies among libs and run only affected unit test and build * fix the travis stage name * fix after renaming dev to demoshell * force the order of the projects * remove unused dependencies * fix content e2e script * exit codes fix * add extra exit codes to core e2e * postinstall hook and package cleanup * cleanup packages * remove deprecated code and dependency on router * improve bundle analyzer script * minor code fixes * update spec * fix code after rebase * upgrade protractor after rebase * fix e2e mapping lib * Update tsconfig.e2e.json * update e2e tsconfig * fix angular config * fix protractor runs * cache dist folder for libs * update material selectors for dropdowns * selector fixes * remove duplicated e2e that have unit tests already * fix login selector * fix e2e * fix test * fix import issues * fix selector * cleanup old monaco extension files * cleanup demo shell login * add protractor max retries * disable customisations of protractor * fix login validation * fix after rebase * fix after rebase, disable latest versions of libs * Hide the report tab and rollback the localstorage * rename protractor config back to js * restore lint as part of build * cleanup code * do not copy anything to node_modules on dist test * fix unit tests * config fixes * fix code * fix code after rebase * fix tests * remove existing words from spellcheck * remove useless directive decorators * update package.json after rebase * add js-api back * code fixes * add missing export * update configs * fix code * try fix the sso login test * fix * remove puppeteer unit * fix e2e script * fix * make provider easy * fix routes module before upgrade * fix unit tests * upgrade angular cli * upgrade to angular 10 Co-authored-by: maurizio vitale <maurizio.vitale@alfresco.com> Co-authored-by: Eugenio Romano <eugenio.romano@alfresco.com> Co-authored-by: Eugenio Romano <eromano@users.noreply.github.com>
292 lines
8.9 KiB
JavaScript
292 lines
8.9 KiB
JavaScript
const {LocalStorageUtil, ACTIVITI_CLOUD_APPS, Logger} = require('../lib/dist/testing');
|
|
const path = require('path');
|
|
const {SpecReporter} = require('jasmine-spec-reporter');
|
|
const retry = require('protractor-retry').retry;
|
|
const tsConfig = require('./tsconfig.e2e.json');
|
|
const testConfig = require('./test.config');
|
|
const RESOURCES = require('./util/resources');
|
|
const smartRunner = require('protractor-smartrunner');
|
|
const resolve = require('path').resolve;
|
|
const fs = require('fs');
|
|
|
|
const {uploadScreenshot, cleanReportFolder} = require('./protractor/save-remote');
|
|
const argv = require('yargs').argv;
|
|
|
|
const width = 1657, height = 1657;
|
|
|
|
const ENV_FILE = process.env.ENV_FILE;
|
|
const GROUP_SUFFIX = process.env.PREFIX || 'adf';
|
|
|
|
RESOURCES.ACTIVITI_CLOUD_APPS = ACTIVITI_CLOUD_APPS;
|
|
if (ENV_FILE) {
|
|
require('dotenv').config({path: ENV_FILE});
|
|
}
|
|
|
|
const HOST = process.env.URL_HOST_ADF;
|
|
const BROWSER_RUN = !!process.env.BROWSER_RUN;
|
|
const FOLDER = process.env.FOLDER || '';
|
|
const SELENIUM_SERVER = process.env.SELENIUM_SERVER || '';
|
|
const MAXINSTANCES = process.env.MAXINSTANCES || 1;
|
|
const MAX_RETRIES = process.env.MAX_RETRIES || 4;
|
|
const TIMEOUT = parseInt(process.env.TIMEOUT, 10);
|
|
const SAVE_SCREENSHOT = (process.env.SAVE_SCREENSHOT === 'true');
|
|
const LIST_SPECS = process.env.LIST_SPECS || [];
|
|
const LOG = !!process.env.LOG;
|
|
|
|
let arraySpecs = [];
|
|
|
|
if (LOG) {
|
|
console.log('======= PROTRACTOR CONFIGURATION ====== ');
|
|
console.log('HOST: ', HOST);
|
|
console.log('BROWSER_RUN : ' + BROWSER_RUN);
|
|
console.log('SAVE_SCREENSHOT : ' + SAVE_SCREENSHOT);
|
|
console.log('FOLDER : ' + FOLDER);
|
|
console.log('MAXINSTANCES : ' + MAXINSTANCES);
|
|
console.log('LIST_SPECS : ' + LIST_SPECS);
|
|
console.log('MAX_RETRIES: ', MAX_RETRIES);
|
|
console.log('SELENIUM_SERVER : ' + SELENIUM_SERVER);
|
|
}
|
|
|
|
const downloadFolder = path.join(__dirname, '/downloads');
|
|
|
|
let specs = function () {
|
|
let LIST_SPECS;
|
|
|
|
if (process.env.LIST_SPECS) {
|
|
LIST_SPECS = process.env.LIST_SPECS;
|
|
}
|
|
|
|
if (LIST_SPECS && LIST_SPECS !== '') {
|
|
arraySpecs = LIST_SPECS.split(',');
|
|
arraySpecs = arraySpecs.map((el) => './' + el);
|
|
|
|
specExists(arraySpecs);
|
|
} else {
|
|
const FOLDER = process.env.FOLDER || '';
|
|
setProvider(FOLDER);
|
|
const specsToRun = FOLDER ? `./${FOLDER}/**/*.e2e.ts` : './**/*.ts';
|
|
arraySpecs = [specsToRun];
|
|
}
|
|
|
|
return arraySpecs;
|
|
};
|
|
|
|
let setProvider = function (folder) {
|
|
if (folder === 'core') {
|
|
testConfig.appConfig.provider = 'ALL';
|
|
} else if (folder === 'content-services') {
|
|
testConfig.appConfig.provider = 'ECM';
|
|
} else if (folder === 'process-services') {
|
|
testConfig.appConfig.provider = 'BPM';
|
|
} else if (folder === 'insights') {
|
|
testConfig.appConfig.provider = 'BPM';
|
|
} else if (folder === 'search') {
|
|
testConfig.appConfig.provider = 'ECM';
|
|
} else if (folder === 'process-services-cloud') {
|
|
testConfig.appConfig.provider = 'BPM';
|
|
}
|
|
};
|
|
|
|
let specExists = function (listSpecs) {
|
|
listSpecs.forEach((path) => {
|
|
if (!fs.existsSync(resolve(__dirname, path))) {
|
|
Logger.error(`Not valid spec path : ${resolve(__dirname, path)} valid path should be for example /search/search-component.e2e.ts`);
|
|
}
|
|
});
|
|
};
|
|
|
|
specs();
|
|
|
|
exports.config = {
|
|
allScriptsTimeout: TIMEOUT,
|
|
|
|
specs: arraySpecs,
|
|
|
|
useAllAngular2AppRoots: true,
|
|
|
|
capabilities: {
|
|
|
|
loggingPrefs: {
|
|
browser: 'ALL' // "OFF", "SEVERE", "WARNING", "INFO", "CONFIG", "FINE", "FINER", "FINEST", "ALL".
|
|
},
|
|
|
|
browserName: 'chrome',
|
|
|
|
maxInstances: MAXINSTANCES,
|
|
|
|
shardTestFiles: true,
|
|
|
|
chromeOptions: {
|
|
prefs: {
|
|
'credentials_enable_service': false,
|
|
'download': {
|
|
'prompt_for_download': false,
|
|
'directory_upgrade': true,
|
|
'default_directory': downloadFolder
|
|
},
|
|
'browser': {
|
|
'setDownloadBehavior': {
|
|
'behavior': 'allow',
|
|
'downloadPath': downloadFolder
|
|
}
|
|
}
|
|
},
|
|
args: ['--incognito',
|
|
`--window-size=${width},${height}`,
|
|
'--disable-gpu',
|
|
'--no-sandbox',
|
|
'--disable-web-security',
|
|
'--disable-browser-side-navigation',
|
|
...(BROWSER_RUN === true ? [] : ['--headless'])]
|
|
}
|
|
},
|
|
|
|
directConnect: !SELENIUM_SERVER,
|
|
|
|
baseUrl: HOST,
|
|
|
|
params: {
|
|
testConfig: testConfig,
|
|
loginRoute: '/login',
|
|
groupSuffix: GROUP_SUFFIX,
|
|
identityAdmin: testConfig.identityAdmin,
|
|
identityUser: testConfig.identityUser,
|
|
resources: RESOURCES
|
|
},
|
|
|
|
framework: 'jasmine2',
|
|
|
|
getPageTimeout: 90000,
|
|
|
|
jasmineNodeOpts: {
|
|
showColors: true,
|
|
defaultTimeoutInterval: 120000,
|
|
print: () => {
|
|
},
|
|
...smartRunner.withOptionalExclusions(
|
|
resolve(__dirname, './protractor.excludes.json')
|
|
)
|
|
},
|
|
|
|
/**
|
|
* The address of a running selenium server (must be manually start before running the tests). If this is specified seleniumServerJar and seleniumPort will be ignored.
|
|
* @config {String} seleniumAddress
|
|
*/
|
|
seleniumAddress: SELENIUM_SERVER,
|
|
|
|
SELENIUM_PROMISE_MANAGER: false,
|
|
|
|
plugins: [{
|
|
package: 'jasmine2-protractor-utils',
|
|
disableScreenshot: false,
|
|
screenshotOnExpectFailure: true,
|
|
screenshotOnSpecFailure: false,
|
|
clearFoldersBeforeTest: true,
|
|
screenshotPath: path.resolve(__dirname, 'e2e-output/screenshots/')
|
|
}],
|
|
|
|
onCleanUp(results) {
|
|
retry.onCleanUp(results);
|
|
},
|
|
|
|
async onPrepare() {
|
|
retry.onPrepare();
|
|
|
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = TIMEOUT;
|
|
|
|
require('ts-node').register({
|
|
project: require('path').join(__dirname, './tsconfig.e2e.json')
|
|
});
|
|
|
|
require('tsconfig-paths').register({
|
|
project: './e2e/tsconfig.e2e.json',
|
|
baseUrl: './e2e/',
|
|
paths: tsConfig.compilerOptions.paths
|
|
});
|
|
|
|
// @ts-ignore
|
|
browser.driver.sendChromiumCommand('Page.setDownloadBehavior', {
|
|
behavior: 'allow',
|
|
downloadPath: downloadFolder
|
|
});
|
|
|
|
// @ts-ignore
|
|
browser.manage().window().setSize(width, height);
|
|
|
|
jasmine.getEnv().addReporter(
|
|
new SpecReporter({
|
|
spec: {
|
|
displayStacktrace: true,
|
|
displayDuration: true
|
|
}
|
|
})
|
|
);
|
|
|
|
// @ts-ignore
|
|
await browser.driver.executeScript(disableCSSAnimation);
|
|
|
|
// @ts-ignore
|
|
await browser.get(`${HOST}/settings`);
|
|
await LocalStorageUtil.clearStorage();
|
|
// @ts-ignore
|
|
await LocalStorageUtil.setStorageItem('ecmHost', browser.params.testConfig.appConfig.ecmHost);
|
|
// @ts-ignore
|
|
await LocalStorageUtil.setStorageItem('bpmHost', browser.params.testConfig.appConfig.bpmHost);
|
|
// @ts-ignore
|
|
await LocalStorageUtil.setStorageItem('providers', browser.params.testConfig.appConfig.provider);
|
|
await LocalStorageUtil.setStorageItem('baseShareUrl', HOST);
|
|
|
|
// @ts-ignore
|
|
if (browser.params.testConfig.appConfig.authType === 'OAUTH') {
|
|
// @ts-ignore
|
|
await LocalStorageUtil.setStorageItem('authType', browser.params.testConfig.appConfig.authType);
|
|
// @ts-ignore
|
|
await LocalStorageUtil.setStorageItem('identityHost', browser.params.testConfig.appConfig.identityHost);
|
|
// @ts-ignore
|
|
await LocalStorageUtil.setStorageItem('oauth2', JSON.stringify(browser.params.testConfig.appConfig.oauth2));
|
|
}
|
|
|
|
await LocalStorageUtil.apiReset();
|
|
|
|
function disableCSSAnimation() {
|
|
const css = '* {' +
|
|
'-webkit-transition-duration: 0s !important;' +
|
|
'transition-duration: 0s !important;' +
|
|
'-webkit-animation-duration: 0s !important;' +
|
|
'animation-duration: 0s !important;' +
|
|
'}';
|
|
const head = document.head || document.getElementsByTagName('head')[0];
|
|
const style = document.createElement('style');
|
|
|
|
style.type = 'text/css';
|
|
style.appendChild(document.createTextNode(css));
|
|
head.appendChild(style);
|
|
}
|
|
|
|
},
|
|
|
|
|
|
beforeLaunch: function () {
|
|
if (SAVE_SCREENSHOT) {
|
|
cleanReportFolder();
|
|
}
|
|
},
|
|
|
|
afterLaunch: async function () {
|
|
if (SAVE_SCREENSHOT) {
|
|
let retryCount = 1;
|
|
if (argv.retry) {
|
|
retryCount = ++argv.retry;
|
|
}
|
|
try {
|
|
await uploadScreenshot(retryCount);
|
|
} catch (error) {
|
|
console.error('Error saving screenshot', error);
|
|
}
|
|
}
|
|
|
|
return retry.afterLaunch(MAX_RETRIES);
|
|
}
|
|
|
|
};
|