Skip to content

Commit 41e28b3

Browse files
committed
coverage updated
1 parent c104cb7 commit 41e28b3

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

src/test-runs/test-runs.service.spec.ts

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,14 @@ describe('TestRunsService', () => {
429429
diffTollerancePercent: undefined,
430430
branchName: 'develop',
431431
merge: true,
432+
ignoreAreas: [
433+
{
434+
x: 1,
435+
y: 2,
436+
width: 100,
437+
height: 200,
438+
},
439+
],
432440
};
433441
const testRunWithResult = {
434442
id: 'id',
@@ -457,7 +465,7 @@ describe('TestRunsService', () => {
457465
browser: 'browser',
458466
viewport: 'viewport',
459467
device: 'device',
460-
ignoreAreas: '[]',
468+
ignoreAreas: '[{"x":3,"y":4,"width":500,"height":600}]',
461469
comment: 'some comment',
462470
createdAt: new Date(),
463471
updatedAt: new Date(),
@@ -487,12 +495,6 @@ describe('TestRunsService', () => {
487495
const result = await service.create(testVariation, createTestRequestDto);
488496

489497
expect(saveImageMock).toHaveBeenCalledWith('screenshot', Buffer.from(createTestRequestDto.imageBase64, 'base64'));
490-
expect(service.getDiff).toHaveBeenCalledWith(
491-
baseline,
492-
image,
493-
testRun.diffTollerancePercent,
494-
JSON.parse(testVariation.ignoreAreas)
495-
);
496498
expect(getImageMock).toHaveBeenNthCalledWith(1, testVariation.baselineName);
497499
expect(getImageMock).toHaveBeenNthCalledWith(2, imageName);
498500
expect(testRunCreateMock).toHaveBeenCalledWith({
@@ -523,12 +525,20 @@ describe('TestRunsService', () => {
523525
status: TestStatus.new,
524526
},
525527
});
526-
expect(getDiffMock).toHaveBeenCalledWith(
527-
baseline,
528-
image,
529-
testRun.diffTollerancePercent,
530-
JSON.parse(testRun.ignoreAreas)
531-
);
528+
expect(getDiffMock).toHaveBeenCalledWith(baseline, image, testRun.diffTollerancePercent, [
529+
{
530+
x: 3,
531+
y: 4,
532+
width: 500,
533+
height: 600,
534+
},
535+
{
536+
x: 1,
537+
y: 2,
538+
width: 100,
539+
height: 200,
540+
},
541+
]);
532542
expect(saveDiffResultMock).toHaveBeenCalledWith(testRun.id, diffResult);
533543
expect(eventTestRunCreatedMock).toHaveBeenCalledWith(testRunWithResult);
534544
expect(result).toBe(testRunWithResult);

src/test-runs/test-runs.service.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,8 @@ export class TestRunsService {
227227
const baseline = this.staticService.getImage(testRun.baselineName);
228228
const image = this.staticService.getImage(imageName);
229229

230-
let ignoreAreas: IgnoreAreaDto[] = [];
231-
if (!!testVariation.ignoreAreas) {
232-
ignoreAreas = ignoreAreas.concat(JSON.parse(testVariation.ignoreAreas));
233-
}
230+
// combine ignore areas from testVarition together with testRun request
231+
let ignoreAreas: IgnoreAreaDto[] = JSON.parse(testVariation.ignoreAreas);
234232
if (createTestRequestDto.ignoreAreas?.length > 0) {
235233
ignoreAreas = ignoreAreas.concat(createTestRequestDto.ignoreAreas);
236234
}

0 commit comments

Comments
 (0)