From 3c2d78c5a94ca858ee9331ac07f6013e67af0a1b Mon Sep 17 00:00:00 2001 From: shadowusr Date: Tue, 7 Nov 2023 15:28:21 +0300 Subject: [PATCH] fix: minor bug fixes --- .babelignore | 1 - .babelrc => babel.config.json | 0 lib/gui/tool-runner/index.js | 4 ++-- lib/reporter-helpers.js | 10 +++++----- lib/test-adapter/hermione.ts | 2 +- .../fixtures/playwright/tests/failed-describe.spec.ts | 1 + 6 files changed, 9 insertions(+), 9 deletions(-) delete mode 100644 .babelignore rename .babelrc => babel.config.json (100%) diff --git a/.babelignore b/.babelignore deleted file mode 100644 index dc6e9aad3..000000000 --- a/.babelignore +++ /dev/null @@ -1 +0,0 @@ -./lib/gui diff --git a/.babelrc b/babel.config.json similarity index 100% rename from .babelrc rename to babel.config.json diff --git a/lib/gui/tool-runner/index.js b/lib/gui/tool-runner/index.js index 5b18d15a9..9b7a6b98f 100644 --- a/lib/gui/tool-runner/index.js +++ b/lib/gui/tool-runner/index.js @@ -150,7 +150,7 @@ module.exports = class ToolRunner { } if (shouldRevertReference) { - await reporterHelper.revertReferenceImage(formattedResult, stateName); + await reporterHelper.revertReferenceImage(removedResult, formattedResult, stateName); } if (previousExpectedPath) { @@ -250,7 +250,7 @@ module.exports = class ToolRunner { return _.extend(imageInfo, {expectedImg: refImg}); }); - const res = _.merge({}, rawTest, {assertViewResults, imagesInfo, sessionId, attempt, origAttempt: attempt, meta: {url}, updated: true}); + const res = _.merge({}, rawTest, {assertViewResults, imagesInfo, sessionId, attempt, meta: {url}, updated: true}); // _.merge can't fully clone test object since hermione@7+ // TODO: use separate object to represent test results. Do not extend test object with test results diff --git a/lib/reporter-helpers.js b/lib/reporter-helpers.js index 49f37c353..3dc583b1f 100644 --- a/lib/reporter-helpers.js +++ b/lib/reporter-helpers.js @@ -7,7 +7,7 @@ const {getShortMD5} = require('./common-utils'); const utils = require('./server-utils'); const {ImageHandler} = require('./image-handler'); -const mkReferenceId = (testId, stateName) => getShortMD5(`${testId}#${stateName}`); +const mkReferenceHash = (testId, stateName) => getShortMD5(`${testId}#${stateName}`); exports.updateReferenceImage = async (testResult, reportPath, stateName) => { const currImg = ImageHandler.getCurrImg(testResult.assertViewResults, stateName) ?? {}; @@ -19,7 +19,7 @@ exports.updateReferenceImage = async (testResult, reportPath, stateName) => { const referencePath = ImageHandler.getRefImg(testResult.assertViewResults, stateName)?.path; if (utils.fileExists(referencePath)) { - const referenceId = mkReferenceId(testResult.id, stateName); + const referenceId = mkReferenceHash(testResult.id, stateName); const oldReferencePath = path.resolve(tmp.tmpdir, referenceId); await utils.copyFileAsync(referencePath, oldReferencePath); } @@ -30,9 +30,9 @@ exports.updateReferenceImage = async (testResult, reportPath, stateName) => { ]); }; -exports.revertReferenceImage = (testResult, stateName) => { - const referenceId = mkReferenceId(testResult.id, stateName); - const oldReferencePath = path.resolve(tmp.tmpdir, referenceId); +exports.revertReferenceImage = (referenceId, testResult, stateName) => { + const referenceHash = mkReferenceHash(referenceId, stateName); + const oldReferencePath = path.resolve(tmp.tmpdir, referenceHash); const referencePath = ImageHandler.getRefImg(testResult.assertViewResults, stateName)?.path; return utils.copyFileAsync(oldReferencePath, referencePath); diff --git a/lib/test-adapter/hermione.ts b/lib/test-adapter/hermione.ts index fc78eeadd..b7f93fa5a 100644 --- a/lib/test-adapter/hermione.ts +++ b/lib/test-adapter/hermione.ts @@ -49,7 +49,7 @@ export class HermioneTestAdapter implements ReporterTestResult { this._testResult = testResult; this._testId = mkTestId(testResult.fullTitle(), testResult.browserId); this._errorDetails = null; - this._timestamp = this._testResult.timestamp; + this._timestamp = this._testResult.timestamp ?? this._testResult.startTime ?? Date.now(); this._status = status; const browserVersion = _.get(this._testResult, 'meta.browserVersion', this._testResult.browserVersion); diff --git a/test/func/fixtures/playwright/tests/failed-describe.spec.ts b/test/func/fixtures/playwright/tests/failed-describe.spec.ts index 214fbcc22..9704ed5a0 100644 --- a/test/func/fixtures/playwright/tests/failed-describe.spec.ts +++ b/test/func/fixtures/playwright/tests/failed-describe.spec.ts @@ -34,6 +34,7 @@ test.describe('failed describe', () => { test.skip(true, 'foo-bar'); }); + // Warning: this test may fail unless launched inside docker container test('test with successful assertView and error', async ({page, baseURL}) => { await page.goto(baseURL as string);