@@ -595,23 +595,21 @@ test.describe('api keys component @machine', () => {
595595 const getAPIKeyCount = createAPIKeyCountHelper ( u ) ;
596596
597597 // Create a specific search term that will match our new key
598- const searchTerm = 'search-test' ;
599- const newApiKeyName = `${ searchTerm } -${ Date . now ( ) } ` ;
598+ const timestamp = Date . now ( ) ;
599+ const searchTerm = `searchfilter-${ timestamp } ` ;
600+ const newApiKeyName = `${ searchTerm } -key` ;
600601
601602 // Apply search filter first
602603 const searchInput = u . page . locator ( 'input.cl-apiKeysSearchInput' ) ;
603604 await searchInput . fill ( searchTerm ) ;
604605
605- // Wait for search to be applied (debounced) - wait for empty state or results
606- await u . page . waitForFunction (
607- ( ) => {
608- const emptyMessage = document . querySelector ( '[data-localization-key*="emptyRow"]' ) ;
609- const hasResults =
610- document . querySelectorAll ( '.cl-apiKeysTable .cl-tableBody .cl-tableRow .cl-menuButton' ) . length > 0 ;
611- return emptyMessage || hasResults ;
612- } ,
613- { timeout : 2000 } ,
614- ) ;
606+ // Wait for search to actually filter results - either empty state appears
607+ // or the loading/fetching state completes with no matching results.
608+ await expect ( async ( ) => {
609+ const emptyMessage = u . page . locator ( '[data-localization-key*="emptyRow"]' ) ;
610+ const isEmptyVisible = await emptyMessage . isVisible ( ) . catch ( ( ) => false ) ;
611+ expect ( isEmptyVisible ) . toBe ( true ) ;
612+ } ) . toPass ( { timeout : 10000 } ) ;
615613
616614 // Verify no results initially match
617615 expect ( await getAPIKeyCount ( ) ) . toBe ( 0 ) ;
@@ -640,7 +638,7 @@ test.describe('api keys component @machine', () => {
640638 ( ) => {
641639 return document . querySelectorAll ( '.cl-apiKeysTable .cl-tableBody .cl-tableRow .cl-menuButton' ) . length > 0 ;
642640 } ,
643- { timeout : 2000 } ,
641+ { timeout : 5000 } ,
644642 ) ;
645643 await expect ( table . locator ( '.cl-tableRow' , { hasText : newApiKeyName } ) ) . toBeVisible ( ) ;
646644 } ) ;
0 commit comments