Skip to content

Commit 20d8bd0

Browse files
committed
fix(KFLUXBUGS-1910): add Gitlab push event type
JIRA: KFLUXBUGS-1910
1 parent b082a43 commit 20d8bd0

File tree

3 files changed

+74
-1
lines changed

3 files changed

+74
-1
lines changed

src/components/PipelineRun/PipelineRunListView/__tests__/pipelinerun-actions.spec.tsx

+68
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/* eslint-disable @typescript-eslint/require-await */
2+
/* eslint-disable @typescript-eslint/no-unsafe-argument */
3+
/* eslint-disable @typescript-eslint/no-explicit-any */
4+
// These checks are disabled for this test.
5+
16
import '@testing-library/jest-dom';
27
import { useNavigate } from 'react-router-dom';
38
import { renderHook } from '@testing-library/react-hooks';
@@ -85,6 +90,45 @@ describe('usePipelinerunActions', () => {
8590
);
8691
});
8792

93+
it('should contain enabled actions for Gitlab pipeline run event type', async () => {
94+
const { result } = renderHook(() =>
95+
usePipelinerunActions({
96+
metadata: {
97+
labels: {
98+
'pipelines.appstudio.openshift.io/type': 'build',
99+
[PipelineRunLabel.COMMIT_EVENT_TYPE_LABEL]: PipelineRunEventType.GITLAB_PUSH,
100+
},
101+
},
102+
status: { conditions: [{ type: 'Succeeded', status: runStatus.Running }] },
103+
} as any),
104+
);
105+
const actions = result.current;
106+
107+
expect(actions[0]).toEqual(
108+
expect.objectContaining({
109+
label: 'Rerun',
110+
disabled: false,
111+
disabledTooltip: null,
112+
}),
113+
);
114+
115+
expect(actions[1]).toEqual(
116+
expect.objectContaining({
117+
label: 'Stop',
118+
disabled: false,
119+
disabledTooltip: undefined,
120+
}),
121+
);
122+
123+
expect(actions[2]).toEqual(
124+
expect.objectContaining({
125+
label: 'Cancel',
126+
disabled: false,
127+
disabledTooltip: undefined,
128+
}),
129+
);
130+
});
131+
88132
it('should contain disabled actions for Stop and Cancel', () => {
89133
useAccessReviewForModelMock.mockReturnValueOnce([true, true]);
90134
const { result } = renderHook(() =>
@@ -134,6 +178,30 @@ describe('usePipelinerunActions', () => {
134178
);
135179
});
136180

181+
it('should contain enabled rerun actions when PAC enabled for Gitlab pipeline run event type', async () => {
182+
useAccessReviewForModelMock.mockReturnValueOnce([true, true]);
183+
const { result } = renderHook(() =>
184+
usePipelinerunActions({
185+
metadata: {
186+
labels: {
187+
'pipelines.appstudio.openshift.io/type': 'build',
188+
[PipelineRunLabel.COMMIT_EVENT_TYPE_LABEL]: PipelineRunEventType.GITLAB_PUSH,
189+
},
190+
},
191+
status: { conditions: [{ type: 'Succeeded', status: 'True' }] },
192+
} as any),
193+
);
194+
const actions = result.current;
195+
196+
expect(actions[0]).toEqual(
197+
expect.objectContaining({
198+
label: 'Rerun',
199+
disabled: false,
200+
disabledTooltip: null,
201+
}),
202+
);
203+
});
204+
137205
it('should contain disabled rerun actions for pull request builds', () => {
138206
useAccessReviewForModelMock.mockReturnValueOnce([true, true]);
139207
const { result } = renderHook(() =>

src/components/PipelineRun/PipelineRunListView/pipelinerun-actions.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ export const usePipelinererunAction = (pipelineRun: PipelineRunKind) => {
5454
const [snapshots, snapshotsLoaded, snapshotsError] = useSnapshots(namespace, workspace);
5555

5656
const snapShotLabel = pipelineRun?.metadata?.labels?.[PipelineRunLabel.SNAPSHOT];
57-
const isPushBuildType = [PipelineRunEventType.PUSH, PipelineRunEventType.INCOMING].includes(
57+
const isPushBuildType = [
58+
PipelineRunEventType.PUSH,
59+
PipelineRunEventType.GITLAB_PUSH,
60+
PipelineRunEventType.INCOMING,
61+
].includes(
5862
pipelineRun?.metadata?.labels?.[
5963
PipelineRunLabel.COMMIT_EVENT_TYPE_LABEL
6064
] as PipelineRunEventType,

src/consts/pipelinerun.ts

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export enum PipelineRunType {
4949

5050
export enum PipelineRunEventType {
5151
PUSH = 'push',
52+
GITLAB_PUSH = 'Push',
5253
PULL = 'pull_request',
5354
INCOMING = 'incoming',
5455
RETEST = 'retest-all-comment',

0 commit comments

Comments
 (0)