@@ -4,6 +4,7 @@ import { createEmptyMinimalIssue, MinimalIssue, Transition } from '@atlassianlab
4
4
import { DetailedSiteInfo , emptySiteInfo , ProductBitbucket } from '../../../../atlclients/authInfo' ;
5
5
import { BitbucketBranchingModel , WorkspaceRepo } from '../../../../bitbucket/model' ;
6
6
import { Container } from '../../../../container' ;
7
+ import { FeatureFlagClient } from '../../../../util/featureFlags' ;
7
8
import { AnalyticsApi } from '../../../analyticsApi' ;
8
9
import { CommonActionType } from '../../../ipc/fromUI/common' ;
9
10
import { StartWorkAction , StartWorkActionType } from '../../../ipc/fromUI/startWork' ;
@@ -27,6 +28,14 @@ import { StartWorkWebviewController } from './startWorkWebviewController';
27
28
jest . mock ( '@atlassianlabs/guipi-core-controller' ) ;
28
29
jest . mock ( '../../../../container' ) ;
29
30
jest . mock ( '../../formatError' ) ;
31
+ jest . mock ( '../../../../util/featureFlags' , ( ) => ( {
32
+ FeatureFlagClient : {
33
+ checkGate : jest . fn ( ) ,
34
+ } ,
35
+ Features : {
36
+ StartWorkV3 : 'startWorkV3' ,
37
+ } ,
38
+ } ) ) ;
30
39
31
40
describe ( 'StartWorkWebviewController' , ( ) => {
32
41
let controller : StartWorkWebviewController ;
@@ -152,6 +161,9 @@ describe('StartWorkWebviewController', () => {
152
161
153
162
( formatError as jest . Mock ) . mockReturnValue ( 'Formatted error message' ) ;
154
163
164
+ // Mock FeatureFlagClient to return false by default (old version)
165
+ ( FeatureFlagClient . checkGate as jest . Mock ) . mockReturnValue ( false ) ;
166
+
155
167
controller = new StartWorkWebviewController (
156
168
mockMessagePoster ,
157
169
mockApi ,
@@ -453,7 +465,10 @@ describe('StartWorkWebviewController', () => {
453
465
} ) ;
454
466
} ) ;
455
467
456
- it ( 'should refresh and post init message with repo data' , async ( ) => {
468
+ it ( 'should refresh and post init message with repo data (old version - includes customBranchType)' , async ( ) => {
469
+ // Mock FeatureFlagClient to return false (old version)
470
+ ( FeatureFlagClient . checkGate as jest . Mock ) . mockReturnValue ( false ) ;
471
+
457
472
await controller . onMessageReceived ( { type : CommonActionType . Refresh } ) ;
458
473
459
474
expect ( mockApi . getWorkspaceRepos ) . toHaveBeenCalled ( ) ;
@@ -483,6 +498,38 @@ describe('StartWorkWebviewController', () => {
483
498
} ) ;
484
499
} ) ;
485
500
501
+ it ( 'should refresh and post init message with repo data (new version - excludes customBranchType)' , async ( ) => {
502
+ // Mock FeatureFlagClient to return true (new version)
503
+ ( FeatureFlagClient . checkGate as jest . Mock ) . mockReturnValue ( true ) ;
504
+
505
+ await controller . onMessageReceived ( { type : CommonActionType . Refresh } ) ;
506
+
507
+ expect ( mockApi . getWorkspaceRepos ) . toHaveBeenCalled ( ) ;
508
+ expect ( mockApi . getRepoDetails ) . toHaveBeenCalledWith ( mockWorkspaceRepo ) ;
509
+ expect ( mockApi . getRepoScmState ) . toHaveBeenCalledWith ( mockWorkspaceRepo ) ;
510
+ expect ( mockMessagePoster ) . toHaveBeenCalledWith ( {
511
+ type : StartWorkMessageType . Init ,
512
+ issue : mockIssue ,
513
+ repoData : expect . arrayContaining ( [
514
+ expect . objectContaining ( {
515
+ workspaceRepo : mockWorkspaceRepo ,
516
+ href : 'https://test.atlassian.net/projects/test/repos/repo' ,
517
+ branchTypes : expect . arrayContaining ( [
518
+ { kind : 'bugfix' , prefix : 'bugfix/' } ,
519
+ { kind : 'feature' , prefix : 'feature/' } ,
520
+ ] ) ,
521
+ developmentBranch : 'develop' ,
522
+ isCloud : true ,
523
+ userName : 'testuser' ,
524
+
525
+ hasSubmodules : false ,
526
+ } ) ,
527
+ ] ) ,
528
+ customTemplate : '{issueKey}' ,
529
+ customPrefixes : [ 'feature/' , 'bugfix/' ] ,
530
+ } ) ;
531
+ } ) ;
532
+
486
533
it ( 'should filter out repos without site remotes' , async ( ) => {
487
534
const repoWithoutRemotes = { ...mockWorkspaceRepo , siteRemotes : [ ] } ;
488
535
mockApi . getWorkspaceRepos . mockReturnValue ( [ repoWithoutRemotes ] ) ;
0 commit comments