@@ -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- testVariation . ignoreAreas
495- ) ;
496498 expect ( getImageMock ) . toHaveBeenNthCalledWith ( 1 , testVariation . baselineName ) ;
497499 expect ( getImageMock ) . toHaveBeenNthCalledWith ( 2 , imageName ) ;
498500 expect ( testRunCreateMock ) . toHaveBeenCalledWith ( {
@@ -523,7 +525,20 @@ describe('TestRunsService', () => {
523525 status : TestStatus . new ,
524526 } ,
525527 } ) ;
526- expect ( getDiffMock ) . toHaveBeenCalledWith ( baseline , image , testRun . diffTollerancePercent , testRun . ignoreAreas ) ;
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+ ] ) ;
527542 expect ( saveDiffResultMock ) . toHaveBeenCalledWith ( testRun . id , diffResult ) ;
528543 expect ( eventTestRunCreatedMock ) . toHaveBeenCalledWith ( testRunWithResult ) ;
529544 expect ( result ) . toBe ( testRunWithResult ) ;
@@ -538,7 +553,7 @@ describe('TestRunsService', () => {
538553 } ) ;
539554 service = await initService ( { } ) ;
540555
541- const result = service . getDiff ( baseline , image , 0 , '[]' ) ;
556+ const result = service . getDiff ( baseline , image , 0 , [ ] ) ;
542557
543558 expect ( result ) . toStrictEqual ( {
544559 status : undefined ,
@@ -560,7 +575,7 @@ describe('TestRunsService', () => {
560575 } ) ;
561576 service = await initService ( { } ) ;
562577
563- const result = service . getDiff ( baseline , image , 0 , '[]' ) ;
578+ const result = service . getDiff ( baseline , image , 0 , [ ] ) ;
564579
565580 expect ( result ) . toStrictEqual ( {
566581 status : TestStatus . unresolved ,
@@ -583,7 +598,7 @@ describe('TestRunsService', () => {
583598 service = await initService ( { } ) ;
584599 mocked ( Pixelmatch ) . mockReturnValueOnce ( 0 ) ;
585600
586- const result = service . getDiff ( baseline , image , 0 , '[]' ) ;
601+ const result = service . getDiff ( baseline , image , 0 , [ ] ) ;
587602
588603 expect ( result ) . toStrictEqual ( {
589604 status : TestStatus . ok ,
@@ -608,7 +623,7 @@ describe('TestRunsService', () => {
608623 const pixelMisMatchCount = 150 ;
609624 mocked ( Pixelmatch ) . mockReturnValueOnce ( pixelMisMatchCount ) ;
610625
611- const result = service . getDiff ( baseline , image , 1.5 , '[]' ) ;
626+ const result = service . getDiff ( baseline , image , 1.5 , [ ] ) ;
612627
613628 expect ( saveImageMock ) . toHaveBeenCalledTimes ( 0 ) ;
614629 expect ( result ) . toStrictEqual ( {
@@ -637,7 +652,7 @@ describe('TestRunsService', () => {
637652 saveImageMock,
638653 } ) ;
639654
640- const result = service . getDiff ( baseline , image , 1 , '[]' ) ;
655+ const result = service . getDiff ( baseline , image , 1 , [ ] ) ;
641656
642657 expect ( saveImageMock ) . toHaveBeenCalledTimes ( 1 ) ;
643658 expect ( result ) . toStrictEqual ( {
@@ -689,7 +704,7 @@ describe('TestRunsService', () => {
689704 baselineMock ,
690705 imageeMock ,
691706 testRun . diffTollerancePercent ,
692- testRun . ignoreAreas
707+ JSON . parse ( testRun . ignoreAreas )
693708 ) ;
694709 expect ( service . emitUpdateBuildEvent ) . toBeCalledWith ( testRun . buildId ) ;
695710 } ) ;
0 commit comments