@@ -17,6 +17,7 @@ import { BuildsService } from '../builds/builds.service';
1717import { TEST_PROJECT } from '../_data_' ;
1818import { getTestVariationUniqueData } from '../utils' ;
1919import { BaselineDataDto } from '../shared/dto/baseline-data.dto' ;
20+ import { CreateTestRequestBase64Dto } from './dto/create-test-request-base64.dto' ;
2021
2122jest . mock ( 'pixelmatch' ) ;
2223jest . mock ( './dto/testRunResult.dto' ) ;
@@ -103,6 +104,7 @@ const initService = async ({
103104} ;
104105describe ( 'TestRunsService' , ( ) => {
105106 let service : TestRunsService ;
107+ const imageBuffer = Buffer . from ( 'Image' ) ;
106108 const ignoreAreas = [ { x : 1 , y : 2 , width : 10 , height : 20 } ] ;
107109 const tempIgnoreAreas = [ { x : 3 , y : 4 , width : 30 , height : 40 } ] ;
108110 const baseTestRun : TestRun = {
@@ -184,7 +186,6 @@ describe('TestRunsService', () => {
184186 buildId : 'buildId' ,
185187 projectId : 'projectId' ,
186188 name : 'Test name' ,
187- imageBase64 : 'Image' ,
188189 os : 'OS' ,
189190 browser : 'browser' ,
190191 viewport : 'viewport' ,
@@ -259,9 +260,9 @@ describe('TestRunsService', () => {
259260 const tryAutoApproveByNewBaselines = jest . fn ( ) ;
260261 service [ 'tryAutoApproveByNewBaselines' ] = tryAutoApproveByNewBaselines . mockResolvedValueOnce ( testRunWithResult ) ;
261262
262- const result = await service . create ( testVariation , createTestRequestDto ) ;
263+ const result = await service . create ( { testVariation, createTestRequestDto, imageBuffer } ) ;
263264
264- expect ( saveImageMock ) . toHaveBeenCalledWith ( 'screenshot' , Buffer . from ( createTestRequestDto . imageBase64 , 'base64' ) ) ;
265+ expect ( saveImageMock ) . toHaveBeenCalledWith ( 'screenshot' , imageBuffer ) ;
265266 expect ( testRunCreateMock ) . toHaveBeenCalledWith ( {
266267 data : {
267268 imageName,
@@ -722,7 +723,6 @@ describe('TestRunsService', () => {
722723 buildId : 'buildId' ,
723724 projectId : 'projectId' ,
724725 name : 'Test name' ,
725- imageBase64 : 'Image' ,
726726 os : 'OS' ,
727727 browser : 'browser' ,
728728 viewport : 'viewport' ,
@@ -789,7 +789,7 @@ describe('TestRunsService', () => {
789789 branchName : createTestRequestDto . branchName ,
790790 } ;
791791
792- await service . postTestRun ( createTestRequestDto ) ;
792+ await service . postTestRun ( { createTestRequestDto, imageBuffer } ) ;
793793
794794 expect ( testVariationFindOrCreateMock ) . toHaveBeenCalledWith ( createTestRequestDto . projectId , baselineData ) ;
795795 expect ( testRunFindManyMock ) . toHaveBeenCalledWith ( {
@@ -800,7 +800,7 @@ describe('TestRunsService', () => {
800800 } ,
801801 } ) ;
802802 expect ( deleteMock ) . toHaveBeenCalledWith ( testRun . id ) ;
803- expect ( createMock ) . toHaveBeenCalledWith ( testVariation , createTestRequestDto ) ;
803+ expect ( createMock ) . toHaveBeenCalledWith ( { testVariation, createTestRequestDto, imageBuffer } ) ;
804804 expect ( service . calculateDiff ) . toHaveBeenCalledWith ( testRun ) ;
805805 expect ( service [ 'tryAutoApproveByPastBaselines' ] ) . toHaveBeenCalledWith ( testVariation , testRun ) ;
806806 expect ( service [ 'tryAutoApproveByNewBaselines' ] ) . toHaveBeenCalledWith ( testVariation , testRun ) ;
0 commit comments