@@ -959,127 +959,4 @@ describe('TestRunsService', () => {
959959 expect ( createMock ) . toHaveBeenCalledWith ( testVariation , createTestRequestDto ) ;
960960 expect ( mocked ( TestRunResultDto ) ) . toHaveBeenCalledWith ( testRun , testVariation ) ;
961961 } ) ;
962-
963- it ( 'merge' , async ( ) => {
964- const mergedBranch = 'develop' ;
965- const project : Project = {
966- id : 'some id' ,
967- name : 'some name' ,
968- mainBranchName : 'master' ,
969- updatedAt : new Date ( ) ,
970- createdAt : new Date ( ) ,
971- } ;
972- const build : Build = {
973- id : 'a9385fc1-884d-4f9f-915e-40da0e7773d5' ,
974- number : null ,
975- branchName : project . mainBranchName ,
976- status : null ,
977- projectId : project . id ,
978- updatedAt : new Date ( ) ,
979- createdAt : new Date ( ) ,
980- userId : null ,
981- } ;
982- const testVariation : TestVariation = {
983- id : '123' ,
984- projectId : project . id ,
985- name : 'Test name' ,
986- baselineName : 'baselineName' ,
987- os : 'OS' ,
988- browser : 'browser' ,
989- viewport : 'viewport' ,
990- device : 'device' ,
991- ignoreAreas : '[]' ,
992- comment : 'some comment' ,
993- createdAt : new Date ( ) ,
994- updatedAt : new Date ( ) ,
995- branchName : mergedBranch ,
996- } ;
997- const testVariationNoBaseline : TestVariation = {
998- id : '123' ,
999- projectId : project . id ,
1000- name : 'Test name' ,
1001- baselineName : null ,
1002- os : 'OS' ,
1003- browser : 'browser' ,
1004- viewport : 'viewport' ,
1005- device : 'device' ,
1006- ignoreAreas : '[]' ,
1007- comment : 'some comment' ,
1008- createdAt : new Date ( ) ,
1009- updatedAt : new Date ( ) ,
1010- branchName : mergedBranch ,
1011- } ;
1012- const testVariationMainBranch : TestVariation = {
1013- id : '123' ,
1014- projectId : project . id ,
1015- name : 'Test name' ,
1016- baselineName : 'baselineName' ,
1017- os : 'OS' ,
1018- browser : 'browser' ,
1019- viewport : 'viewport' ,
1020- device : 'device' ,
1021- ignoreAreas : '[]' ,
1022- comment : 'some comment' ,
1023- createdAt : new Date ( ) ,
1024- updatedAt : new Date ( ) ,
1025- branchName : project . mainBranchName ,
1026- } ;
1027- const projectFindOneMock = jest . fn ( ) . mockResolvedValueOnce ( project ) ;
1028- const buildCreateMock = jest . fn ( ) . mockResolvedValueOnce ( build ) ;
1029- const eventBuildCreatedMock = jest . fn ( ) ;
1030- const testVariationFindManyMock = jest . fn ( ) . mockResolvedValueOnce ( [ testVariation , testVariationNoBaseline ] ) ;
1031- const image = new PNG ( {
1032- width : 10 ,
1033- height : 10 ,
1034- } ) ;
1035- const getImageMock = jest
1036- . fn ( )
1037- . mockReturnValueOnce ( image )
1038- . mockReturnValueOnce ( null ) ;
1039- const testVariationFindOrCreateMock = jest . fn ( ) . mockResolvedValueOnce ( testVariationMainBranch ) ;
1040- const createMock = jest . fn ( ) ;
1041- const service = await initService ( {
1042- projectFindOneMock,
1043- buildCreateMock,
1044- eventBuildCreatedMock,
1045- testVariationFindManyMock,
1046- testVariationFindOrCreateMock,
1047- getImageMock,
1048- } ) ;
1049- service . create = createMock ;
1050-
1051- await service . merge ( project . id , mergedBranch ) ;
1052-
1053- expect ( projectFindOneMock ) . toHaveBeenCalledWith ( { where : { id : project . id } } ) ;
1054- expect ( buildCreateMock ) . toHaveBeenCalledWith ( {
1055- data : {
1056- branchName : project . mainBranchName ,
1057- project : {
1058- connect : {
1059- id : project . id ,
1060- } ,
1061- } ,
1062- } ,
1063- } ) ;
1064- expect ( eventBuildCreatedMock ) . toHaveBeenCalledWith ( new BuildDto ( build ) ) ;
1065- expect ( testVariationFindManyMock ) . toHaveBeenCalledWith ( {
1066- where : { projectId : project . id , branchName : mergedBranch } ,
1067- } ) ;
1068- expect ( getImageMock ) . toHaveBeenCalledWith ( testVariation . baselineName ) ;
1069- expect ( testVariationFindOrCreateMock ) . toHaveBeenCalledWith ( project . id , {
1070- name : testVariation . name ,
1071- os : testVariation . os ,
1072- device : testVariation . device ,
1073- browser : testVariation . browser ,
1074- viewport : testVariation . viewport ,
1075- branchName : project . mainBranchName ,
1076- } ) ;
1077- expect ( createMock ) . toHaveBeenCalledWith ( testVariationMainBranch , {
1078- ...testVariation ,
1079- buildId : build . id ,
1080- imageBase64 : PNG . sync . write ( image ) . toString ( 'base64' ) ,
1081- diffTollerancePercent : 0 ,
1082- merge : true ,
1083- } ) ;
1084- } ) ;
1085962} ) ;
0 commit comments