@@ -85,6 +85,48 @@ describe('usePipelinerunActions', () => {
85
85
) ;
86
86
} ) ;
87
87
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
+
88
130
it ( 'should contain disabled actions for Stop and Cancel' , ( ) => {
89
131
useAccessReviewForModelMock . mockReturnValueOnce ( [ true , true ] ) ;
90
132
const { result } = renderHook ( ( ) =>
@@ -134,6 +176,33 @@ describe('usePipelinerunActions', () => {
134
176
) ;
135
177
} ) ;
136
178
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
+
137
206
it ( 'should contain disabled rerun actions for pull request builds' , ( ) => {
138
207
useAccessReviewForModelMock . mockReturnValueOnce ( [ true , true ] ) ;
139
208
const { result } = renderHook ( ( ) =>
0 commit comments