@@ -9,7 +9,7 @@ import deployment_status_staging from "fixtures/deployment_status_staging.json";
99import { getRepoConfig } from "services/user-config-service" ;
1010import { when } from "jest-when" ;
1111import { DatabaseStateCreator } from "test/utils/database-state-creator" ;
12- import { shouldSendAll } from "config/feature-flags" ;
12+ import { shouldSendAll , booleanFlag , BooleanFlags } from "config/feature-flags" ;
1313import { cacheSuccessfulDeploymentInfo } from "services/deployment-cache-service" ;
1414import { Config } from "interfaces/common" ;
1515import { cloneDeep } from "lodash" ;
@@ -476,6 +476,60 @@ describe("transform GitHub webhook payload to Jira payload", () => {
476476 ] ) ) ;
477477 } ) ;
478478
479+ it ( `skip sending commits association in deployment for Cloud when ff is on` , async ( ) => {
480+
481+ when ( booleanFlag ) . calledWith ( BooleanFlags . SKIP_SENDING_COMMIT_ASSOCIATION , expect . anything ( ) ) . mockResolvedValue ( true ) ;
482+
483+ githubUserTokenNock ( DatabaseStateCreator . GITHUB_INSTALLATION_ID ) ;
484+ githubUserTokenNock ( DatabaseStateCreator . GITHUB_INSTALLATION_ID ) ;
485+
486+ await cacheSuccessfulDeploymentInfo ( {
487+ gitHubBaseUrl : gitHubClient . baseUrl ,
488+ repositoryId : deployment_status . payload . repository . id ,
489+ commitSha : "6e87a40179eb7ecf5094b9c8d690db727472d5bc" ,
490+ env : "Production" ,
491+ createdAt : new Date ( new Date ( deployment_status . payload . deployment_status . created_at ) . getTime ( ) - 1000 )
492+ } , getLogger ( "deploymentLogger" ) ) ;
493+
494+ // Mocking all GitHub API Calls
495+ // Get commit
496+ githubNock . get ( `/repos/${ owner . login } /${ repoName } /commits/${ deployment_status . payload . deployment . sha } ` )
497+ . reply ( 200 , {
498+ ...owner ,
499+ commit : {
500+ message : "testing"
501+ }
502+ } ) ;
503+
504+ // Compare commits
505+ githubNock . get ( `/repos/${ owner . login } /${ repoName } /compare/6e87a40179eb7ecf5094b9c8d690db727472d5bc...${ deployment_status . payload . deployment . sha } ` )
506+ . reply ( 200 , {
507+ commits : [
508+ {
509+ commit : {
510+ message : "ABC-1"
511+ } ,
512+ sha : "6e87a40179eb7ecf5094b9c8d690db727472d5bc1"
513+ } ,
514+ {
515+ commit : {
516+ message : "ABC-2"
517+ } ,
518+ sha : "6e87a40179eb7ecf5094b9c8d690db727472d5bc2"
519+ }
520+ ]
521+ } ) ;
522+
523+ const jiraPayload = await transformDeployment ( gitHubClient , deployment_status . payload as any , jiraHost , "webhook" , getLogger ( "deploymentLogger" ) , undefined ) ;
524+
525+ expect ( jiraPayload ) . toMatchObject ( buildJiraPayload ( "testing" , [
526+ {
527+ associationType : "issueIdOrKeys" ,
528+ values : [ "ABC-1" , "ABC-2" ]
529+ }
530+ ] ) ) ;
531+ } ) ;
532+
479533 it ( `supports branch and merge workflows, sending related commits in deploymentfor Cloud` , async ( ) => {
480534
481535 githubUserTokenNock ( DatabaseStateCreator . GITHUB_INSTALLATION_ID ) ;
0 commit comments