@@ -39,15 +39,15 @@ export class TestVariationsService {
3939 } ) ;
4040 }
4141
42- async findOrCreate ( projectId : string , baselineData : BaselineDataDto ) : Promise < TestVariation > {
42+ async findOrCreate ( projectId : string , baselineData : BaselineDataDto , mainBranchName ?: string ) : Promise < TestVariation > {
4343 const project = await this . prismaService . project . findUnique ( { where : { id : projectId } } ) ;
4444
4545 const [ [ mainBranchTestVariation ] , [ currentBranchTestVariation ] ] = await Promise . all ( [
4646 // search main branch variation
4747 this . prismaService . testVariation . findMany ( {
4848 where : {
4949 projectId,
50- branchName : project . mainBranchName ,
50+ branchName : mainBranchName ?? project . mainBranchName ,
5151 ...getTestVariationUniqueData ( baselineData ) ,
5252 } ,
5353 } ) ,
@@ -92,18 +92,18 @@ export class TestVariationsService {
9292 } ) ;
9393 }
9494
95- async merge ( projectId : string , branchName : string ) : Promise < BuildDto > {
95+ async merge ( projectId : string , fromBranch : string , toBranch : string ) : Promise < BuildDto > {
9696 const project : Project = await this . prismaService . project . findUnique ( { where : { id : projectId } } ) ;
9797
9898 // create build
9999 const build : BuildDto = await this . buildsService . create ( {
100- branchName : project . mainBranchName ,
100+ branchName : toBranch ,
101101 project : projectId ,
102102 } ) ;
103103
104104 // find side branch variations
105105 const testVariations : TestVariation [ ] = await this . prismaService . testVariation . findMany ( {
106- where : { projectId, branchName } ,
106+ where : { projectId, branchName : fromBranch } ,
107107 } ) ;
108108
109109 // compare to main branch variations
@@ -113,10 +113,10 @@ export class TestVariationsService {
113113 try {
114114 const imageBase64 = PNG . sync . write ( baseline ) . toString ( 'base64' ) ;
115115
116- // get main branch variation
116+ // get destination branch variation
117117 const baselineData = convertBaselineDataToQuery ( {
118118 ...sideBranchTestVariation ,
119- branchName : project . mainBranchName ,
119+ branchName : toBranch ,
120120 } ) ;
121121 const mainBranchTestVariation = await this . findOrCreate ( projectId , baselineData ) ;
122122
0 commit comments