@@ -48,4 +48,46 @@ test.describe('Files: Navigation', () => {
4848 await expect ( filesListPage . getRowForFile ( 'baz' ) ) . toBeVisible ( )
4949 await expect ( filesListPage . getRowForFile ( 'baz' ) ) . toBeActiveRow ( )
5050 } )
51+
52+ test ( 'show loading indicator when navigating' , async ( { page, filesListPage } ) => {
53+ await filesListPage . navigateToFolder ( 'foo/bar/baz' )
54+ await expect ( page . locator ( '[data-cy-files-list-row-fileid]' ) ) . toHaveCount ( 0 )
55+
56+ // Block the PROPFIND request to simulate a slow network and show the loading indicator
57+ let releaseNavigation ! : ( ) => void
58+ const navigationBlocked = new Promise < void > ( ( resolve ) => {
59+ releaseNavigation = resolve
60+ } )
61+ let blockedNavigationRequest = false
62+ await page . route ( / r e m o t e \. p h p \/ d a v \/ f i l e s \/ / , async ( route ) => {
63+ const request = route . request ( )
64+ if ( ! blockedNavigationRequest && request . method ( ) === 'PROPFIND' && request . url ( ) . includes ( '/foo/bar' ) ) {
65+ blockedNavigationRequest = true
66+ await navigationBlocked
67+ }
68+
69+ await route . continue ( )
70+ } )
71+
72+ // Navigate back to the parent folder — the PROPFIND request will be blocked
73+ const navigationResponse = page . waitForResponse ( ( response ) => response . url ( ) . includes ( '/remote.php/dav/files/' )
74+ && response . request ( ) . method ( ) === 'PROPFIND'
75+ && response . url ( ) . includes ( '/foo/bar' ) )
76+
77+ await page . goBack ( )
78+
79+ await expect . poll ( ( ) => new URL ( page . url ( ) ) . searchParams . get ( 'dir' ) ) . toBe ( '/foo/bar' )
80+ await expect ( page . locator ( '[data-cy-files-loading]' ) ) . toBeVisible ( )
81+ expect ( blockedNavigationRequest ) . toBe ( true )
82+
83+ // Release the blocked navigation request and wait for it to complete
84+ releaseNavigation ( )
85+ await navigationResponse
86+ await page . unroute ( / r e m o t e \. p h p \/ d a v \/ f i l e s \/ / )
87+
88+ // Wait for the loading indicator to disappear and the folder to be rendered
89+ await expect ( page . locator ( '[data-cy-files-loading]' ) ) . not . toBeVisible ( )
90+ await expect ( filesListPage . getRowForFile ( 'baz' ) ) . toBeVisible ( )
91+ await expect ( filesListPage . getRowForFile ( 'baz' ) ) . toBeActiveRow ( )
92+ } )
5193} )
0 commit comments