From d482e7fb862600855d4f109efe94a8a37df24361 Mon Sep 17 00:00:00 2001 From: shadowusr Date: Wed, 20 Sep 2023 12:57:10 +0300 Subject: [PATCH] fix: fix incorrect behavior for diff and no ref errors --- lib/common-utils.ts | 8 ++++++-- lib/errors/index.ts | 3 ++- lib/image-handler.ts | 2 +- lib/static/components/retry-switcher/item.jsx | 4 ++-- lib/static/components/section/body/tabs.jsx | 1 + lib/static/components/state/state-error.jsx | 4 ++-- lib/test-adapter/playwright.ts | 2 +- .../hermione/failed-describe.hermione.js | 6 ++++++ .../hermione/screens/7357338/chrome/header.png | Bin 0 -> 176 bytes .../header-chromium-darwin.png | Bin 0 -> 3775 bytes 10 files changed, 21 insertions(+), 9 deletions(-) create mode 100644 test/func/fixtures/hermione/screens/7357338/chrome/header.png create mode 100644 test/func/fixtures/playwright/tests/failed-describe.spec.ts-snapshots/header-chromium-darwin.png diff --git a/lib/common-utils.ts b/lib/common-utils.ts index 07f9ecdf8..1cffb41ff 100644 --- a/lib/common-utils.ts +++ b/lib/common-utils.ts @@ -5,7 +5,7 @@ import axios, {AxiosRequestConfig} from 'axios'; import {SUCCESS, FAIL, ERROR, SKIPPED, UPDATED, IDLE, RUNNING, QUEUED, TestStatus} from './constants'; import {UNCHECKED, INDETERMINATE, CHECKED} from './constants/checked-statuses'; -import {AssertViewResult, ImageData, ImageBase64, ImageInfoFull, TestError} from './types'; +import {AssertViewResult, ImageData, ImageBase64, ImageInfoFull, TestError, ImageInfoError} from './types'; import {ErrorName, ImageDiffError, NoRefImageError} from './errors'; export const getShortMD5 = (str: string): string => { return crypto.createHash('md5').update(str, 'ascii').digest('hex').substr(0, 7); @@ -87,6 +87,10 @@ export const mkTestId = (fullTitle: string, browserId: string): string => { return fullTitle + '.' + browserId; }; +export const isAssertViewError = (error?: unknown): boolean => { + return (error as {name?: string})?.name === ErrorName.ASSERT_VIEW; +}; + export const isImageDiffError = (error?: unknown): error is ImageDiffError => { return (error as {name?: string})?.name === ErrorName.IMAGE_DIFF; }; @@ -102,7 +106,7 @@ export const hasNoRefImageErrors = ({assertViewResults = []}: {assertViewResults const hasFailedImages = (result: {imagesInfo?: ImageInfoFull[]}): boolean => { const {imagesInfo = []} = result; - return imagesInfo.some((imageInfo: ImageInfoFull) => isErroredStatus(imageInfo.status) || isFailStatus(imageInfo.status)); + return imagesInfo.some((imageInfo: ImageInfoFull) => !isAssertViewError((imageInfo as ImageInfoError).error) && (isErroredStatus(imageInfo.status) || isFailStatus(imageInfo.status))); }; export const hasResultFails = (testResult: {status: TestStatus, imagesInfo?: ImageInfoFull[]}): boolean => { diff --git a/lib/errors/index.ts b/lib/errors/index.ts index b1899863b..a3acaf709 100644 --- a/lib/errors/index.ts +++ b/lib/errors/index.ts @@ -4,7 +4,8 @@ import {ValueOf} from 'type-fest'; export const ErrorName = { IMAGE_DIFF: 'ImageDiffError', - NO_REF_IMAGE: 'NoRefImageError' + NO_REF_IMAGE: 'NoRefImageError', + ASSERT_VIEW: 'AssertViewError' } as const; export type ErrorName = ValueOf; export type ErrorNames = typeof ErrorName; diff --git a/lib/image-handler.ts b/lib/image-handler.ts index 6c6bb4b57..ac808ec08 100644 --- a/lib/image-handler.ts +++ b/lib/image-handler.ts @@ -132,7 +132,7 @@ export class ImageHandler extends EventEmitter2 implements ImagesInfoFormatter { status = FAIL; } else if (isNoRefImageError(assertResult)) { status = ERROR; - error = _.pick(assertResult, ['message', 'stack']); + error = _.pick(assertResult, ['message', 'name', 'stack']); } else { status = SUCCESS; } diff --git a/lib/static/components/retry-switcher/item.jsx b/lib/static/components/retry-switcher/item.jsx index 5818fa2c4..330b1ab7a 100644 --- a/lib/static/components/retry-switcher/item.jsx +++ b/lib/static/components/retry-switcher/item.jsx @@ -4,7 +4,7 @@ import classNames from 'classnames'; import {connect} from 'react-redux'; import {get} from 'lodash'; import {ERROR} from '../../../constants/test-statuses'; -import {isFailStatus, isImageDiffError, isNoRefImageError} from '../../../common-utils'; +import {isAssertViewError, isFailStatus, isImageDiffError, isNoRefImageError} from '../../../common-utils'; class RetrySwitcherItem extends Component { static propTypes = { @@ -50,5 +50,5 @@ export default connect( )(RetrySwitcherItem); function hasScreenAndAssertErrors(status, error) { - return isFailStatus(status) && error && !isNoRefImageError(error) && !isImageDiffError(error); + return isFailStatus(status) && error && !isNoRefImageError(error) && !isImageDiffError(error) && !isAssertViewError(error); } diff --git a/lib/static/components/section/body/tabs.jsx b/lib/static/components/section/body/tabs.jsx index 0c62b740e..b3a8e2593 100644 --- a/lib/static/components/section/body/tabs.jsx +++ b/lib/static/components/section/body/tabs.jsx @@ -42,6 +42,7 @@ export default class Tabs extends Component { ? null : this._drawTab({key: errorTabId}); } + console.log(result.imageIds); const tabs = result.imageIds.map((imageId) => this._drawTab({key: imageId, imageId})); diff --git a/lib/static/components/state/state-error.jsx b/lib/static/components/state/state-error.jsx index 588df8de6..226541695 100644 --- a/lib/static/components/state/state-error.jsx +++ b/lib/static/components/state/state-error.jsx @@ -11,7 +11,7 @@ import ResizedScreenshot from './screenshot/resized'; import ErrorDetails from './error-details'; import Details from '../details'; import {ERROR_TITLE_TEXT_LENGTH} from '../../../constants/errors'; -import {isImageDiffError, isNoRefImageError} from '../../../common-utils'; +import {isAssertViewError, isImageDiffError, isNoRefImageError} from '../../../common-utils'; class StateError extends Component { static propTypes = { @@ -95,7 +95,7 @@ class StateError extends Component { } _shouldDrawErrorInfo(error) { - return !isImageDiffError(error); + return !isImageDiffError(error) && !isAssertViewError(error); } render() { diff --git a/lib/test-adapter/playwright.ts b/lib/test-adapter/playwright.ts index f5ba556e4..2f097f898 100644 --- a/lib/test-adapter/playwright.ts +++ b/lib/test-adapter/playwright.ts @@ -160,7 +160,7 @@ export class PlaywrightTestAdapter implements ReporterTestResult { result.stack = stack; } - if (message.includes('snapshot doesn\'t exist') && message.endsWith('.png.')) { + if (message.includes('snapshot doesn\'t exist') && message.includes('.png')) { result.name = ErrorName.NO_REF_IMAGE; } else if (message.includes('Screenshot comparison failed')) { result.name = ErrorName.IMAGE_DIFF; diff --git a/test/func/fixtures/hermione/failed-describe.hermione.js b/test/func/fixtures/hermione/failed-describe.hermione.js index 990ea07a8..b5c50c412 100644 --- a/test/func/fixtures/hermione/failed-describe.hermione.js +++ b/test/func/fixtures/hermione/failed-describe.hermione.js @@ -11,6 +11,12 @@ describe('failed describe', function() { await browser.assertView('header', 'header'); }); + it('test with diff', async ({browser}) => { + await browser.url(browser.options.baseUrl); + + await browser.assertView('header', 'header'); + }); + it('test with long error message', async () => { throw new Error(`long_error_message ${'0123456789'.repeat(20)}\n message content`); }); diff --git a/test/func/fixtures/hermione/screens/7357338/chrome/header.png b/test/func/fixtures/hermione/screens/7357338/chrome/header.png new file mode 100644 index 0000000000000000000000000000000000000000..5bc4221ca688962862c7b63a15bc321f05979a62 GIT binary patch literal 176 zcmeAS@N?(olHy`uVBq!ia0vp^5EamT(V6_?>+9$BQAurq+;zOG6gF+x@MHao6&`|dn^Fw(xHU{;0s}wR=jZF^aW7i5 z=%2NdK8+7{*}rN{c}XamvO1e W&P`V`b9{idF?hQAxvXNEDK_LiUj@`;uJ@62{Vy@?a9OCF`iHW6w}_MF}DM zI>r(j(^#@^1??+0NN(ZO}=w6W1s0`vlh1E@YKNaq3PaHl1+bV_BwLN`$Vu zY+gRTsOQhwevVafL~>rVr7uZ@ow=2lVHD}m{$es-SCJeRQH?~QE{3u4FO=047M`5` z990wZXE|%oHW31sn8kHx=e)Su(YnB^7Ghj@JpQ(U!IQec4SGmthC*bz9NJfxpt#T& z!cb~floF8C-p|tQUG(7z%0OfJ-UUk?1R1Jch5-_QBOMV;ZwzEz(d27!^ zPfr`pyy`Y2E^0)Kq5Q%HG`E?2VQ= zY`!jxACi@mBXH%4LH@I-sD7&a{V5e*g@9F>%7F4(*r0kily8K1n(bf#Yw#e*^Vrx| z_`-sM6`4lcvQyWtZH?bjJuIgJq3KM_%*_>CAO-E9B&DSTcoPy5ygl9=o|u3DWIy93 z#aq@Wk%Zac6Xj%H|2h2R%NO;IOuaX^?slX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