mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
* remove unneeded JS-API dep
move auth in the right place
* [AAE-12501] Replace alfresco api client with AdfHttpClient
* [AAE-12501] Restore get username methods
* [AAE-12501] Get username with authentication service
* [AAE-12501] Create a request options interface with the needed props, remove the import from js-api, return the body from request
* add emitters
* [AAE-12501] Replace Math.random() to fix hospot security issue, fix lint issues
* [AAE-12501] Comment temporary setCsrfToken because is not possible to import app config service from core due to circular dependencies
* [AAE-12501] Get disableCsrf from app config serviice when app configuration is loaded
* [AAE-12501] Remove wrong character
* Pass down the requestUrl for request interception
bring back check from js-api
fixing isLogin issues part1
some fix around emit
Narrow access for methods
fix sso username issue
Switch to dynamic service injection
add emitters
move auth inside ADF
* clean
* fix unit test
* fix lint
* Fix exports
* Fix process-services unit tests
* Fix core unit tests
Fix core unit tests
Fix core unit tests
Fix core unit tests
Fix core unit tests
Fix core unit tests
Fix core unit tests
* Fix content-services unit tests: getEcmUsername from authentication service
Fix content-services unit tests: alfresco api service has been replaced by authentication service
* Fix circular dependecies issue importing AppConfigService outside the api entrypoint dir
* Import AuthModule even in not only canary mode to let the e2es run
* Fix authentication unit tests
* Fix unit test '[ECM] should return a ticket undefined after logout'
* Remove AlfrescoApiService is not used anymore
* Fix unit test '[BPM] should return an BPM ticket after the login done': add Basic suffix to basicAuth
* Fix unit tests core
* Fix login errors with the BASIC authentication
* Fix missing onLogin event
* Temporary skip unit tests to check e2es
* Fix login component doesn't add the authorization header
* Fix prefix is undefined
* Fix image is not showed by the alfresco file viewer because alf_ticket is not added to the content url query params, pass ticketEcm to the alfrescoApi configuration used by alfrescoApiClient.ts getAlfTicket()
* Fix C280012: set app prefix before calling content api
* Revert "Fix image is not showed by the alfresco file viewer because alf_ticket is not added to the content url query params, pass ticketEcm to the alfrescoApi configuration used by alfrescoApiClient.ts getAlfTicket()"
This reverts commit afbf086b98d72835aab8b15d4af433efeaac2d3b.
* try to change adf core autoamtion service init
* go back
* grant type password login
* fix
* remove automatic login in reset try
* fix not silent login
* lint happy
* fix
* Update alfresco-api-v2-loader.service.ts
* fixint
* Revert "Temporary skip unit tests to check e2es"
This reverts commit a0adc7e58a001a54442c82952761bff891caa5cd.
* fix modules
* fix app config stream in storing service
fix app config stream for sub property
* fix identity test to use the real service
* fix unit
* fix unit
* fix unit
* remove test that are probably have never been green
* fix
* fix PC
* fix localstorage
* fix
* fix
* fix
* fix
* fix storybook
move e2e in content for versioning
fix lint
* fix
* fix size
* enable log
* some fix for usernames
* remove log
* fix rebase
* [AAE-12502] Restore isKerberosEnabled into authentication service
* subject onLogin
* fix unit
* Fix lint issue
* fix
* Update error message
* Revert change did by b79c5d37d6
\#diff-ad85723e21276e05e577bab652c6ab0d243bd0ad54d4cc70ef6e60dc5e635c33L38
* Refresh the browser to wait for the user to click process cloud page
* Remove e2e, the application list is already tested by the app-list-cloud.component.spec.ts https://github.com/Alfresco/alfresco-ng2-components/blob/dev-eromano-AAE-12501-2/lib/process-services-cloud/src/lib/app/components/app-list-cloud.component.spec.ts\#L147
* [12502] Add getUsername method to the AuthenticationService
* [12501] restore mutlipart/form-data header needed by angular http-client to to fix 415 unsupported media type
* Revert "[12501] restore mutlipart/form-data header needed by angular http-client to to fix 415 unsupported media type"
This reverts commit d8c584b94f649b57859d74157ec0861f2ebddebb.
* [12501] fix unsupported upload file on admin-apa, append json content type only calling alfresco api
* [12501] fix unsupported upload file on admin-apa
[12501] fix unsupported upload file on admin-apa
* Revert "[12501] fix unsupported upload file on admin-apa"
This reverts commit 53cda21d795588d87244c78c5a5347afd04ea2b1.
* Improve getHeaders
* Revert change
* Set application/json content type if request body is not a FormData
* Logout by the authenticationService
* Update returned error message
* Fix lint issues after rebasing
* [12502] Add basic template with data-automation-ad selector to check when is attached to the Dom
* Fix issues after rebase
---------
Co-authored-by: Amedeo Lepore <amedeo.lepore@hyland.com>
Co-authored-by: Andras Popovics <popovics@ndras.hu>
343 lines
11 KiB
JavaScript
343 lines
11 KiB
JavaScript
const { LocalStorageUtil, Logger } = require('@alfresco/adf-testing');
|
|
const path = require('path');
|
|
const { SpecReporter } = require('jasmine-spec-reporter');
|
|
const retry = require('protractor-retry-angular-cli').retry;
|
|
const tsConfig = require('./tsconfig.e2e.json');
|
|
const testConfig = require('./test.config');
|
|
const RESOURCES = require('./util/resources');
|
|
const resolve = require('path').resolve;
|
|
const fs = require('fs');
|
|
const smartRunnerFactory = require('./smartrunner-factory');
|
|
|
|
const { uploadScreenshot } = 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 || process.env.GH_BUILD_NUMBER || 'adf';
|
|
|
|
if (ENV_FILE) {
|
|
require('dotenv').config({ path: ENV_FILE });
|
|
}
|
|
|
|
const HOST = process.env.URL_HOST_ADF;
|
|
const BROWSER_RUN = [true, 'true'].includes(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 = [];
|
|
|
|
console.log('Parallel e2e : ' + MAXINSTANCES);
|
|
console.log('Max fail Retry: ', MAX_RETRIES);
|
|
|
|
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('LIST_SPECS : ' + LIST_SPECS);
|
|
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.replace('e2e/', ''));
|
|
|
|
specExists(arraySpecs);
|
|
} else {
|
|
const FOLDER = process.env.FOLDER || '';
|
|
setProvider(FOLDER);
|
|
const specsToRun = FOLDER ? `./${FOLDER}/**/*.e2e.ts` : './**/*.e2e.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: 30000,
|
|
|
|
specs: arraySpecs,
|
|
|
|
suites: {
|
|
smokeTestCore: [
|
|
"./core/login-sso/login-sso.e2e.ts",
|
|
"./core/viewer/**/*.e2e.ts"
|
|
],
|
|
smokeTestCsSearch: [
|
|
"./content-services/document-list/**/*.e2e.ts",
|
|
"./content-services/metadata/**/*.e2e.ts",
|
|
"./search/components/**/*.e2e.ts"
|
|
],
|
|
smokeTestPs: [
|
|
"./process-services/process/**/*.e2e.ts",
|
|
"./process-services/form/**/*.e2e.ts",
|
|
"./process-services-cloud/process/**/*.e2e.ts"
|
|
]
|
|
},
|
|
|
|
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: [
|
|
`--window-size=${width},${height}`,
|
|
'--disable-gpu',
|
|
'--no-sandbox',
|
|
'--disable-web-security',
|
|
'--disable-browser-side-navigation',
|
|
'--allow-running-insecure-content',
|
|
...(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: 'jasmine',
|
|
|
|
getPageTimeout: 90000,
|
|
|
|
jasmineNodeOpts: {
|
|
showColors: true,
|
|
defaultTimeoutInterval: 180000,
|
|
includeStackTrace: true,
|
|
print: () => {
|
|
},
|
|
...(process.env.CI ? smartRunnerFactory.applyExclusionFilter() : {})
|
|
},
|
|
|
|
/**
|
|
* 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: 'protractor-screenshoter-plugin',
|
|
screenshotPath: path.resolve(__dirname, '../e2e-output/'),
|
|
screenshotOnExpect: 'failure',
|
|
withLogs: true,
|
|
writeReportFreq: 'end',
|
|
imageToAscii: 'none',
|
|
htmlOnExpect: 'none',
|
|
htmlOnSpec: 'none',
|
|
clearFoldersBeforeTest: false
|
|
}],
|
|
|
|
onCleanUp(results) {
|
|
if (process.env.CI) {
|
|
retry.onCleanUp(results);
|
|
}
|
|
},
|
|
|
|
async onPrepare() {
|
|
if (process.env.CI) {
|
|
retry.onPrepare();
|
|
smartRunnerFactory.getInstance().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: 'raw',
|
|
displayDuration: true
|
|
}
|
|
})
|
|
);
|
|
|
|
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);
|
|
}
|
|
|
|
// @ts-ignore
|
|
await browser.driver.executeScript(disableCSSAnimation);
|
|
|
|
// @ts-ignore
|
|
await browser.waitForAngularEnabled(false);
|
|
await browser.get(`${HOST}/#/settings`);
|
|
await browser.waitForAngularEnabled(true);
|
|
|
|
try {
|
|
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);
|
|
|
|
// @ts-ignore
|
|
await LocalStorageUtil.setStorageItem('authType', browser.params.testConfig.appConfig.authType);
|
|
|
|
// @ts-ignore
|
|
if (browser.params.testConfig.appConfig.authType === 'OAUTH') {
|
|
Logger.info(`Configure demo shell OAUTH`);
|
|
// @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();
|
|
|
|
} catch (error) {
|
|
Logger.error(`====== Demo shell not able to start ======`);
|
|
Logger.error(error);
|
|
process.exit();
|
|
}
|
|
},
|
|
|
|
afterLaunch: async function (statusCode) {
|
|
if (SAVE_SCREENSHOT) {
|
|
console.log(`Save screenshot enabled`);
|
|
|
|
let retryCount = 1;
|
|
if (argv.retry) {
|
|
retryCount = ++argv.retry;
|
|
}
|
|
try {
|
|
await uploadScreenshot(retryCount, (process.env.FOLDER || ''));
|
|
} catch (error) {
|
|
console.error('Error saving screenshot', error);
|
|
}
|
|
} else {
|
|
console.log(`Save screenshot disabled`);
|
|
}
|
|
|
|
return retry.afterLaunch(MAX_RETRIES, statusCode);
|
|
},
|
|
|
|
onComplete: async function () {
|
|
browser.manage().logs().get('browser').then(function (browserLog) {
|
|
if (browserLog.length) {
|
|
browserLog = browserLog.filter((log) => {
|
|
return log.level.name_ === 'SEVERE';
|
|
})
|
|
if (browserLog.length) {
|
|
console.error('\x1b[31m', '============ Browser console error ===========');
|
|
|
|
browserLog.forEach((log) => {
|
|
console.error('\x1b[31m', log.message);
|
|
})
|
|
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
};
|