Skip to content

Commit dfa612f

Browse files
test(files): add test case for loading indicator during folder navigation
Signed-off-by: Luka Trovic <luka@nextcloud.com>
1 parent 1d5e2c1 commit dfa612f

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

apps/files/src/views/FilesList.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
<!-- Initial loading -->
100100
<NcLoadingIcon
101101
v-if="loading && !isRefreshing"
102+
data-cy-files-loading
102103
class="files-list__loading-icon"
103104
:size="38"
104105
:name="t('files', 'Loading current folder')" />

tests/playwright/e2e/files/files-navigation.spec.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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(/remote\.php\/dav\/files\//, 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(/remote\.php\/dav\/files\//)
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

Comments
 (0)