Add HTML Reporter (#3757)

* Add HTML Reporter;
Removed parallel execution;
Removed z-finish.e2e.ts tests;
Copy the screenshots and the report to an environment.

* fix report upload and unify folder
This commit is contained in:
cristinaj
2018-09-10 18:02:29 +03:00
committed by Eugenio Romano
parent 04799f0c95
commit 2a883fca5f
5 changed files with 120 additions and 241 deletions

View File

@@ -1,79 +0,0 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AlfrescoApi = require('alfresco-js-api-node');
import TestConfig = require('../test.config');
import fs = require('fs');
import path = require('path');
let buildNumber = process.env.TRAVIS_BUILD_NUMBER;
let saveScreenshot = process.env.SAVE_SCREENSHOT;
describe('Save screenshot at the end', () => {
beforeAll(async (done) => {
if (saveScreenshot === 'true') {
if (!buildNumber) {
buildNumber = Date.now();
}
let alfrescoJsApi = new AlfrescoApi({
provider: 'ECM',
hostEcm: TestConfig.adf.url
});
let files = fs.readdirSync(path.join(__dirname, '../../e2e-output/screenshots'));
if (files && files.length > 0) {
alfrescoJsApi.login(TestConfig.adf.adminEmail, TestConfig.adf.adminPassword);
let folder = await alfrescoJsApi.nodes.addNode('-my-', {
'name': 'content-services',
'relativePath': 'Build-screenshot/Screenshot-e2e-' + buildNumber,
'nodeType': 'cm:folder'
}, {}, {
'overwrite': true
});
for (const fileName of files) {
let pathFile = path.join(__dirname, '../../e2e-output/screenshots', fileName);
let file: any = fs.createReadStream(pathFile);
await alfrescoJsApi.upload.uploadFile(
file,
'',
folder.entry.id,
null,
{
'name': file.name,
'nodeType': 'cm:content'
}
);
}
}
}
done();
});
it('screenshot need it', () => {
expect(true).toEqual(true);
});
});

View File

@@ -1,79 +0,0 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AlfrescoApi = require('alfresco-js-api-node');
import TestConfig = require('../test.config');
import fs = require('fs');
import path = require('path');
let buildNumber = process.env.TRAVIS_BUILD_NUMBER;
let saveScreenshot = process.env.SAVE_SCREENSHOT;
describe('Save screenshot at the end', () => {
beforeAll(async (done) => {
if (saveScreenshot === 'true') {
if (!buildNumber) {
buildNumber = Date.now();
}
let alfrescoJsApi = new AlfrescoApi({
provider: 'ECM',
hostEcm: TestConfig.adf.url
});
let files = fs.readdirSync(path.join(__dirname, '../../e2e-output/screenshots'));
if (files && files.length > 0) {
alfrescoJsApi.login(TestConfig.adf.adminEmail, TestConfig.adf.adminPassword);
let folder = await alfrescoJsApi.nodes.addNode('-my-', {
'name': 'core',
'relativePath': 'Build-screenshot/Screenshot-e2e-' + buildNumber,
'nodeType': 'cm:folder'
}, {}, {
'overwrite': true
});
for (const fileName of files) {
let pathFile = path.join(__dirname, '../../e2e-output/screenshots', fileName);
let file: any = fs.createReadStream(pathFile);
await alfrescoJsApi.upload.uploadFile(
file,
'',
folder.entry.id,
null,
{
'name': file.name,
'nodeType': 'cm:content'
}
);
}
}
}
done();
});
it('screenshot need it', () => {
expect(true).toEqual(true);
});
});

View File

@@ -1,79 +0,0 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AlfrescoApi = require('alfresco-js-api-node');
import TestConfig = require('../test.config');
import fs = require('fs');
import path = require('path');
let buildNumber = process.env.TRAVIS_BUILD_NUMBER;
let saveScreenshot = process.env.SAVE_SCREENSHOT;
describe('Save screenshot at the end', () => {
beforeAll(async (done) => {
if (saveScreenshot === 'true') {
if (!buildNumber) {
buildNumber = Date.now();
}
let alfrescoJsApi = new AlfrescoApi({
provider: 'ECM',
hostEcm: TestConfig.adf.url
});
let files = fs.readdirSync(path.join(__dirname, '../../e2e-output/screenshots'));
if (files && files.length > 0) {
alfrescoJsApi.login(TestConfig.adf.adminEmail, TestConfig.adf.adminPassword);
let folder = await alfrescoJsApi.nodes.addNode('-my-', {
'name': 'process-services',
'relativePath': 'Build-screenshot/Screenshot-e2e-' + buildNumber,
'nodeType': 'cm:folder'
}, {}, {
'overwrite': true
});
for (const fileName of files) {
let pathFile = path.join(__dirname, '../../e2e-output/screenshots', fileName);
let file: any = fs.createReadStream(pathFile);
await alfrescoJsApi.upload.uploadFile(
file,
'',
folder.entry.id,
null,
{
'name': file.name,
'nodeType': 'cm:content'
}
);
}
}
}
done();
});
it('screenshot need it', () => {
expect(true).toEqual(true);
});
});

View File

@@ -126,7 +126,7 @@
"http-proxy-middleware": "^0.19.0",
"jasmine-ajax": "3.2.0",
"jasmine-core": "~2.8.0",
"jasmine-reporters": "^2.3.1",
"jasmine-reporters": "^2.3.2",
"jasmine-spec-reporter": "~4.2.1",
"jasmine2-protractor-utils": "1.1.3",
"js-yaml": "^3.12.0",
@@ -153,6 +153,7 @@
"ng-packagr": "4.0.1",
"node-sass": "4.9.2",
"protractor": "^5.4.0",
"protractor-html-reporter-2": "^1.0.4",
"raw-loader": "0.5.1",
"remap-istanbul": "^0.11.1",
"remark": "^9.0.0",

View File

@@ -4,8 +4,14 @@
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');
const fs = require('fs');
const projectRoot = path.resolve(__dirname);
const width = 1366;
@@ -44,8 +50,6 @@ exports.config = {
capabilities: {
browserName: 'chrome',
shardTestFiles: true,
maxInstances: 1,
chromeOptions: {
prefs: {
'credentials_enable_service': false,
@@ -131,6 +135,117 @@ exports.config = {
},
onComplete: async function () {
let buildNumber = process.env.TRAVIS_BUILD_NUMBER;
let saveScreenshot = process.env.SAVE_SCREENSHOT;
let alfrescoJsApi = new AlfrescoApi({
provider: 'ECM',
hostEcm: TestConfig.adf.url
});
alfrescoJsApi.login(TestConfig.adf.adminEmail, TestConfig.adf.adminPassword);
if (saveScreenshot === 'true') {
if (!buildNumber) {
buildNumber = Date.now();
}
let files = fs.readdirSync(path.join(__dirname, './e2e-output/screenshots'));
if (files && files.length > 0) {
try {
folder = await alfrescoJsApi.nodes.addNode('-my-', {
'name': 'screenshot',
'relativePath': `Builds/${buildNumber}`,
'nodeType': 'cm:folder'
}, {}, {
'overwrite': true
});
} catch (error) {
console.log('Folder screenshot already present');
folder = await alfrescoJsApi.nodes.getNode('-my-', {
'relativePath': `Builds/${buildNumber}/screenshot`,
'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'
}
);
}
}
}
testConfig = {
reportTitle: 'Protractor Test Execution Report',
outputPath: `${projectRoot}/e2e-output/junit-report`,
outputFilename: 'ProtractorTestReport',
screenshotPath: '`${projectRoot}/e2e-output/screenshots/`',
screenshotsOnlyOnFailure: true
};
new htmlReporter().from(`${projectRoot}/e2e-output/junit-report/results.xml`, testConfig);
let pathFile = path.join(__dirname, './e2e-output/junit-report', 'ProtractorTestReport.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) {
console.log('Folder report already present' + 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'
}
);
} catch (error) {
console.log('error' + error);
}
},
afterLaunch() {
return retry.afterLaunch(3);
}