Skip to content

Commit

Permalink
fix: minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowusr committed Nov 7, 2023
1 parent 245de9a commit 3c2d78c
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
1 change: 0 additions & 1 deletion .babelignore

This file was deleted.

File renamed without changes.
4 changes: 2 additions & 2 deletions lib/gui/tool-runner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ module.exports = class ToolRunner {
}

if (shouldRevertReference) {
await reporterHelper.revertReferenceImage(formattedResult, stateName);
await reporterHelper.revertReferenceImage(removedResult, formattedResult, stateName);
}

if (previousExpectedPath) {
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions lib/reporter-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) ?? {};
Expand All @@ -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);
}
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/test-adapter/hermione.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 3c2d78c

Please sign in to comment.