Skip to content

Commit d2d5200

Browse files
authored
Merge pull request #41 from CryptoRodeo/kfluxbugs-1910
fix(KFLUXBUGS-1910): add Gitlab push event type
2 parents e5a978b + b8716bf commit d2d5200

File tree

2 files changed

+70
-1
lines changed

2 files changed

+70
-1
lines changed

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

+69
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,48 @@ describe('usePipelinerunActions', () => {
8585
);
8686
});
8787

88+
// eslint-disable-next-line @typescript-eslint/require-await
89+
it('should contain enabled actions for Gitlab pipeline run event type', async () => {
90+
const { result } = renderHook(() =>
91+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
92+
usePipelinerunActions({
93+
metadata: {
94+
labels: {
95+
'pipelines.appstudio.openshift.io/type': 'build',
96+
[PipelineRunLabel.COMMIT_EVENT_TYPE_LABEL]: 'Push',
97+
},
98+
},
99+
status: { conditions: [{ type: 'Succeeded', status: runStatus.Running }] },
100+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
101+
} as any),
102+
);
103+
const actions = result.current;
104+
105+
expect(actions[0]).toEqual(
106+
expect.objectContaining({
107+
label: 'Rerun',
108+
disabled: false,
109+
disabledTooltip: null,
110+
}),
111+
);
112+
113+
expect(actions[1]).toEqual(
114+
expect.objectContaining({
115+
label: 'Stop',
116+
disabled: false,
117+
disabledTooltip: undefined,
118+
}),
119+
);
120+
121+
expect(actions[2]).toEqual(
122+
expect.objectContaining({
123+
label: 'Cancel',
124+
disabled: false,
125+
disabledTooltip: undefined,
126+
}),
127+
);
128+
});
129+
88130
it('should contain disabled actions for Stop and Cancel', () => {
89131
useAccessReviewForModelMock.mockReturnValueOnce([true, true]);
90132
const { result } = renderHook(() =>
@@ -134,6 +176,33 @@ describe('usePipelinerunActions', () => {
134176
);
135177
});
136178

179+
// eslint-disable-next-line @typescript-eslint/require-await
180+
it('should contain enabled rerun actions when PAC enabled for Gitlab pipeline run event type', async () => {
181+
useAccessReviewForModelMock.mockReturnValueOnce([true, true]);
182+
const { result } = renderHook(() =>
183+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
184+
usePipelinerunActions({
185+
metadata: {
186+
labels: {
187+
'pipelines.appstudio.openshift.io/type': 'build',
188+
[PipelineRunLabel.COMMIT_EVENT_TYPE_LABEL]: 'Push',
189+
},
190+
},
191+
status: { conditions: [{ type: 'Succeeded', status: 'True' }] },
192+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
193+
} as any),
194+
);
195+
const actions = result.current;
196+
197+
expect(actions[0]).toEqual(
198+
expect.objectContaining({
199+
label: 'Rerun',
200+
disabled: false,
201+
disabledTooltip: null,
202+
}),
203+
);
204+
});
205+
137206
it('should contain disabled rerun actions for pull request builds', () => {
138207
useAccessReviewForModelMock.mockReturnValueOnce([true, true]);
139208
const { result } = renderHook(() =>

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export const usePipelinererunAction = (pipelineRun: PipelineRunKind) => {
5757
const isPushBuildType = [PipelineRunEventType.PUSH, PipelineRunEventType.INCOMING].includes(
5858
pipelineRun?.metadata?.labels?.[
5959
PipelineRunLabel.COMMIT_EVENT_TYPE_LABEL
60-
] as PipelineRunEventType,
60+
]?.toLowerCase() as PipelineRunEventType,
6161
);
6262

6363
const snapshot = React.useMemo(

0 commit comments

Comments
 (0)