@@ -28,6 +28,7 @@ import {
28
28
SettingsMinor
29
29
} from '@shopify/polaris-icons' ;
30
30
import api from "../api" ;
31
+ import observeApi from "../../observe/api" ;
31
32
import func from '@/util/func' ;
32
33
import { useParams } from 'react-router' ;
33
34
import { useState , useEffect , useRef , useMemo , useReducer } from 'react' ;
@@ -107,6 +108,12 @@ let filterOptions = [
107
108
label : 'API groups' ,
108
109
title : 'API groups' ,
109
110
choices : [ ] ,
111
+ } ,
112
+ {
113
+ key : 'apiNameFilter' ,
114
+ label : 'API Name' ,
115
+ title : 'API name' ,
116
+ choices : [ ] ,
110
117
}
111
118
]
112
119
@@ -185,6 +192,8 @@ function SingleTestRunPage() {
185
192
case 'categoryFilter' :
186
193
case 'testFilter' :
187
194
return func . convertToDisambiguateLabelObj ( value , null , 2 )
195
+ case 'apiNameFilter' :
196
+ return func . convertToDisambiguateLabelObj ( value , null , 1 )
188
197
default :
189
198
return value ;
190
199
}
@@ -234,13 +243,13 @@ function SingleTestRunPage() {
234
243
}
235
244
236
245
useEffect ( ( ) => {
237
- setUpdateTable ( Date . now ( ) . toString ( ) )
238
246
if (
239
247
( localCategoryMap && Object . keys ( localCategoryMap ) . length > 0 ) &&
240
248
( localSubCategoryMap && Object . keys ( localSubCategoryMap ) . length > 0 )
241
249
) {
242
250
setUseLocalSubCategoryData ( true )
243
251
}
252
+ setUpdateTable ( Date . now ( ) . toString ( ) )
244
253
} , [ testingRunResultSummariesObj ] )
245
254
246
255
filterOptions = func . getCollectionFilters ( filterOptions )
@@ -264,13 +273,66 @@ function SingleTestRunPage() {
264
273
}
265
274
} )
266
275
276
+ const populateApiNameFilterChoices = async ( testingRun ) => {
277
+ if ( testingRun ?. testingEndpoints ) {
278
+ const { testingEndpoints} = testingRun ;
279
+ let apiEndpoints = [ ] ;
280
+
281
+ if ( testingEndpoints . type === "COLLECTION_WISE" ) {
282
+ const collectionId = testingEndpoints . apiCollectionId ;
283
+ if ( collectionId ) {
284
+ try {
285
+ const response = await observeApi . fetchApiInfosForCollection (
286
+ collectionId ) ;
287
+ if ( response ?. apiInfoList ) {
288
+ const limitedEndpoints = response . apiInfoList . slice (
289
+ 0 , 5000 ) ;
290
+ apiEndpoints = getApiEndpointsMap ( limitedEndpoints ) ;
291
+ }
292
+ } catch ( error ) {
293
+ console . error ( "Error fetching collection endpoints:" , error ) ;
294
+ }
295
+ }
296
+ } else if ( testingEndpoints . type === "CUSTOM"
297
+ && testingEndpoints . apisList ) {
298
+ const limitedApis = testingEndpoints . apisList . slice ( 0 , 5000 ) ;
299
+ apiEndpoints = getApiEndpointsMap ( limitedApis ) ;
300
+ }
301
+
302
+ filterOptions = filterOptions . map ( filter => {
303
+ if ( filter . key === 'apiNameFilter' ) {
304
+ return {
305
+ ...filter ,
306
+ choices : apiEndpoints
307
+ } ;
308
+ }
309
+ return filter ;
310
+ } ) ;
311
+ setUpdateTable ( Date . now ( ) . toString ( ) ) ;
312
+ }
313
+ }
314
+
315
+ const getApiEndpointsMap = ( endpoints ) => {
316
+ return Array . from (
317
+ new Map (
318
+ endpoints
319
+ . map ( e => e . id )
320
+ . map ( e => [ e . url ,
321
+ { label : func . convertToRelativePath ( e . url ) , value : e . url } ] )
322
+ ) . values ( )
323
+ ) ;
324
+ }
325
+
267
326
const fetchTestingRunResultSummaries = async ( ) => {
268
327
let tempTestingRunResultSummaries = [ ] ;
269
- await api . fetchTestingRunResultSummaries ( hexId ) . then ( ( { testingRun, testingRunResultSummaries, workflowTest, testingRunType } ) => {
328
+ await api . fetchTestingRunResultSummaries ( hexId ) . then ( async ( { testingRun, testingRunResultSummaries, workflowTest, testingRunType } ) => {
270
329
tempTestingRunResultSummaries = testingRunResultSummaries
271
330
setTestingRunResultSummariesObj ( {
272
331
testingRun, workflowTest, testingRunType
273
332
} )
333
+ if ( testingRun ) {
334
+ await populateApiNameFilterChoices ( testingRun )
335
+ }
274
336
} )
275
337
const timeNow = func . timeNow ( )
276
338
const defaultIgnoreTime = LocalStore . getState ( ) . defaultIgnoreSummaryTime
@@ -285,6 +347,7 @@ function SingleTestRunPage() {
285
347
if ( isBWithinTimeAndRunning ) return 1 ;
286
348
return b . startTimestamp - a . startTimestamp ;
287
349
} )
350
+
288
351
if ( tempTestingRunResultSummaries && tempTestingRunResultSummaries . length > 0 ) {
289
352
setSummary ( tempTestingRunResultSummaries [ 0 ] , true )
290
353
}
0 commit comments