Skip to content

Commit 28e2f2e

Browse files
committed
test: add failing test for saveMethods
1 parent b749bed commit 28e2f2e

3 files changed

Lines changed: 56 additions & 0 deletions

File tree

packages/image-comparison-core/src/commands/saveFullPageScreen.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,4 +318,23 @@ describe('saveFullPageScreen', () => {
318318
fileName: 'test-fullpage.png'
319319
})
320320
})
321+
322+
it('should always save actual image even when alwaysSaveActualImage is false in config', async () => {
323+
const options = {
324+
...baseOptions,
325+
saveFullPageOptions: {
326+
...baseOptions.saveFullPageOptions,
327+
wic: {
328+
...baseOptions.saveFullPageOptions.wic,
329+
alwaysSaveActualImage: false, // Set to false in config
330+
}
331+
}
332+
}
333+
334+
await saveFullPageScreen(options)
335+
336+
expect(buildAfterScreenshotOptionsSpy).toHaveBeenCalled()
337+
const buildAfterScreenshotOptionsCall = buildAfterScreenshotOptionsSpy.mock.calls[buildAfterScreenshotOptionsSpy.mock.calls.length - 1]
338+
expect(buildAfterScreenshotOptionsCall[0].wicOptions).toHaveProperty('alwaysSaveActualImage', true)
339+
})
321340
})

packages/image-comparison-core/src/commands/saveWebElement.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,4 +277,23 @@ describe('saveWebElement', () => {
277277
expect(buildAfterScreenshotOptionsSpy.mock.calls[0][0]).toMatchSnapshot()
278278
expect(afterScreenshotSpy.mock.calls[0][1]).toMatchSnapshot()
279279
})
280+
281+
it('should always save actual image even when alwaysSaveActualImage is false in config', async () => {
282+
const options = {
283+
...baseOptions,
284+
saveElementOptions: {
285+
...baseOptions.saveElementOptions,
286+
wic: {
287+
...baseOptions.saveElementOptions.wic,
288+
alwaysSaveActualImage: false, // Set to false in config
289+
}
290+
}
291+
}
292+
293+
await saveWebElement(options)
294+
295+
expect(buildAfterScreenshotOptionsSpy).toHaveBeenCalled()
296+
const buildAfterScreenshotOptionsCall = buildAfterScreenshotOptionsSpy.mock.calls[buildAfterScreenshotOptionsSpy.mock.calls.length - 1]
297+
expect(buildAfterScreenshotOptionsCall[0].wicOptions).toHaveProperty('alwaysSaveActualImage', true)
298+
})
280299
})

packages/image-comparison-core/src/commands/saveWebScreen.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,4 +248,22 @@ describe('saveWebScreen', () => {
248248
expect(takeWebScreenshotSpy.mock.calls[0]).toMatchSnapshot()
249249
expect(afterScreenshotSpy.mock.calls[0]).toMatchSnapshot()
250250
})
251+
252+
it('should always save actual image even when alwaysSaveActualImage is false in config', async () => {
253+
const options = createTestOptions(baseOptions, {
254+
saveScreenOptions: {
255+
...baseOptions.saveScreenOptions,
256+
wic: {
257+
...baseOptions.saveScreenOptions.wic,
258+
alwaysSaveActualImage: false, // Set to false in config
259+
}
260+
}
261+
})
262+
263+
await saveWebScreen(options)
264+
265+
expect(afterScreenshotSpy).toHaveBeenCalled()
266+
const afterScreenshotCall = afterScreenshotSpy.mock.calls[afterScreenshotSpy.mock.calls.length - 1]
267+
expect(afterScreenshotCall[1]).toHaveProperty('alwaysSaveActualImage', true)
268+
})
251269
})

0 commit comments

Comments
 (0)