1111 * limitations under the License.
1212 */
1313import { APIRequestContext , expect , Page , test } from '@playwright/test' ;
14+ import { PLAYWRIGHT_BASIC_TEST_TAG_OBJ } from '../../constant/config' ;
1415import { GlobalSettingOptions } from '../../constant/settings' ;
1516import { getApiContext , redirectToHomePage } from '../../utils/common' ;
1617import { settingClick } from '../../utils/sidebar' ;
17- import { PLAYWRIGHT_BASIC_TEST_TAG_OBJ } from '../../constant/config' ;
1818
1919const navigateToAuditLogsPage = async ( page : Page ) => {
20- const logRequest = page . waitForResponse ( '/api/v1/audit/logs?*' ) ;
20+ const logRequest = page . waitForResponse ( '/api/v1/audit/logs?*' ) ;
2121 await settingClick ( page , GlobalSettingOptions . AUDIT_LOGS ) ;
2222 await logRequest ;
23- await page . waitForSelector ( '[data-testid="loader"]' , { state : 'detached' } ) ;
23+ await page . waitForSelector ( '.ant-skeleton' , { state : 'detached' } ) ;
24+ await page . getByTestId ( 'audit-log-list' ) . waitFor ( { state : 'visible' } ) ;
2425} ;
2526
2627test . use ( { storageState : 'playwright/.auth/admin.json' } ) ;
@@ -118,6 +119,9 @@ test.describe('Audit Logs Page', PLAYWRIGHT_BASIC_TEST_TAG_OBJ, () => {
118119
119120 // Verify Time filter is active
120121 const timeFilterTag = page . getByTestId ( 'filter-chip-time' ) ;
122+ await page . waitForSelector ( '.ant-skeleton' , {
123+ state : 'detached' ,
124+ } ) ;
121125 await expect ( timeFilterTag ) . toBeVisible ( ) ;
122126 } ) ;
123127
@@ -289,7 +293,13 @@ test.describe('Audit Logs Page', PLAYWRIGHT_BASIC_TEST_TAG_OBJ, () => {
289293 await userFilter . click ( ) ;
290294
291295 const searchInput = page . getByTestId ( 'search-input' ) ;
296+ const userSearchResponse = page . waitForResponse (
297+ ( response ) =>
298+ response . url ( ) . includes ( '/api/v1/search/query' ) &&
299+ response . url ( ) . includes ( 'index=user_search_index' )
300+ ) ;
292301 await searchInput . fill ( 'admin' ) ;
302+ await userSearchResponse ;
293303
294304 const adminOption = page
295305 . locator ( '.ant-dropdown-menu' )
@@ -330,8 +340,6 @@ test.describe('Audit Logs Page', PLAYWRIGHT_BASIC_TEST_TAG_OBJ, () => {
330340 const searchInput = page . getByTestId ( 'search-input' ) ;
331341 await searchInput . fill ( entityType ) ;
332342
333- await page . waitForTimeout ( 500 ) ;
334-
335343 const entityOption = page . locator ( '.ant-dropdown-menu-item' ) . first ( ) ;
336344 await expect ( entityOption ) . toBeVisible ( ) ;
337345
@@ -404,6 +412,9 @@ test.describe('Audit Logs Page', PLAYWRIGHT_BASIC_TEST_TAG_OBJ, () => {
404412 await searchInput . press ( 'Enter' ) ;
405413 const response = await auditLogResponse ;
406414 expect ( response . status ( ) ) . toBe ( 200 ) ;
415+ await page . waitForSelector ( '.ant-skeleton' , {
416+ state : 'detached' ,
417+ } ) ;
407418 } ) ;
408419
409420 await test . step ( 'Verify Clear button appears after search' , async ( ) => {
@@ -412,8 +423,15 @@ test.describe('Audit Logs Page', PLAYWRIGHT_BASIC_TEST_TAG_OBJ, () => {
412423 } ) ;
413424
414425 await test . step ( 'Clear search' , async ( ) => {
426+ const auditLogResponse = page . waitForResponse ( ( response ) =>
427+ response . url ( ) . includes ( '/api/v1/audit' )
428+ ) ;
415429 const clearButton = page . getByTestId ( 'clear-filters' ) ;
416430 await clearButton . click ( ) ;
431+ await auditLogResponse ;
432+ await page . waitForSelector ( '.ant-skeleton' , {
433+ state : 'detached' ,
434+ } ) ;
417435
418436 const searchInput = page . getByPlaceholder ( 'Search audit logs' ) ;
419437 await expect ( searchInput ) . toHaveValue ( '' ) ;
@@ -434,14 +452,24 @@ test.describe('Audit Logs Page', PLAYWRIGHT_BASIC_TEST_TAG_OBJ, () => {
434452 await searchInput . press ( 'Enter' ) ;
435453 const response = await auditLogResponse ;
436454 expect ( response . status ( ) ) . toBe ( 200 ) ;
455+ await page . waitForSelector ( '.ant-skeleton' , {
456+ state : 'detached' ,
457+ } ) ;
437458
438459 // Clear search
439460 const clearButton = page . getByTestId ( 'clear-filters' ) ;
440461 if ( await clearButton . isVisible ( ) ) {
462+ const auditLogResponseClear = page . waitForResponse ( ( response ) =>
463+ response . url ( ) . includes ( '/api/v1/audit' )
464+ ) ;
441465 await clearButton . click ( ) ;
466+ await auditLogResponseClear ;
442467 }
443468
444469 // Search with uppercase term - should return similar results
470+ await page . waitForSelector ( '.ant-skeleton' , {
471+ state : 'detached' ,
472+ } ) ;
445473 await searchInput . fill ( 'ADMIN' ) ;
446474
447475 const auditLogResponse2 = page . waitForResponse (
@@ -453,6 +481,9 @@ test.describe('Audit Logs Page', PLAYWRIGHT_BASIC_TEST_TAG_OBJ, () => {
453481 await searchInput . press ( 'Enter' ) ;
454482 const response2 = await auditLogResponse2 ;
455483 expect ( response2 . status ( ) ) . toBe ( 200 ) ;
484+ await page . waitForSelector ( '.ant-skeleton' , {
485+ state : 'detached' ,
486+ } ) ;
456487 } ) ;
457488 } ) ;
458489
@@ -678,6 +709,9 @@ test.describe(
678709 await searchInput . press ( 'Enter' ) ;
679710 const response = await auditLogResponse ;
680711 expect ( response . status ( ) ) . toBe ( 200 ) ;
712+ await page . waitForSelector ( '.ant-skeleton' , {
713+ state : 'detached' ,
714+ } ) ;
681715 const responseData = await response . json ( ) ;
682716
683717 // Verify response has expected structure
@@ -788,11 +822,15 @@ test.describe(
788822 await test . step ( 'Enter a search term' , async ( ) => {
789823 const searchInput = page . getByPlaceholder ( 'Search audit logs' ) ;
790824 await searchInput . fill ( 'admin' ) ;
791- await searchInput . press ( 'Enter' ) ;
792825
793- await page . waitForResponse ( ( response ) =>
826+ const auditResponse = page . waitForResponse ( ( response ) =>
794827 response . url ( ) . includes ( '/api/v1/audit' )
795828 ) ;
829+ await searchInput . press ( 'Enter' ) ;
830+ await auditResponse ;
831+ await page . waitForSelector ( '.ant-skeleton' , {
832+ state : 'detached' ,
833+ } ) ;
796834 } ) ;
797835
798836 await test . step ( 'Open Export modal' , async ( ) => {
@@ -1601,6 +1639,9 @@ test.describe(
16011639 await searchInput . press ( 'Enter' ) ;
16021640 const response = await searchResponse ;
16031641 expect ( response . status ( ) ) . toBe ( 200 ) ;
1642+ await page . waitForSelector ( '.ant-skeleton' , {
1643+ state : 'detached' ,
1644+ } ) ;
16041645 const responseData = await response . json ( ) ;
16051646
16061647 // Should find at least one entry
0 commit comments