Skip to content

Commit 2148a2c

Browse files
committed
AXON-762: remove 'custom' branch prefix in new version
1 parent 5fc9e2c commit 2148a2c

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

src/lib/webview/controller/startwork/startWorkWebviewController.test.ts

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { createEmptyMinimalIssue, MinimalIssue, Transition } from '@atlassianlab
44
import { DetailedSiteInfo, emptySiteInfo, ProductBitbucket } from '../../../../atlclients/authInfo';
55
import { BitbucketBranchingModel, WorkspaceRepo } from '../../../../bitbucket/model';
66
import { Container } from '../../../../container';
7+
import { FeatureFlagClient } from '../../../../util/featureFlags';
78
import { AnalyticsApi } from '../../../analyticsApi';
89
import { CommonActionType } from '../../../ipc/fromUI/common';
910
import { StartWorkAction, StartWorkActionType } from '../../../ipc/fromUI/startWork';
@@ -27,6 +28,14 @@ import { StartWorkWebviewController } from './startWorkWebviewController';
2728
jest.mock('@atlassianlabs/guipi-core-controller');
2829
jest.mock('../../../../container');
2930
jest.mock('../../formatError');
31+
jest.mock('../../../../util/featureFlags', () => ({
32+
FeatureFlagClient: {
33+
checkGate: jest.fn(),
34+
},
35+
Features: {
36+
StartWorkV3: 'startWorkV3',
37+
},
38+
}));
3039

3140
describe('StartWorkWebviewController', () => {
3241
let controller: StartWorkWebviewController;
@@ -152,6 +161,9 @@ describe('StartWorkWebviewController', () => {
152161

153162
(formatError as jest.Mock).mockReturnValue('Formatted error message');
154163

164+
// Mock FeatureFlagClient to return false by default (old version)
165+
(FeatureFlagClient.checkGate as jest.Mock).mockReturnValue(false);
166+
155167
controller = new StartWorkWebviewController(
156168
mockMessagePoster,
157169
mockApi,
@@ -453,7 +465,10 @@ describe('StartWorkWebviewController', () => {
453465
});
454466
});
455467

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+
457472
await controller.onMessageReceived({ type: CommonActionType.Refresh });
458473

459474
expect(mockApi.getWorkspaceRepos).toHaveBeenCalled();
@@ -483,6 +498,38 @@ describe('StartWorkWebviewController', () => {
483498
});
484499
});
485500

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+
userEmail: '[email protected]',
525+
hasSubmodules: false,
526+
}),
527+
]),
528+
customTemplate: '{issueKey}',
529+
customPrefixes: ['feature/', 'bugfix/'],
530+
});
531+
});
532+
486533
it('should filter out repos without site remotes', async () => {
487534
const repoWithoutRemotes = { ...mockWorkspaceRepo, siteRemotes: [] };
488535
mockApi.getWorkspaceRepos.mockReturnValue([repoWithoutRemotes]);

src/lib/webview/controller/startwork/startWorkWebviewController.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { ProductBitbucket } from '../../../../atlclients/authInfo';
55
import { BitbucketBranchingModel } from '../../../../bitbucket/model';
66
import { Commands } from '../../../../constants';
77
import { Container } from '../../../../container';
8+
import { FeatureFlagClient, Features } from '../../../../util/featureFlags';
89
import { OnJiraEditedRefreshDelay } from '../../../../util/time';
910
import { AnalyticsApi } from '../../../analyticsApi';
1011
import { CommonActionType } from '../../../ipc/fromUI/common';
@@ -84,7 +85,8 @@ export class StartWorkWebviewController implements WebviewController<StartWorkIs
8485
return a.kind.localeCompare(b.kind);
8586
},
8687
),
87-
customBranchType,
88+
// Only add customBranchType for old version (not V3)
89+
...(FeatureFlagClient.checkGate(Features.StartWorkV3) ? [] : [customBranchType]),
8890
];
8991
const developmentBranch = repoDetails.developmentBranch;
9092
const href = repoDetails.url;

0 commit comments

Comments
 (0)