html-reporter
Advanced tools
Comparing version 2.18.1 to 2.19.0
@@ -5,2 +5,12 @@ # Change Log | ||
<a name="2.19.0"></a> | ||
# [2.19.0](https://github.com/gemini-testing/html-reporter/compare/v2.18.1...v2.19.0) (2018-06-22) | ||
### Features | ||
* **hermione:** show all assertView images ([9f88f90](https://github.com/gemini-testing/html-reporter/commit/9f88f90)) | ||
<a name="2.18.1"></a> | ||
@@ -7,0 +17,0 @@ ## [2.18.1](https://github.com/gemini-testing/html-reporter/compare/v2.18.0...v2.18.1) (2018-06-09) |
@@ -40,4 +40,5 @@ 'use strict'; | ||
const {path: reportPath} = pluginConfig; | ||
function handleErrorEvent(result) { | ||
var src = result.imagePath || result.currentPath; | ||
var src = result.getImagePath() || result.currentPath; | ||
@@ -55,8 +56,8 @@ return src && utils.copyImageAsync(src, utils.getCurrentAbsolutePath(result, reportPath)); | ||
gemini.on(gemini.events.RETRY, (testResult) => { | ||
const wrapped = reportBuilder.format(testResult); | ||
const formattedResult = reportBuilder.format(testResult); | ||
queue = queue.then(() => { | ||
return wrapped.hasDiff() | ||
? saveTestImages(wrapped, reportPath) | ||
: handleErrorEvent(wrapped); | ||
return formattedResult.hasDiff() | ||
? saveTestImages(formattedResult, reportPath) | ||
: handleErrorEvent(formattedResult); | ||
}); | ||
@@ -63,0 +64,0 @@ }); |
@@ -5,3 +5,2 @@ 'use strict'; | ||
const PluginAdapter = require('./lib/plugin-adapter'); | ||
const utils = require('./lib/server-utils'); | ||
const {saveTestImages, saveBase64Screenshot} = require('./lib/reporter-helpers'); | ||
@@ -35,8 +34,7 @@ | ||
function failHandler(testResult) { | ||
const wrapped = reportBuilder.format(testResult); | ||
const {assertViewState} = wrapped; | ||
const formattedResult = reportBuilder.format(testResult); | ||
return wrapped.hasDiff() | ||
? reportBuilder.addFail(testResult, {assertViewState}) | ||
: reportBuilder.addError(testResult, {assertViewState}); | ||
return formattedResult.hasDiff() | ||
? reportBuilder.addFail(testResult) | ||
: reportBuilder.addError(testResult); | ||
} | ||
@@ -46,15 +44,13 @@ } | ||
function prepareImages(hermione, pluginConfig, reportBuilder) { | ||
function handleErrorEvent(testResult) { | ||
const {assertViewState} = testResult; | ||
const src = testResult.currentPath; | ||
const {path: reportPath} = pluginConfig; | ||
return src | ||
? utils.copyImageAsync(src, utils.getCurrentAbsolutePath(testResult, pluginConfig.path, assertViewState)) | ||
: saveBase64Screenshot(testResult, pluginConfig.path); | ||
} | ||
function failHandler(testResult) { | ||
const wrapped = reportBuilder.format(testResult); | ||
const formattedResult = reportBuilder.format(testResult); | ||
const actions = [saveTestImages(formattedResult, reportPath)]; | ||
return wrapped.hasDiff() ? saveTestImages(wrapped, pluginConfig.path) : handleErrorEvent(wrapped); | ||
if (formattedResult.screenshot) { | ||
actions.push(saveBase64Screenshot(formattedResult, reportPath)); | ||
} | ||
return Promise.all(actions); | ||
} | ||
@@ -66,3 +62,3 @@ | ||
hermione.on(hermione.events.TEST_PASS, (testResult) => { | ||
queue = queue.then(() => saveTestImages(reportBuilder.format(testResult), pluginConfig.path)); | ||
queue = queue.then(() => saveTestImages(reportBuilder.format(testResult), reportPath)); | ||
}); | ||
@@ -69,0 +65,0 @@ |
@@ -64,11 +64,19 @@ 'use strict'; | ||
const updateResult = this._prepareUpdateResult(test); | ||
const formattedResult = reportBuilder.addUpdated(updateResult); | ||
const formattedResult = reportBuilder.format(updateResult); | ||
Object.assign(formattedResult, {actualPath: test.actualPath}); | ||
return reporterHelper.updateReferenceImage(formattedResult, this._reportPath) | ||
.then(() => { | ||
this._tool.emit(this._tool.events.UPDATE_RESULT, updateResult); | ||
return Promise.map(updateResult.imagesInfo, (imageInfo) => { | ||
const {stateName} = imageInfo; | ||
return findTestResult(reportBuilder.getSuites(), formattedResult.prepareTestResult()); | ||
}); | ||
return reporterHelper.updateReferenceImage(formattedResult, this._reportPath, stateName) | ||
.then(() => { | ||
this._tool.emit( | ||
this._tool.events.UPDATE_RESULT, | ||
_.extend(updateResult, {imagePath: imageInfo.imagePath}) | ||
); | ||
}); | ||
}).then(() => { | ||
reportBuilder.addUpdated(updateResult); | ||
return findTestResult(reportBuilder.getSuites(), formattedResult.prepareTestResult()); | ||
}); | ||
}); | ||
@@ -75,0 +83,0 @@ } |
@@ -48,3 +48,4 @@ 'use strict'; | ||
const referencePath = this._tool.getScreenshotPath(state.suite, state.state.name, state.browserId); | ||
return this._reportBuilder.addIdle(state, path.relative(process.cwd(), referencePath)); | ||
state.referencePath = path.relative(process.cwd(), referencePath); | ||
return this._reportBuilder.addIdle(state); | ||
}); | ||
@@ -66,2 +67,3 @@ | ||
const {metaInfo: {sessionId, url: fullUrl}, attempt, actualPath} = test; | ||
const imagesInfo = test.imagesInfo.map((imageInfo) => _.set(imageInfo, 'imagePath', imagePath)); | ||
@@ -74,3 +76,3 @@ const testResult = { | ||
return _.merge(testResult, {imagePath, sessionId, attempt, actualPath, suite: {fullUrl}, updated: true}); | ||
return _.merge(testResult, {imagePath, sessionId, attempt, imagesInfo, actualPath, suite: {fullUrl}, updated: true}); | ||
} | ||
@@ -77,0 +79,0 @@ }; |
@@ -32,9 +32,9 @@ 'use strict'; | ||
gemini.on(gemini.events.TEST_RESULT, (data) => { | ||
const result = data.equal | ||
const formattedResult = data.equal | ||
? reportBuilder.addSuccess(data) | ||
: reportBuilder.addFail(data); | ||
const testResult = findTestResult(reportBuilder.getSuites(), result.prepareTestResult()); | ||
const testResult = findTestResult(reportBuilder.getSuites(), formattedResult.prepareTestResult()); | ||
saveTestImages(result, reportPath) | ||
saveTestImages(formattedResult, reportPath) | ||
.then(() => client.emit(clientEvents.TEST_RESULT, testResult)); | ||
@@ -44,6 +44,6 @@ }); | ||
gemini.on(gemini.events.ERROR, (error) => { | ||
const result = reportBuilder.addError(error); | ||
const testResult = findTestResult(reportBuilder.getSuites(), result.prepareTestResult()); | ||
const formattedResult = reportBuilder.addError(error); | ||
const testResult = findTestResult(reportBuilder.getSuites(), formattedResult.prepareTestResult()); | ||
saveTestCurrentImage(result, reportPath) | ||
saveTestCurrentImage(formattedResult, reportPath) | ||
.then(() => client.emit(gemini.events.ERROR, testResult)); | ||
@@ -53,9 +53,9 @@ }); | ||
gemini.on(gemini.events.RETRY, (data) => { | ||
const result = reportBuilder.addRetry(data); | ||
const formattedResult = reportBuilder.addRetry(data); | ||
const actionFn = result.hasDiff() | ||
const actionFn = formattedResult.hasDiff() | ||
? saveTestImages | ||
: saveTestCurrentImage; | ||
actionFn(result, reportPath); | ||
actionFn(formattedResult, reportPath); | ||
}); | ||
@@ -62,0 +62,0 @@ |
@@ -50,3 +50,3 @@ 'use strict'; | ||
_prepareUpdateResult(test) { | ||
const {suite, state, browserId, attempt, actualPath} = test; | ||
const {suite, state, browserId, attempt} = test; | ||
@@ -59,5 +59,10 @@ // https://github.com/mochajs/mocha/blob/v2.4.5/lib/runnable.js#L165 | ||
const {sessionId, url} = test.metaInfo; | ||
const imagePath = this._tool.config.browsers[browserId].getScreenshotPath(testResult, test.assertViewState); | ||
const imagesInfo = test.imagesInfo.map((imageInfo) => { | ||
const {stateName} = imageInfo; | ||
const imagePath = this._tool.config.browsers[browserId].getScreenshotPath(testResult, stateName); | ||
return _.merge({}, testResult, {imagePath, sessionId, attempt, actualPath, meta: {url}, updated: true}); | ||
return _.extend(imageInfo, {imagePath}); | ||
}); | ||
return _.merge({}, testResult, {imagesInfo, sessionId, attempt, meta: {url}, updated: true}); | ||
} | ||
@@ -64,0 +69,0 @@ }; |
@@ -7,7 +7,16 @@ 'use strict'; | ||
const {findTestResult} = require('../utils'); | ||
const { | ||
saveTestImages, saveTestCurrentImage, saveBase64Screenshot | ||
} = require('../../../reporter-helpers'); | ||
const {saveTestImages, saveBase64Screenshot} = require('../../../reporter-helpers'); | ||
module.exports = (hermione, reportBuilder, client, reportPath) => { | ||
function failHandler(testResult) { | ||
const formattedResult = reportBuilder.format(testResult); | ||
const actions = [saveTestImages(formattedResult, reportPath)]; | ||
if (formattedResult.screenshot) { | ||
actions.push(saveBase64Screenshot(formattedResult, reportPath)); | ||
} | ||
return Promise.all(actions); | ||
} | ||
hermione.on(hermione.events.SUITE_BEGIN, (suite) => { | ||
@@ -45,11 +54,9 @@ if (suite.pending) { | ||
const formattedResult = reportBuilder.format(data); | ||
const saveImageFn = getSaveImageFn(formattedResult); | ||
const {assertViewState} = formattedResult; | ||
const result = formattedResult.hasDiff() | ||
? reportBuilder.addFail(data, {assertViewState}) | ||
: reportBuilder.addError(data, {assertViewState}); | ||
formattedResult.hasDiff() | ||
? reportBuilder.addFail(data) | ||
: reportBuilder.addError(data); | ||
const testResult = findTestResult(reportBuilder.getSuites(), formattedResult.prepareTestResult()); | ||
saveImageFn(result, reportPath, assertViewState) | ||
failHandler(data) | ||
.then(() => client.emit(clientEvents.TEST_RESULT, testResult)); | ||
@@ -59,7 +66,5 @@ }); | ||
hermione.on(hermione.events.RETRY, (data) => { | ||
const result = reportBuilder.addRetry(data); | ||
const {assertViewState} = result; | ||
const saveImageFn = getSaveImageFn(result); | ||
reportBuilder.addRetry(data); | ||
saveImageFn(result, reportPath, assertViewState); | ||
failHandler(data); | ||
}); | ||
@@ -72,9 +77,1 @@ | ||
}; | ||
function getSaveImageFn(formattedResult) { | ||
if (formattedResult.hasDiff()) { | ||
return saveTestImages; | ||
} | ||
return formattedResult.assertViewState ? saveTestCurrentImage : saveBase64Screenshot; | ||
} |
@@ -8,4 +8,4 @@ 'use strict'; | ||
const {IDLE, RUNNING, SUCCESS, FAIL, ERROR, SKIPPED, UPDATED} = require('../constants/test-statuses'); | ||
const {getCurrentPath, getReferencePath, getDiffPath, logger} = require('../server-utils'); | ||
const {setStatusForBranch} = require('../static/modules/utils'); | ||
const {logger, getPathsFor} = require('../server-utils'); | ||
const {setStatusForBranch, hasFails} = require('../static/modules/utils'); | ||
@@ -31,7 +31,4 @@ const NO_STATE = 'NO_STATE'; | ||
addIdle(result, expectedPath = '') { | ||
return this._addTestResult(this.format(result), { | ||
status: IDLE, | ||
expectedPath | ||
}); | ||
addIdle(result) { | ||
return this._addTestResult(this.format(result), {status: IDLE}); | ||
} | ||
@@ -62,3 +59,10 @@ | ||
addUpdated(result) { | ||
return this._addSuccessResult(this.format(result), UPDATED); | ||
const formattedResult = this.format(result); | ||
formattedResult.imagesInfo = (result.imagesInfo || []).map((imageInfo) => { | ||
const {stateName} = imageInfo; | ||
return _.extend(imageInfo, getPathsFor(UPDATED, formattedResult, stateName)); | ||
}); | ||
return this._addSuccessResult(formattedResult, UPDATED); | ||
} | ||
@@ -70,20 +74,20 @@ | ||
addFail(result, props) { | ||
return this._addFailResult(this.format(result), props); | ||
addFail(result) { | ||
return this._addFailResult(this.format(result)); | ||
} | ||
_addFailResult(formattedResult, props = {}) { | ||
return this._addTestResult(formattedResult, _.extend({status: FAIL}, props)); | ||
_addFailResult(formattedResult) { | ||
return this._addTestResult(formattedResult, {status: FAIL}); | ||
} | ||
addError(result, props) { | ||
return this._addErrorResult(this.format(result), props); | ||
addError(result) { | ||
return this._addErrorResult(this.format(result)); | ||
} | ||
_addErrorResult(formattedResult, props = {}) { | ||
return this._addTestResult(formattedResult, _.extend({ | ||
_addErrorResult(formattedResult) { | ||
return this._addTestResult(formattedResult, { | ||
status: ERROR, | ||
image: !!formattedResult.imagePath || !!formattedResult.currentPath || !!formattedResult.screenshot, | ||
image: !!formattedResult.getImagesInfo(ERROR).length || !!formattedResult.currentPath || !!formattedResult.screenshot, | ||
reason: formattedResult.error | ||
}, props)); | ||
}); | ||
} | ||
@@ -108,3 +112,3 @@ | ||
_createTestResult(result, props) { | ||
const {browserId, suite, sessionId, description} = result; | ||
const {browserId, suite, sessionId, description, imagesInfo} = result; | ||
const {baseHost} = this._pluginConfig; | ||
@@ -115,3 +119,3 @@ const suiteUrl = suite.getUrl({browserId, baseHost}); | ||
return Object.assign({suiteUrl, name: browserId, metaInfo, description}, props); | ||
return Object.assign({suiteUrl, name: browserId, metaInfo, description, imagesInfo}, props); | ||
} | ||
@@ -130,4 +134,4 @@ | ||
formattedResult.attempt = testResult.attempt; | ||
const imagePaths = calcImagePaths(formattedResult, testResult.status); | ||
node.browsers.push({name: browserId, result: _.extend(testResult, imagePaths), retries: []}); | ||
extendTestWithImagePaths(testResult, formattedResult); | ||
node.browsers.push({name: browserId, result: testResult, retries: []}); | ||
setStatusForBranch(this._tree, node.suitePath, testResult.status); | ||
@@ -139,3 +143,3 @@ | ||
const stateInBrowser = node.browsers[existing]; | ||
const previousResult = stateInBrowser.result; | ||
const previousResult = _.cloneDeep(stateInBrowser.result); | ||
@@ -155,5 +159,6 @@ const statuses = [SKIPPED, RUNNING, IDLE]; | ||
formattedResult.attempt = testResult.attempt; | ||
const imagePaths = calcImagePaths(formattedResult, testResult.status); | ||
stateInBrowser.result = _.extend(testResult, imagePaths); | ||
const {imagesInfo} = stateInBrowser.result; | ||
stateInBrowser.result = extendTestWithImagePaths(testResult, formattedResult, imagesInfo); | ||
stateInBrowser.result.status = hasFails(stateInBrowser) ? FAIL : SUCCESS; | ||
setStatusForBranch(this._tree, node.suitePath, testResult.status); | ||
@@ -249,21 +254,18 @@ | ||
function calcImagePaths(formattedResult, status) { | ||
if (status === SUCCESS || status === UPDATED) { | ||
// TODO: remove after showing all hermione images for test | ||
const stateName = _.get(formattedResult, 'assertViewResults[0].stateName'); | ||
return {expectedPath: getReferencePath(formattedResult, stateName)}; | ||
} | ||
function extendTestWithImagePaths(test, formattedResult, oldImagesInfo = []) { | ||
test.imagesInfo = oldImagesInfo; | ||
const newImagesInfo = formattedResult.getImagesInfo(test.status); | ||
const stateName = _.get(formattedResult, 'assertViewState'); | ||
if (status === FAIL) { | ||
return { | ||
actualPath: getCurrentPath(formattedResult, stateName), | ||
expectedPath: getReferencePath(formattedResult, stateName), | ||
diffPath: getDiffPath(formattedResult, stateName) | ||
}; | ||
if (test.imagesInfo.length) { | ||
newImagesInfo.forEach((imageInfo) => { | ||
const {stateName} = imageInfo; | ||
const index = _.findIndex(test.imagesInfo, {stateName}); | ||
test.imagesInfo[index >= 0 ? index : _.findLastIndex(test.imagesInfo)] = imageInfo; | ||
}); | ||
return test; | ||
} | ||
if (status === ERROR) { | ||
return {actualPath: formattedResult.state ? getCurrentPath(formattedResult, stateName) : ''}; | ||
} | ||
return _.set(test, 'imagesInfo', newImagesInfo); | ||
} |
@@ -12,8 +12,10 @@ 'use strict'; | ||
const {stateName} = assertResult; | ||
const actions = [ | ||
utils.copyImageAsync( | ||
const actions = []; | ||
if (!(assertResult instanceof Error)) { | ||
actions.push(utils.copyImageAsync( | ||
assertResult.refImagePath, | ||
utils.getReferenceAbsolutePath(testResult, reportPath, stateName) | ||
) | ||
]; | ||
)); | ||
} | ||
@@ -26,2 +28,6 @@ if (testResult.isImageDiffError(assertResult)) { | ||
utils.getDiffAbsolutePath(testResult, reportPath, stateName) | ||
), | ||
utils.copyImageAsync( | ||
assertResult.refImagePath, | ||
utils.getReferenceAbsolutePath(testResult, reportPath, stateName) | ||
) | ||
@@ -31,2 +37,6 @@ ); | ||
if (testResult.isNoRefImageError(assertResult)) { | ||
actions.push(exports.saveTestCurrentImage(testResult, reportPath, stateName)); | ||
} | ||
return Promise.all(actions); | ||
@@ -67,3 +77,3 @@ }); | ||
} else { | ||
src = testResult.imagePath || testResult.currentPath || testResult.screenshot; | ||
src = testResult.getImagePath() || testResult.currentPath || testResult.screenshot; | ||
} | ||
@@ -76,10 +86,10 @@ | ||
exports.updateReferenceImage = (testResult, reportPath) => { | ||
exports.updateReferenceImage = (testResult, reportPath, stateName) => { | ||
const src = testResult.actualPath | ||
? path.resolve(reportPath, testResult.actualPath) | ||
: utils.getCurrentAbsolutePath(testResult, reportPath); | ||
: utils.getCurrentAbsolutePath(testResult, reportPath, stateName); | ||
return Promise.all([ | ||
utils.copyImageAsync(src, testResult.imagePath), | ||
utils.copyImageAsync(src, utils.getReferenceAbsolutePath(testResult, reportPath)) | ||
utils.copyImageAsync(src, testResult.getImagePath(stateName)), | ||
utils.copyImageAsync(src, utils.getReferenceAbsolutePath(testResult, reportPath, stateName)) | ||
]); | ||
@@ -86,0 +96,0 @@ }; |
@@ -7,2 +7,3 @@ 'use strict'; | ||
const fs = require('fs-extra'); | ||
const {SUCCESS, FAIL, ERROR, UPDATED} = require('./constants/test-statuses'); | ||
@@ -34,2 +35,3 @@ const getReferencePath = (testResult, stateName) => createPath('ref', testResult, stateName); | ||
* @param {StateResult} result | ||
* @param {String} stateName - имя стэйта для теста | ||
* @returns {String} | ||
@@ -79,2 +81,22 @@ */ | ||
function getPathsFor(status, formattedResult, stateName) { | ||
if (status === SUCCESS || status === UPDATED) { | ||
return {expectedPath: getReferencePath(formattedResult, stateName)}; | ||
} | ||
if (status === FAIL) { | ||
return { | ||
actualPath: getCurrentPath(formattedResult, stateName), | ||
expectedPath: getReferencePath(formattedResult, stateName), | ||
diffPath: getDiffPath(formattedResult, stateName) | ||
}; | ||
} | ||
if (status === ERROR) { | ||
return { | ||
actualPath: formattedResult.state ? getCurrentPath(formattedResult, stateName) : '' | ||
}; | ||
} | ||
return {}; | ||
} | ||
module.exports = { | ||
@@ -84,2 +106,3 @@ getReferencePath, | ||
getDiffPath, | ||
getPathsFor, | ||
@@ -86,0 +109,0 @@ getReferenceAbsolutePath, |
'use strict'; | ||
import React, {Component, Fragment} from 'react'; | ||
import {connect} from 'react-redux'; | ||
import PropTypes from 'prop-types'; | ||
import MetaInfo from './meta-info'; | ||
import classNames from 'classnames'; | ||
import StateError from './state-error'; | ||
import StateSuccess from './state-success'; | ||
import StateFail from './state-fail'; | ||
import Description from './description'; | ||
import ControlButton from '../controls/button'; | ||
import {isAcceptable} from '../../modules/utils'; | ||
import {isSuccessStatus, isFailStatus, isErroredStatus, isUpdatedStatus, isIdleStatus} from '../../../common-utils'; | ||
export default class State extends Component { | ||
class State extends Component { | ||
static propTypes = { | ||
state: PropTypes.shape({ | ||
suiteUrl: PropTypes.string.isRequired, | ||
metaInfo: PropTypes.object.isRequired, | ||
status: PropTypes.string, | ||
@@ -22,10 +22,37 @@ image: PropTypes.bool, | ||
actualPath: PropTypes.string, | ||
diffPath: PropTypes.string, | ||
description: PropTypes.string | ||
}) | ||
diffPath: PropTypes.string | ||
}), | ||
acceptHandler: PropTypes.func, | ||
gui: PropTypes.bool, | ||
scaleImages: PropTypes.bool | ||
} | ||
_getAcceptButton() { | ||
if (!this.props.gui) { | ||
return null; | ||
} | ||
const {state, state: {stateName}, acceptHandler} = this.props; | ||
const isAcceptDisabled = !isAcceptable(state); | ||
const acceptFn = () => acceptHandler(stateName); | ||
return ( | ||
<ControlButton | ||
label="✔ Accept" | ||
isSuiteControl={true} | ||
isDisabled={isAcceptDisabled} | ||
handler={acceptFn} | ||
/> | ||
); | ||
} | ||
_getStateTitle(stateName, status) { | ||
return stateName | ||
? (<div className={`state-title state-title_${status}`}>{stateName}</div>) | ||
: null; | ||
} | ||
render() { | ||
const {suiteUrl, metaInfo, status, reason, image, | ||
expectedPath, actualPath, diffPath, description} = this.props.state; | ||
const {status, reason, image, expectedPath, actualPath, diffPath, stateName} = this.props.state; | ||
@@ -44,7 +71,13 @@ let elem = null; | ||
const className = classNames( | ||
'image-box__container', | ||
{'image-box__container_scale': this.props.scaleImages} | ||
); | ||
return ( | ||
<Fragment> | ||
<MetaInfo metaInfo={metaInfo} suiteUrl={suiteUrl}/> | ||
{description && <Description content={description}/>} | ||
{elem} | ||
<hr/> | ||
{this._getStateTitle(stateName, status)} | ||
{this._getAcceptButton()} | ||
<div className={className}>{elem}</div> | ||
</Fragment> | ||
@@ -54,1 +87,3 @@ ); | ||
} | ||
export default connect(({gui, view: {scaleImages}}) => ({gui, scaleImages}))(State); |
@@ -6,3 +6,2 @@ 'use strict'; | ||
import PropTypes from 'prop-types'; | ||
import classNames from 'classnames'; | ||
import Screenshot from './screenshot'; | ||
@@ -15,4 +14,3 @@ | ||
diff: PropTypes.string.isRequired, | ||
showOnlyDiff: PropTypes.bool.isRequired, | ||
scaleImages: PropTypes.bool.isRequired | ||
showOnlyDiff: PropTypes.bool.isRequired | ||
} | ||
@@ -22,12 +20,8 @@ | ||
const {expected, actual, diff} = this.props; | ||
const className = classNames( | ||
'image-box__container', | ||
{'image-box__container_scale': this.props.scaleImages} | ||
); | ||
return ( | ||
<div className={className}> | ||
<Fragment> | ||
{this._drawExpectedAndActual(expected, actual)} | ||
{this._drawImageBox('Diff', diff)} | ||
</div> | ||
</Fragment> | ||
); | ||
@@ -59,7 +53,2 @@ } | ||
export default connect( | ||
({view}) => ({ | ||
showOnlyDiff: view.showOnlyDiff, | ||
scaleImages: view.scaleImages | ||
}) | ||
)(StateFail); | ||
export default connect(({view: {showOnlyDiff}}) => ({showOnlyDiff}))(StateFail); |
'use strict'; | ||
import axios from 'axios'; | ||
import {assign, filter, flatMap, set, cloneDeep} from 'lodash'; | ||
import {assign, filter, flatMap, set, cloneDeep, compact} from 'lodash'; | ||
import actionNames from './action-names'; | ||
import {QUEUED} from '../../constants/test-statuses'; | ||
import {QUEUED, UPDATED} from '../../constants/test-statuses'; | ||
import {isSuiteFailed, isAcceptable} from './utils'; | ||
@@ -62,3 +62,3 @@ | ||
try { | ||
const {data: updatedData} = await axios.post('/update-reference', formattedFails); | ||
const {data: updatedData} = await axios.post('/update-reference', compact(formattedFails)); | ||
dispatch({type: actionNames.UPDATE_RESULT, payload: updatedData}); | ||
@@ -71,4 +71,4 @@ } catch (e) { | ||
export const acceptTest = (suite, browserId, attempt) => { | ||
return acceptAll(assign({browserId}, suite, {acceptTestAttempt: attempt})); | ||
export const acceptTest = (suite, browserId, attempt, stateName) => { | ||
return acceptAll(assign({browserId, stateName}, suite, {acceptTestAttempt: attempt})); | ||
}; | ||
@@ -112,11 +112,23 @@ | ||
const {suitePath, name, acceptTestAttempt} = test; | ||
const prepareImages = (images, filterCond) => { | ||
return filter(images, filterCond) | ||
.filter(isAcceptable) | ||
.map(({actualPath, stateName}) => ({status: UPDATED, actualPath, stateName})); | ||
}; | ||
return flatMap(test.browsers, (browser) => { | ||
const {actualPath} = acceptTestAttempt >= 0 | ||
const browserResult = acceptTestAttempt >= 0 | ||
? browser.retries.concat(browser.result)[acceptTestAttempt] | ||
: browser.result; | ||
const {metaInfo, assertViewState, attempt} = browser.result; | ||
let imagesInfo; | ||
if (test.stateName) { | ||
imagesInfo = prepareImages(browserResult.imagesInfo, {stateName: test.stateName}); | ||
} else { | ||
imagesInfo = prepareImages(browserResult.imagesInfo, 'actualPath'); | ||
} | ||
return { | ||
const {metaInfo, attempt} = browserResult; | ||
return imagesInfo.length && { | ||
suite: {path: suitePath.slice(0, -1)}, | ||
@@ -126,5 +138,4 @@ state: {name}, | ||
metaInfo, | ||
assertViewState, | ||
attempt, | ||
actualPath | ||
imagesInfo, | ||
attempt | ||
}; | ||
@@ -131,0 +142,0 @@ }); |
@@ -9,5 +9,13 @@ 'use strict'; | ||
function hasFailedImages(result) { | ||
const {imagesInfo, status} = result; | ||
return imagesInfo.length | ||
? imagesInfo.some(({status}) => isErroredStatus(status) || isFailStatus(status)) | ||
: isErroredStatus(status) || isFailStatus(status); | ||
} | ||
function hasFails(node) { | ||
const {result} = node; | ||
const isFailed = result && (isErroredStatus(result.status) || isFailStatus(result.status)); | ||
const isFailed = result && hasFailedImages(result); | ||
@@ -14,0 +22,0 @@ return isFailed || walk(node, hasFails); |
@@ -7,2 +7,4 @@ 'use strict'; | ||
const GeminiSuiteAdapter = require('../suite-adapter/gemini-suite-adapter'); | ||
const {getPathsFor} = require('../server-utils'); | ||
const {IDLE} = require('../constants/test-statuses'); | ||
@@ -24,2 +26,12 @@ module.exports = class GeminiTestResultAdapter extends TestAdapter { | ||
getImagesInfo(status) { | ||
const reason = !_.isEmpty(this.error) && this.error; | ||
this.imagesInfo = status === IDLE | ||
? [{status, expectedPath: this._testResult.referencePath}] | ||
: [].concat(_.extend({status, reason}, getPathsFor(status, this))); | ||
return this.imagesInfo; | ||
} | ||
get error() { | ||
@@ -59,2 +71,6 @@ return _.pick(this._testResult, ['message', 'stack']); | ||
getImagePath() { | ||
return this._testResult.imagePath; | ||
} | ||
prepareTestResult() { | ||
@@ -61,0 +77,0 @@ const {state: {name}, suite, browserId} = this._testResult; |
@@ -7,2 +7,4 @@ 'use strict'; | ||
const {getSuitePath} = require('../plugin-utils').getHermioneUtils(); | ||
const {getPathsFor} = require('../server-utils'); | ||
const {SUCCESS, FAIL, ERROR} = require('../constants/test-statuses'); | ||
@@ -18,6 +20,2 @@ module.exports = class HermioneTestResultAdapter extends TestAdapter { | ||
saveDiffTo(...args) { | ||
return (this._firstAssertViewFail || this._testResult.err).saveDiffTo(...args); | ||
} | ||
hasDiff() { | ||
@@ -35,2 +33,45 @@ return this.assertViewResults.some((result) => this.isImageDiffError(result)); | ||
isNoRefImageError(assertResult) { | ||
return assertResult instanceof this._errors.NoRefImageError; | ||
} | ||
getImagesInfo() { | ||
if (this.imagesInfo) { | ||
return this.imagesInfo; | ||
} | ||
this.imagesInfo = this.assertViewResults.map((assertResult) => { | ||
let status, reason; | ||
if (!(assertResult instanceof Error)) { | ||
status = SUCCESS; | ||
} | ||
if (this.isImageDiffError(assertResult)) { | ||
status = FAIL; | ||
} | ||
if (this.isNoRefImageError(assertResult)) { | ||
status = ERROR; | ||
reason = _.pick(assertResult, ['message', 'stack']); | ||
} | ||
const {stateName, refImagePath} = assertResult; | ||
return _.extend({stateName, refImagePath, status, reason}, getPathsFor(status, this, stateName)); | ||
}); | ||
// common screenshot on test fail | ||
if (this.screenshot) { | ||
const errorImage = _.extend( | ||
{status: ERROR, reason: this.error}, | ||
getPathsFor(ERROR, this) | ||
); | ||
this.imagesInfo.push(errorImage); | ||
} | ||
return this.imagesInfo; | ||
} | ||
// hack which should be removed when html-reporter is able to show all assert view fails for one test | ||
@@ -42,3 +83,3 @@ get _firstAssertViewFail() { | ||
get error() { | ||
return _.pick(this._firstAssertViewFail || this._testResult.err, ['message', 'stack', 'stateName']); | ||
return _.pick(this._testResult.err, ['message', 'stack', 'stateName']); | ||
} | ||
@@ -70,14 +111,2 @@ | ||
get referencePath() { | ||
return this._firstAssertViewFail | ||
? _.get(this._firstAssertViewFail, 'refImagePath') | ||
: _.get(this._testResult, 'err.refImagePath'); | ||
} | ||
get currentPath() { | ||
return this._firstAssertViewFail | ||
? _.get(this._firstAssertViewFail, 'currentImagePath') | ||
: _.get(this._testResult, 'err.currentImagePath'); | ||
} | ||
get screenshot() { | ||
@@ -101,2 +130,6 @@ return _.get(this._testResult, 'err.screenshot'); | ||
getImagePath(stateName) { | ||
return (_.find(this.imagesInfo, {stateName}) || {}).imagePath; | ||
} | ||
prepareTestResult() { | ||
@@ -103,0 +136,0 @@ const {title: name, browserId} = this._testResult; |
@@ -24,5 +24,9 @@ 'use strict'; | ||
get imagePath() { | ||
return this._testResult.imagePath; | ||
get imagesInfo() { | ||
return this._testResult.imagesInfo; | ||
} | ||
set imagesInfo(imagesInfo) { | ||
this._testResult.imagesInfo = imagesInfo; | ||
} | ||
}; |
{ | ||
"name": "html-reporter", | ||
"version": "2.18.1", | ||
"version": "2.19.0", | ||
"description": "Plugin for gemini and hermione which is intended to aggregate the results of tests running into html report", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1063616
93
6632