diff --git a/CHANGELOG.md b/CHANGELOG.md index e93d259af..94ca1e4b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,18 @@ 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.1](https://github.com/gemini-testing/html-reporter/compare/v2.20.0...v2.20.1) (2018-07-04) + + +### Bug Fixes + +* display error state if state images does not exist ([1240276](https://github.com/gemini-testing/html-reporter/commit/1240276)) +* **hermione gui:** pass grep to readTests ([13251ab](https://github.com/gemini-testing/html-reporter/commit/13251ab)) +* **scaleImages:** diff images can be higher than actual and expected ([51bf7e0](https://github.com/gemini-testing/html-reporter/commit/51bf7e0)) + + + # [2.20.0](https://github.com/gemini-testing/html-reporter/compare/v2.19.2...v2.20.0) (2018-06-26) diff --git a/lib/gui/tool-runner-factory/base-tool-runner.js b/lib/gui/tool-runner-factory/base-tool-runner.js index ee6373551..4e7d0199d 100644 --- a/lib/gui/tool-runner-factory/base-tool-runner.js +++ b/lib/gui/tool-runner-factory/base-tool-runner.js @@ -22,6 +22,7 @@ module.exports = class ToolRunner { this._testFiles = [].concat(paths); this._tool = tool; this._tree = null; + this._collection = null; this._globalOpts = globalOpts; this._guiOpts = guiOpts; @@ -41,7 +42,18 @@ module.exports = class ToolRunner { initialize() { return this._readTests() - .then(() => this._subscribeOnEvents()); + .then((collection) => { + this._collection = collection; + + this._handleRunnableCollection(); + this._subscribeOnEvents(); + }); + } + + _readTests() { + const {grep, set: sets, browser: browsers} = this._globalOpts; + + return this._tool.readTests(this._testFiles, {grep, sets, browsers}); } finalize() { @@ -81,13 +93,11 @@ module.exports = class ToolRunner { }); } - _loadReuseData() { - try { - return utils.require(path.resolve(this._reportPath, 'data')); - } catch (e) { - utils.logger.warn(chalk.yellow(`Nothing to reuse in ${this._reportPath}`)); - return {}; - } + _fillTestsTree() { + const {autoRun} = this._guiOpts; + + this._tree = Object.assign(this._reportBuilder.getResult(), {gui: true, autoRun}); + this._tree.suites = this._applyReuseData(this._tree.suites); } _applyReuseData(testSuites) { @@ -103,6 +113,15 @@ module.exports = class ToolRunner { return testSuites.map((suite) => applyReuse(reuseData)(suite)); } + + _loadReuseData() { + try { + return utils.require(path.resolve(this._reportPath, 'data')); + } catch (e) { + utils.logger.warn(chalk.yellow(`Nothing to reuse in ${this._reportPath}`)); + return {}; + } + } }; function applyReuse(reuseData) { diff --git a/lib/gui/tool-runner-factory/gemini/index.js b/lib/gui/tool-runner-factory/gemini/index.js index d3037df2f..9b4279e2c 100644 --- a/lib/gui/tool-runner-factory/gemini/index.js +++ b/lib/gui/tool-runner-factory/gemini/index.js @@ -11,7 +11,6 @@ module.exports = class GeminiRunner extends BaseToolRunner { constructor(paths, tool, configs) { super(paths, tool, configs); - this._collection = null; this._collectionStates = null; } @@ -22,36 +21,29 @@ module.exports = class GeminiRunner extends BaseToolRunner { .run((collection) => this._tool.test(collection, {reporters: ['vflat']})); } - _readTests() { - const {grep, set, browser} = this._globalOpts; - const {autoRun} = this._guiOpts; + _handleRunnableCollection() { + const {browser: browsers} = this._globalOpts; + const suites = this._collection.topLevelSuites(); - return this._tool.readTests(this._testFiles, {grep, sets: set}) - .then((collection) => { - this._collection = collection; - const suites = this._collection.topLevelSuites(); - - if (browser) { - suites.forEach((suite) => { - suite.browsers = _.intersection(suite.browsers, browser); - }); - } + if (browsers) { + suites.forEach((suite) => { + suite.browsers = _.intersection(suite.browsers, browsers); + }); + } - this._collectionStates = getAllStates(this._collection.clone().allSuites()); + this._collectionStates = getAllStates(this._collection.clone().allSuites()); - this._collectionStates.forEach((state) => { - if (state.state.shouldSkip(state.browserId)) { - return this._reportBuilder.addSkipped(state); - } + this._collectionStates.forEach((state) => { + if (state.state.shouldSkip(state.browserId)) { + return this._reportBuilder.addSkipped(state); + } - const referencePath = this._tool.getScreenshotPath(state.suite, state.state.name, state.browserId); - state.referencePath = path.relative(process.cwd(), referencePath); - return this._reportBuilder.addIdle(state); - }); + const referencePath = this._tool.getScreenshotPath(state.suite, state.state.name, state.browserId); + state.referencePath = path.relative(process.cwd(), referencePath); + return this._reportBuilder.addIdle(state); + }); - this._tree = Object.assign(this._reportBuilder.getResult(), {gui: true, autoRun}); - this._tree.suites = this._applyReuseData(this._tree.suites); - }); + this._fillTestsTree(); } _subscribeOnEvents() { diff --git a/lib/gui/tool-runner-factory/hermione/index.js b/lib/gui/tool-runner-factory/hermione/index.js index 18981742e..9fac13844 100644 --- a/lib/gui/tool-runner-factory/hermione/index.js +++ b/lib/gui/tool-runner-factory/hermione/index.js @@ -11,7 +11,6 @@ module.exports = class HermioneRunner extends BaseToolRunner { constructor(paths, tool, configs) { super(paths, tool, configs); - this._collection = null; this._tests = {}; } @@ -23,26 +22,17 @@ module.exports = class HermioneRunner extends BaseToolRunner { .run((collection) => this._tool.run(collection, {grep, sets, browsers})); } - _readTests() { - const {browser: browsers} = this._globalOpts; - const {autoRun} = this._guiOpts; + _handleRunnableCollection() { + this._collection.eachTest((test, browserId) => { + const testId = formatId(test.id(), browserId); + this._tests[testId] = _.extend(test, {browserId}); - return this._tool.readTests(this._testFiles, {browsers}) - .then((collection) => { - this._collection = collection; - - this._collection.eachTest((test, browserId) => { - const testId = formatId(test.id(), browserId); - this._tests[testId] = _.extend(test, {browserId}); - - test.pending - ? this._reportBuilder.addSkipped(test) - : this._reportBuilder.addIdle(test); - }); + test.pending + ? this._reportBuilder.addSkipped(test) + : this._reportBuilder.addIdle(test); + }); - this._tree = Object.assign(this._reportBuilder.getResult(), {gui: true, autoRun}); - this._tree.suites = this._applyReuseData(this._tree.suites); - }); + this._fillTestsTree(); } _subscribeOnEvents() { diff --git a/lib/static/components/section/body/index.js b/lib/static/components/section/body/index.js index 65865f59d..e6f34732b 100644 --- a/lib/static/components/section/body/index.js +++ b/lib/static/components/section/body/index.js @@ -1,5 +1,6 @@ 'use strict'; +import {isEmpty} from 'lodash'; import React, {Component} from 'react'; import {connect} from 'react-redux'; import {bindActionCreators} from 'redux'; @@ -11,6 +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'; class Body extends Component { static propTypes = { @@ -78,21 +80,29 @@ class Body extends Component { _getTabs() { const activeResult = this._getActiveResult(); + if (isEmpty(activeResult.imagesInfo)) { + return isSuccessStatus(activeResult.status) ? null : this._drawTab(activeResult); + } + return activeResult.imagesInfo.map((imageInfo, idx) => { const {stateName} = imageInfo; const reason = imageInfo.reason || activeResult.reason; const state = Object.assign({image: true, reason}, imageInfo); - return ( -
-
- -
-
- ); + return this._drawTab(state, stateName || idx); }); } + _drawTab(state, key = '') { + return ( +
+
+ +
+
+ ); + } + render() { const {retries} = this.props; const activeResult = this._getActiveResult(); diff --git a/lib/static/components/state/index.js b/lib/static/components/state/index.js index 3b2a8ca24..2b10093c1 100644 --- a/lib/static/components/state/index.js +++ b/lib/static/components/state/index.js @@ -63,7 +63,7 @@ class State extends Component { elem = ; } else if (isFailStatus(status)) { elem = reason - ? + ? : ; } diff --git a/lib/static/components/state/state-error.js b/lib/static/components/state/state-error.js index baecff8b4..019cdb2a1 100644 --- a/lib/static/components/state/state-error.js +++ b/lib/static/components/state/state-error.js @@ -7,9 +7,9 @@ import Screenshot from './screenshot'; export default class StateError extends Component { static propTypes = { - actual: PropTypes.string.isRequired, image: PropTypes.bool.isRequired, - reason: PropTypes.object.isRequired + reason: PropTypes.object.isRequired, + actual: PropTypes.string }; render() { diff --git a/lib/static/styles.css b/lib/static/styles.css index aa8d26e45..2f8557dfe 100644 --- a/lib/static/styles.css +++ b/lib/static/styles.css @@ -134,10 +134,6 @@ box-sizing: border-box; } -.image-box__image:last-child { - padding-right: 0; -} - .image-box__screenshot { max-width: 100%; height: auto; diff --git a/package-lock.json b/package-lock.json index 0e665ac5e..a93e82a2d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "html-reporter", - "version": "2.20.0", + "version": "2.20.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 2b56854f7..56945eb87 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "html-reporter", - "version": "2.20.0", + "version": "2.20.1", "description": "Plugin for gemini and hermione which is intended to aggregate the results of tests running into html report", "scripts": { "lint": "eslint .", diff --git a/test/lib/gui/tool-runner-factory/base-tool-runner.js b/test/lib/gui/tool-runner-factory/base-tool-runner.js index ff635c1ff..68ba034f9 100644 --- a/test/lib/gui/tool-runner-factory/base-tool-runner.js +++ b/test/lib/gui/tool-runner-factory/base-tool-runner.js @@ -114,6 +114,31 @@ describe('lib/gui/tool-runner-factory/base-tool-runner', () => { }); }); + describe(`initialize ${name}`, () => { + it('should pass paths to "readTests" method', () => { + const gui = initGuiReporter({paths: ['foo', 'bar']}); + + return gui.initialize() + .then(() => assert.calledOnceWith(tool.readTests, ['foo', 'bar'])); + }); + + it('should pass "grep", "sets" and "browsers" options to "readTests" method', () => { + const grep = 'foo'; + const set = 'bar'; + const browser = 'yabro'; + const gui = initGuiReporter({ + configs: { + program: {name: () => 'tool', grep, set, browser} + } + }); + + return gui.initialize() + .then(() => { + assert.calledOnceWith(tool.readTests, sinon.match.any, {grep, sets: set, browsers: browser}); + }); + }); + }); + describe(`finalize ${name}`, () => { it('should save data file', () => { const gui = initGuiReporter(); diff --git a/test/lib/static/components/section/body.js b/test/lib/static/components/section/body.js index 30404e276..a731df5bf 100644 --- a/test/lib/static/components/section/body.js +++ b/test/lib/static/components/section/body.js @@ -70,6 +70,22 @@ 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_(); + + const component = mkConnectedComponent(); + + assert.lengthOf(component.find('.tab'), 1); + }); + + 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'), 0); + }); + describe('"Retry" button', () => { it('should be disabled while tests running', () => { const testResult = mkTestResult_();