Skip to content

Commit

Permalink
fix(KFLUXBUGS-1910): add Gitlab push event type
Browse files Browse the repository at this point in the history
JIRA: KFLUXBUGS-1910
  • Loading branch information
CryptoRodeo committed Dec 3, 2024
1 parent 8041520 commit b8716bf
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,48 @@ describe('usePipelinerunActions', () => {
);
});

// eslint-disable-next-line @typescript-eslint/require-await
it('should contain enabled actions for Gitlab pipeline run event type', async () => {
const { result } = renderHook(() =>
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
usePipelinerunActions({
metadata: {
labels: {
'pipelines.appstudio.openshift.io/type': 'build',
[PipelineRunLabel.COMMIT_EVENT_TYPE_LABEL]: 'Push',
},
},
status: { conditions: [{ type: 'Succeeded', status: runStatus.Running }] },
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any),
);
const actions = result.current;

expect(actions[0]).toEqual(
expect.objectContaining({
label: 'Rerun',
disabled: false,
disabledTooltip: null,
}),
);

expect(actions[1]).toEqual(
expect.objectContaining({
label: 'Stop',
disabled: false,
disabledTooltip: undefined,
}),
);

expect(actions[2]).toEqual(
expect.objectContaining({
label: 'Cancel',
disabled: false,
disabledTooltip: undefined,
}),
);
});

it('should contain disabled actions for Stop and Cancel', () => {
useAccessReviewForModelMock.mockReturnValueOnce([true, true]);
const { result } = renderHook(() =>
Expand Down Expand Up @@ -134,6 +176,33 @@ describe('usePipelinerunActions', () => {
);
});

// eslint-disable-next-line @typescript-eslint/require-await
it('should contain enabled rerun actions when PAC enabled for Gitlab pipeline run event type', async () => {
useAccessReviewForModelMock.mockReturnValueOnce([true, true]);
const { result } = renderHook(() =>
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
usePipelinerunActions({
metadata: {
labels: {
'pipelines.appstudio.openshift.io/type': 'build',
[PipelineRunLabel.COMMIT_EVENT_TYPE_LABEL]: 'Push',
},
},
status: { conditions: [{ type: 'Succeeded', status: 'True' }] },
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any),
);
const actions = result.current;

expect(actions[0]).toEqual(
expect.objectContaining({
label: 'Rerun',
disabled: false,
disabledTooltip: null,
}),
);
});

it('should contain disabled rerun actions for pull request builds', () => {
useAccessReviewForModelMock.mockReturnValueOnce([true, true]);
const { result } = renderHook(() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const usePipelinererunAction = (pipelineRun: PipelineRunKind) => {
const isPushBuildType = [PipelineRunEventType.PUSH, PipelineRunEventType.INCOMING].includes(
pipelineRun?.metadata?.labels?.[
PipelineRunLabel.COMMIT_EVENT_TYPE_LABEL
] as PipelineRunEventType,
]?.toLowerCase() as PipelineRunEventType,
);

const snapshot = React.useMemo(
Expand Down

0 comments on commit b8716bf

Please sign in to comment.