|
| 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 | + |
1 | 6 | import '@testing-library/jest-dom';
|
2 | 7 | import { useNavigate } from 'react-router-dom';
|
3 | 8 | import { renderHook } from '@testing-library/react-hooks';
|
@@ -85,6 +90,45 @@ describe('usePipelinerunActions', () => {
|
85 | 90 | );
|
86 | 91 | });
|
87 | 92 |
|
| 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 | + |
88 | 132 | it('should contain disabled actions for Stop and Cancel', () => {
|
89 | 133 | useAccessReviewForModelMock.mockReturnValueOnce([true, true]);
|
90 | 134 | const { result } = renderHook(() =>
|
@@ -134,6 +178,30 @@ describe('usePipelinerunActions', () => {
|
134 | 178 | );
|
135 | 179 | });
|
136 | 180 |
|
| 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 | + |
137 | 205 | it('should contain disabled rerun actions for pull request builds', () => {
|
138 | 206 | useAccessReviewForModelMock.mockReturnValueOnce([true, true]);
|
139 | 207 | const { result } = renderHook(() =>
|
|
0 commit comments