mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
* library dialog * integrate with demo shell * update resources * fix license * auto focus for the first input * update e2e tests * try close the dialog between tests * fix afterEach * Revert "try close the dialog between tests" This reverts commit 63464f2b03c226c606d09b18c7d2782e3bb52c0a. * update code due to css lint issues * csslint settings for vs code * missing import lint fix remove not used import convert errorPage js to ts convert tasklistpage js to ts fix redirection creation folder in root fix lint issue fix e2e * e2e fix * fix PS tests * navigation import * fix tests tooltip convert paginapage to ts * fix lint * fix lock files e2e filterspage to ts * fix lint * fix cs cre git dept 3 and not 50 as default in travis * quiet log git download * add some delay and change the delete lock * fix node entry * convert searchDialog to typescript parallel protractor * disable browser execute * restote test * change search tests * move search in a separate e2e folder * experiment fix e2e * change util presence change protractor conf * fix unshare test * improve query viewerPage using css over xpath * waitForAngularEnabled before browser redirect * convert util to ts and more * convert other files to ts * convert to ts other files * trigger build * function fixes use arrow function * process service fixes * lint fix review timeout default * fix failing tests * restore timeout * share dialog fix * remove * use configuration admin * fix APS 2 login sso
321 lines
10 KiB
JavaScript
321 lines
10 KiB
JavaScript
const path = require('path');
|
|
const {SpecReporter} = require('jasmine-spec-reporter');
|
|
const jasmineReporters = require('jasmine-reporters');
|
|
const htmlReporter = require('protractor-html-reporter-2');
|
|
const retry = require('protractor-retry').retry;
|
|
|
|
const AlfrescoApi = require('alfresco-js-api-node');
|
|
const TestConfig = require('./e2e/test.config');
|
|
var argv = require('yargs').argv;
|
|
|
|
const fs = require('fs');
|
|
const rimraf = require('rimraf');
|
|
|
|
const projectRoot = path.resolve(__dirname);
|
|
|
|
const width = 1366;
|
|
const height = 768;
|
|
|
|
var HOST = process.env.URL_HOST_ADF;
|
|
var BROWSER_RUN = process.env.BROWSER_RUN;
|
|
var FOLDER = process.env.FOLDER || '';
|
|
var SELENIUM_SERVER = process.env.SELENIUM_SERVER || '';
|
|
var DIRECT_CONNECCT = SELENIUM_SERVER ? false : true;
|
|
var MAXINSTANCES = process.env.MAXINSTANCES || 1;
|
|
var TIMEOUT = parseInt(process.env.TIMEOUT, 10);
|
|
|
|
var specsToRun = './**/' + FOLDER + '**/*.e2e.ts';
|
|
|
|
if (process.env.NAME_TEST) {
|
|
specsToRun = './e2e/**/' + process.env.NAME_TEST;
|
|
}
|
|
|
|
var args_options = [];
|
|
|
|
if (BROWSER_RUN === 'true') {
|
|
args_options = ['--incognito', '--window-size=1366,768', '--disable-gpu'];
|
|
} else {
|
|
args_options = ['--incognito', '--headless', '--window-size=1366,768', '--disable-gpu'];
|
|
}
|
|
|
|
var downloadFolder = path.join(__dirname, 'e2e/downloads');
|
|
|
|
var buildNumber = () => {
|
|
let buildNumber = process.env.TRAVIS_BUILD_NUMBER;
|
|
if (!buildNumber) {
|
|
process.env.TRAVIS_BUILD_NUMBER = Date.now();
|
|
}
|
|
|
|
return process.env.TRAVIS_BUILD_NUMBER;
|
|
}
|
|
|
|
exports.config = {
|
|
allScriptsTimeout: TIMEOUT,
|
|
|
|
specs: [
|
|
specsToRun
|
|
],
|
|
|
|
useAllAngular2AppRoots: true,
|
|
|
|
capabilities: {
|
|
browserName: 'chrome',
|
|
|
|
shardTestFiles: true,
|
|
maxInstances: MAXINSTANCES,
|
|
chromeOptions: {
|
|
prefs: {
|
|
'credentials_enable_service': false,
|
|
'download': {
|
|
'prompt_for_download': false,
|
|
'default_directory': downloadFolder
|
|
}
|
|
},
|
|
args: args_options
|
|
}
|
|
},
|
|
|
|
directConnect: DIRECT_CONNECCT,
|
|
|
|
baseUrl: "http://" + HOST,
|
|
|
|
framework: 'jasmine2',
|
|
|
|
jasmineNodeOpts: {
|
|
showColors: true,
|
|
defaultTimeoutInterval: 90000,
|
|
print: function () {
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 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,
|
|
|
|
plugins: [{
|
|
package: 'jasmine2-protractor-utils',
|
|
disableScreenshot: false,
|
|
screenshotOnExpectFailure: true,
|
|
screenshotOnSpecFailure: false,
|
|
clearFoldersBeforeTest: true,
|
|
screenshotPath: `${projectRoot}/e2e-output/screenshots/`
|
|
}],
|
|
|
|
onCleanUp(results) {
|
|
retry.onCleanUp(results);
|
|
},
|
|
|
|
onPrepare() {
|
|
retry.onPrepare();
|
|
|
|
require('ts-node').register({
|
|
project: 'e2e/tsconfig.e2e.json'
|
|
});
|
|
|
|
browser.manage().window().setSize(width, height);
|
|
|
|
jasmine.getEnv().addReporter(new SpecReporter({spec: {displayStacktrace: true}}));
|
|
var generatedSuiteName = Math.random().toString(36).substr(2, 5);
|
|
var junitReporter = new jasmineReporters.JUnitXmlReporter({
|
|
consolidateAll: true,
|
|
savePath: `${projectRoot}/e2e-output/junit-report`,
|
|
filePrefix: 'results.xml-' + generatedSuiteName,
|
|
});
|
|
jasmine.getEnv().addReporter(junitReporter);
|
|
|
|
return browser.driver.executeScript(disableCSSAnimation);
|
|
|
|
function disableCSSAnimation() {
|
|
var css = '* {' +
|
|
'-webkit-transition-duration: 0s !important;' +
|
|
'transition-duration: 0s !important;' +
|
|
'-webkit-animation-duration: 0s !important;' +
|
|
'animation-duration: 0s !important;' +
|
|
'}',
|
|
head = document.head || document.getElementsByTagName('head')[0],
|
|
style = document.createElement('style');
|
|
|
|
style.type = 'text/css';
|
|
style.appendChild(document.createTextNode(css));
|
|
head.appendChild(style);
|
|
}
|
|
|
|
},
|
|
|
|
beforeLaunch: function () {
|
|
var reportsFolder = `${projectRoot}/e2e-output/junit-report/`;
|
|
|
|
fs.exists(reportsFolder, function (exists, error) {
|
|
if (exists) {
|
|
rimraf(reportsFolder, function (err) {
|
|
console.log('[ERROR] rimraf: ', err);
|
|
});
|
|
}
|
|
|
|
if (error) {
|
|
console.log('[ERROR] fs', error);
|
|
}
|
|
});
|
|
},
|
|
|
|
afterLaunch: async function () {
|
|
|
|
let saveScreenshot = process.env.SAVE_SCREENSHOT;
|
|
|
|
if (saveScreenshot) {
|
|
var retryCount = 1;
|
|
if (argv.retry) {
|
|
retryCount = ++argv.retry;
|
|
}
|
|
|
|
let filenameReport = `ProtractorTestReport-${FOLDER.replace('/', '')}-${retryCount}`;
|
|
|
|
console.log(filenameReport);
|
|
|
|
let output = '';
|
|
let savePath = `${projectRoot}/e2e-output/junit-report/`;
|
|
let temporaryHtmlPath = savePath + 'html/temporaryHtml/';
|
|
let lastFileName = '';
|
|
|
|
let files = fs.readdirSync(savePath);
|
|
|
|
if (files && files.length > 0) {
|
|
for (const fileName of files) {
|
|
testConfigReport = {
|
|
reportTitle: 'Protractor Test Execution Report',
|
|
outputPath: temporaryHtmlPath,
|
|
outputFilename: Math.random().toString(36).substr(2, 5) + filenameReport,
|
|
};
|
|
|
|
let filePath = `${projectRoot}/e2e-output/junit-report/` + fileName;
|
|
|
|
new htmlReporter().from(filePath, testConfigReport);
|
|
lastFileName = testConfigReport.outputFilename;
|
|
}
|
|
}
|
|
;
|
|
|
|
var lastHtmlFile = temporaryHtmlPath + lastFileName + '.html';
|
|
|
|
if (!(fs.lstatSync(lastHtmlFile).isDirectory())) {
|
|
output = output + fs.readFileSync(lastHtmlFile);
|
|
}
|
|
;
|
|
|
|
var fileName = savePath + 'html/' + filenameReport + '.html';
|
|
|
|
fs.writeFileSync(fileName, output, 'utf8');
|
|
|
|
let alfrescoJsApi = new AlfrescoApi({
|
|
provider: 'ECM',
|
|
hostEcm: TestConfig.adf.url
|
|
});
|
|
alfrescoJsApi.login(TestConfig.adf.adminEmail, TestConfig.adf.adminPassword);
|
|
|
|
if (saveScreenshot === 'true') {
|
|
|
|
let files = fs.readdirSync(path.join(__dirname, './e2e-output/screenshots'));
|
|
|
|
if (files && files.length > 0) {
|
|
|
|
try {
|
|
folder = await
|
|
alfrescoJsApi.nodes.addNode('-my-', {
|
|
'name': `retry-${retryCount}`,
|
|
'relativePath': `Builds/${buildNumber()}/screenshot`,
|
|
'nodeType': 'cm:folder'
|
|
}, {}, {
|
|
'overwrite': true
|
|
});
|
|
} catch (error) {
|
|
folder = await
|
|
alfrescoJsApi.nodes.getNode('-my-', {
|
|
'relativePath': `Builds/${buildNumber()}/screenshot/retry-${retryCount}`,
|
|
'nodeType': 'cm:folder'
|
|
}, {}, {
|
|
'overwrite': true
|
|
});
|
|
}
|
|
|
|
for (const fileName of files) {
|
|
|
|
let pathFile = path.join(__dirname, './e2e-output/screenshots', fileName);
|
|
let file = fs.createReadStream(pathFile);
|
|
|
|
await
|
|
alfrescoJsApi.upload.uploadFile(
|
|
file,
|
|
'',
|
|
folder.entry.id,
|
|
null,
|
|
{
|
|
'name': file.name,
|
|
'nodeType': 'cm:content',
|
|
'autoRename': true
|
|
}
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
let pathFile = path.join(__dirname, './e2e-output/junit-report/html', filenameReport + '.html');
|
|
let reportFile = fs.createReadStream(pathFile);
|
|
|
|
let reportFolder;
|
|
|
|
try {
|
|
reportFolder = await
|
|
alfrescoJsApi.nodes.addNode('-my-', {
|
|
'name': 'report',
|
|
'relativePath': `Builds/${buildNumber()}`,
|
|
'nodeType': 'cm:folder'
|
|
}, {}, {
|
|
'overwrite': true
|
|
});
|
|
} catch (error) {
|
|
reportFolder = await
|
|
alfrescoJsApi.nodes.getNode('-my-', {
|
|
'relativePath': `Builds/${buildNumber()}/report`,
|
|
'nodeType': 'cm:folder'
|
|
}, {}, {
|
|
'overwrite': true
|
|
});
|
|
|
|
}
|
|
|
|
try {
|
|
await
|
|
alfrescoJsApi.upload.uploadFile(
|
|
reportFile,
|
|
'',
|
|
reportFolder.entry.id,
|
|
null,
|
|
{
|
|
'name': reportFile.name,
|
|
'nodeType': 'cm:content',
|
|
'autoRename': true
|
|
}
|
|
);
|
|
|
|
} catch (error) {
|
|
console.log('error' + error);
|
|
|
|
}
|
|
|
|
if (saveScreenshot === 'true') {
|
|
rimraf(`${projectRoot}/e2e-output/screenshots/`, function () {
|
|
console.log('done delete screenshot');
|
|
});
|
|
}
|
|
|
|
}
|
|
|
|
return retry.afterLaunch(3);
|
|
}
|
|
};
|
|
|
|
|
|
|