From 80e4beb1a57a4b7a5954c599990c81881bb4c55e Mon Sep 17 00:00:00 2001 From: DudaGod Date: Fri, 20 Jul 2018 14:29:56 +0300 Subject: [PATCH 1/2] fix: display all info about test result --- lib/report-builder-factory/report-builder.js | 14 +++-- lib/static/components/section/body/index.js | 10 +++- lib/test-adapter/gemini-test-adapter.js | 4 ++ lib/test-adapter/hermione-test-adapter.js | 4 ++ .../report-builder-factory/report-builder.js | 8 +-- test/lib/static/components/section/body.js | 55 ++++++++++++++++--- 6 files changed, 78 insertions(+), 17 deletions(-) diff --git a/lib/report-builder-factory/report-builder.js b/lib/report-builder-factory/report-builder.js index 11151003f..794860478 100644 --- a/lib/report-builder-factory/report-builder.js +++ b/lib/report-builder-factory/report-builder.js @@ -104,13 +104,15 @@ module.exports = class ReportBuilder { } _createTestResult(result, props) { - const {browserId, suite, sessionId, description, imagesInfo} = result; + const {browserId, suite, sessionId, description, imagesInfo, screenshot, multipleTabs} = result; const {baseHost} = this._pluginConfig; const suiteUrl = suite.getUrl({browserId, baseHost}); - const metaInfo = _.merge(result.meta, {url: suite.fullUrl, file: suite.file, sessionId}); - return Object.assign({suiteUrl, name: browserId, metaInfo, description, imagesInfo}, props); + return Object.assign({ + suiteUrl, name: browserId, metaInfo, description, imagesInfo, + screenshot: Boolean(screenshot), multipleTabs + }, props); } _addTestResult(formattedResult, props) { @@ -152,7 +154,11 @@ module.exports = class ReportBuilder { const {imagesInfo} = stateInBrowser.result; stateInBrowser.result = extendTestWithImagePaths(testResult, formattedResult, imagesInfo); - stateInBrowser.result.status = hasFails(stateInBrowser) ? FAIL : SUCCESS; + + if (!hasFails(stateInBrowser)) { + stateInBrowser.result.status = SUCCESS; + } + setStatusForBranch(this._tree, node.suitePath, testResult.status); return formattedResult; diff --git a/lib/static/components/section/body/index.js b/lib/static/components/section/body/index.js index e6f34732b..04d6f07a4 100644 --- a/lib/static/components/section/body/index.js +++ b/lib/static/components/section/body/index.js @@ -12,7 +12,7 @@ import State from '../../state'; import MetaInfo from './meta-info'; import Description from './description'; import * as actions from '../../../modules/actions'; -import {isSuccessStatus} from '../../../../common-utils'; +import {isSuccessStatus, isErroredStatus} from '../../../../common-utils'; class Body extends Component { static propTypes = { @@ -84,13 +84,19 @@ class Body extends Component { return isSuccessStatus(activeResult.status) ? null : this._drawTab(activeResult); } - return activeResult.imagesInfo.map((imageInfo, idx) => { + const tabs = activeResult.imagesInfo.map((imageInfo, idx) => { const {stateName} = imageInfo; const reason = imageInfo.reason || activeResult.reason; const state = Object.assign({image: true, reason}, imageInfo); return this._drawTab(state, stateName || idx); }); + + const {multipleTabs, status, screenshot} = activeResult; + + return multipleTabs && isErroredStatus(status) && !screenshot + ? tabs.concat(this._drawTab(activeResult)) + : tabs; } _drawTab(state, key = '') { diff --git a/lib/test-adapter/gemini-test-adapter.js b/lib/test-adapter/gemini-test-adapter.js index 5962f3f5e..99834620f 100644 --- a/lib/test-adapter/gemini-test-adapter.js +++ b/lib/test-adapter/gemini-test-adapter.js @@ -76,4 +76,8 @@ module.exports = class GeminiTestResultAdapter extends TestAdapter { return {name, suitePath, browserId}; } + + get multipleTabs() { + return false; + } }; diff --git a/lib/test-adapter/hermione-test-adapter.js b/lib/test-adapter/hermione-test-adapter.js index eb552e245..753a045dc 100644 --- a/lib/test-adapter/hermione-test-adapter.js +++ b/lib/test-adapter/hermione-test-adapter.js @@ -132,4 +132,8 @@ module.exports = class HermioneTestResultAdapter extends TestAdapter { return {name, suitePath, browserId}; } + + get multipleTabs() { + return true; + } }; diff --git a/test/lib/report-builder-factory/report-builder.js b/test/lib/report-builder-factory/report-builder.js index a8c5a23b8..15e1169c5 100644 --- a/test/lib/report-builder-factory/report-builder.js +++ b/test/lib/report-builder-factory/report-builder.js @@ -263,10 +263,10 @@ describe('ReportBuilder', () => { describe('should not rewrite suite status to "success" if image comparison is successful, but test', () => { [ - {status: 'failed', methodName: 'addFail'}, - {status: 'errored', methodName: 'addError'} + {status: FAIL, methodName: 'addFail'}, + {status: ERROR, methodName: 'addError'} ].forEach(({status, methodName}) => { - it(`${status}`, () => { + it(`${status}ed`, () => { const reportBuilder = mkReportBuilder_(); const test = stubTest_({ @@ -278,7 +278,7 @@ describe('ReportBuilder', () => { const suiteResult = getSuiteResult_(reportBuilder); - assert.equal(suiteResult.status, FAIL); + assert.equal(suiteResult.status, status); }); }); }); diff --git a/test/lib/static/components/section/body.js b/test/lib/static/components/section/body.js index a731df5bf..1462a1269 100644 --- a/test/lib/static/components/section/body.js +++ b/test/lib/static/components/section/body.js @@ -1,7 +1,7 @@ import React from 'react'; import proxyquire from 'proxyquire'; import {mkConnectedComponent, mkTestResult_} from '../utils'; -import {ERROR} from 'lib/constants/test-statuses'; +import {SUCCESS, FAIL, ERROR} from 'lib/constants/test-statuses'; describe('', () => { const sandbox = sinon.sandbox.create(); @@ -70,20 +70,61 @@ describe('', () => { assert.lengthOf(component.find('.tab'), 2); }); - it('should render state even if state images does not exist and test does not pass', () => { - const testResult = mkTestResult_(); + it('should not render state if state images does not exist and test passed succesfully', () => { + const testResult = mkTestResult_({status: SUCCESS}); const component = mkConnectedComponent(); - assert.lengthOf(component.find('.tab'), 1); + assert.lengthOf(component.find('.tab'), 0); }); - it('should not render state if state images does not exist and test passed succesfully', () => { - const testResult = mkTestResult_({status: 'success'}); + it('should render additional tab if test errored without screenshot', () => { + const imagesInfo = [{stateName: 'plain1', status: SUCCESS, expectedPath: 'some/path'}]; + const testResult = mkTestResult_({status: ERROR, multipleTabs: true, reason: {}, imagesInfo}); const component = mkConnectedComponent(); - assert.lengthOf(component.find('.tab'), 0); + assert.lengthOf(component.find('.tab'), 2); + }); + + describe('errored additional tab', () => { + it('should render if test errored without screenshot and tool can use multi tabs', () => { + const imagesInfo = [{stateName: 'plain1', status: SUCCESS, expectedPath: 'some/path'}]; + const testResult = mkTestResult_({status: ERROR, multipleTabs: true, reason: {}, imagesInfo}); + + const component = mkConnectedComponent(); + + assert.lengthOf(component.find('.tab'), 2); + }); + + it('should not render if tool does not use multi tabs', () => { + const imagesInfo = [{stateName: 'plain1', status: SUCCESS, expectedPath: 'some/path'}]; + const testResult = mkTestResult_({status: ERROR, multipleTabs: false, reason: {}, screenshot: 'some-screen', imagesInfo}); + + const component = mkConnectedComponent(); + + assert.lengthOf(component.find('.tab'), 1); + }); + + it('should not render if test errored with screenshot', () => { + const imagesInfo = [{stateName: 'plain1', status: SUCCESS, expectedPath: 'some/path'}]; + const testResult = mkTestResult_({status: ERROR, multipleTabs: true, reason: {}, screenshot: 'some-screen', imagesInfo}); + + const component = mkConnectedComponent(); + + assert.lengthOf(component.find('.tab'), 1); + }); + + [SUCCESS, FAIL].forEach((status) => { + it(`should not render if test ${status}ed`, () => { + const imagesInfo = [{stateName: 'plain1', status: SUCCESS, expectedPath: 'some/path'}]; + const testResult = mkTestResult_({status, multipleTabs: true, reason: {}, imagesInfo}); + + const component = mkConnectedComponent(); + + assert.lengthOf(component.find('.tab'), 1); + }); + }); }); describe('"Retry" button', () => { From eeddd077d4817801440abd9d29afa1b88b8d7864 Mon Sep 17 00:00:00 2001 From: DudaGod Date: Tue, 24 Jul 2018 00:08:54 +0300 Subject: [PATCH 2/2] chore(release): 2.20.5 --- CHANGELOG.md | 10 ++++++++++ package-lock.json | 2 +- package.json | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6256e368..7311200f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,16 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +## [2.20.5](https://github.com/gemini-testing/html-reporter/compare/v2.20.4...v2.20.5) (2018-07-23) + + +### Bug Fixes + +* display all info about test result ([80e4beb](https://github.com/gemini-testing/html-reporter/commit/80e4beb)) + + + ## [2.20.4](https://github.com/gemini-testing/html-reporter/compare/v2.20.3...v2.20.4) (2018-07-18) diff --git a/package-lock.json b/package-lock.json index f4910dac1..9c7bbeaa9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "html-reporter", - "version": "2.20.4", + "version": "2.20.5", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 3b9f8e48c..f8b5b9a0e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "html-reporter", - "version": "2.20.4", + "version": "2.20.5", "description": "Plugin for gemini and hermione which is intended to aggregate the results of tests running into html report", "scripts": { "lint": "eslint .",