From 5c5148714c2b82e769ed909eaa8829dbf0566454 Mon Sep 17 00:00:00 2001 From: sipayrt Date: Mon, 2 Oct 2023 17:44:45 +0300 Subject: [PATCH] fix(screenshot-undo): do not fail on revert screenshot with different state name --- lib/report-builder/gui.js | 3 ++- test/unit/lib/report-builder/gui.js | 7 ++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/report-builder/gui.js b/lib/report-builder/gui.js index 456f452d1..f4fa5d4cb 100644 --- a/lib/report-builder/gui.js +++ b/lib/report-builder/gui.js @@ -115,7 +115,8 @@ module.exports = class GuiReportBuilder extends StaticReportBuilder { } const previousExpectedPath = _.get(previousImage, 'expectedImg.path', null); - const shouldRemoveReference = _.isNull(previousImage.refImg.size); + const previousImageRefImgSize = _.get(previousImage, 'refImg.size', null); + const shouldRemoveReference = _.isNull(previousImageRefImgSize); const shouldRevertReference = !shouldRemoveReference; let updatedImage, removedResult; diff --git a/test/unit/lib/report-builder/gui.js b/test/unit/lib/report-builder/gui.js index 23f101417..e0d2bdd30 100644 --- a/test/unit/lib/report-builder/gui.js +++ b/test/unit/lib/report-builder/gui.js @@ -365,7 +365,7 @@ describe('GuiReportBuilder', () => { let reportBuilder; function stubResultData_(result, {resultId, stateName}) { - const res = _.defaultsDeep(result, { + const res = _.defaults(result, { imageId: 'imageId', status: UPDATED, timestamp: 100500, @@ -475,10 +475,7 @@ describe('GuiReportBuilder', () => { const resultId = 'result-id'; const stateName = 's-name'; const formattedResult = mkFormattedResultStub_({id: resultId, stateName}); - const previousImage = { - expectedImg: {path: 'previous-expected-path'}, - refImg: {path: 'previous-reference-path', size: null} - }; + const previousImage = null; const updatedImage = { id: 'updated-img-id', parentId: 'parent-id'