Skip to content

Commit ed7fb12

Browse files
committed
test: adjust Cypress tests for refactored files app UI
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent d8b05ec commit ed7fb12

8 files changed

Lines changed: 209 additions & 141 deletions

File tree

cypress/e2e/files/FilesUtils.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export function triggerSelectionAction(actionId: string) {
162162
getSelectionActionButton().click({ force: true })
163163
// the entry might already be a button or a button might its child
164164
getSelectionActionEntry(actionId)
165-
.then(($el) => $el.is('button') ? cy.wrap($el) : cy.wrap($el).findByRole('button').last())
165+
.then(($el) => $el.is('button') ? cy.wrap($el) : cy.wrap($el).findByRole('menuitem').last())
166166
.should('exist')
167167
.click()
168168
}
@@ -384,12 +384,24 @@ export function triggerFileListAction(actionId: string) {
384384
}
385385

386386
/**
387+
* Reloads the current folder
387388
*
389+
* @param intercept if true this will wait for the PROPFIND to complete before it resolves
388390
*/
389-
export function reloadCurrentFolder() {
391+
export function reloadCurrentFolder(intercept = true) {
390392
cy.intercept('PROPFIND', /\/remote.php\/dav\//).as('propfind')
391-
cy.get('[data-cy-files-content-breadcrumbs]').findByRole('button', { description: 'Reload current directory' }).click()
392-
cy.wait('@propfind')
393+
cy.findByRole('navigation', { name: 'Current directory path' })
394+
.findAllByRole('button')
395+
.filter('[aria-haspopup="menu"]')
396+
.click()
397+
cy.findByRole('menu')
398+
.should('be.visible')
399+
.findByRole('menuitem', { name: 'Reload content' })
400+
.click()
401+
402+
if (intercept) {
403+
cy.wait('@propfind')
404+
}
393405
}
394406

395407
/**

cypress/e2e/files/drag-n-drop.cy.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ describe('files: Drag and Drop', { testIsolation: true }, () => {
132132
cy.get('[data-cy-upload-picker] progress').should('not.be.visible')
133133
cy.get('@uploadFile.all').should('have.length', 2)
134134

135+
// see the warning
136+
cy.get('.toast-warning').should('exist')
137+
138+
// close all toasts
139+
cy.get('.toastify')
140+
.findAllByRole('button', { name: 'Close' })
141+
.click({ multiple: true })
142+
135143
getRowForFile('first.txt').should('be.visible')
136144
getRowForFile('second.txt').should('be.visible')
137145
getRowForFile('Foo').should('not.exist')

cypress/e2e/files/files-filtering.cy.ts

Lines changed: 56 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,17 @@ describe('files: Filter in files list', { testIsolation: true }, () => {
6969
getRowForFile('file.txt').should('be.visible')
7070
getRowForFile('spreadsheet.csv').should('be.visible')
7171

72-
filesFilters.filterContainter()
73-
.findByRole('button', { name: 'Type' })
74-
.should('be.visible')
75-
.click()
76-
cy.findByRole('menuitemcheckbox', { name: 'Spreadsheets' })
77-
.should('be.visible')
78-
.click()
79-
filesFilters.filterContainter()
80-
.findByRole('button', { name: 'Type' })
72+
filesFilters.triggerFilter('Type')
73+
74+
cy.findByRole('button', { name: 'Spreadsheets' })
8175
.should('be.visible')
76+
.and('have.attr', 'aria-pressed', 'false')
77+
.as('spreadsheetsFilterButton')
8278
.click()
79+
cy.get('@spreadsheetsFilterButton')
80+
.should('have.attr', 'aria-pressed', 'true')
81+
82+
filesFilters.closeFilterMenu()
8383

8484
// See that only the spreadsheet is visible
8585
getRowForFile('spreadsheet.csv').should('be.visible')
@@ -91,33 +91,32 @@ describe('files: Filter in files list', { testIsolation: true }, () => {
9191
// All are visible by default
9292
getRowForFile('folder').should('be.visible')
9393

94-
filesFilters.filterContainter()
95-
.findByRole('button', { name: 'Type' })
96-
.should('be.visible')
97-
.click()
98-
cy.findByRole('menuitemcheckbox', { name: 'Spreadsheets' })
99-
.should('be.visible')
100-
.click()
101-
filesFilters.filterContainter()
102-
.findByRole('button', { name: 'Type' })
94+
filesFilters.triggerFilter('Type')
95+
96+
cy.findByRole('button', { name: 'Spreadsheets' })
10397
.should('be.visible')
98+
.as('spreadsheetsFilterButton')
10499
.click()
100+
cy.get('@spreadsheetsFilterButton')
101+
.should('have.attr', 'aria-pressed', 'true')
102+
103+
filesFilters.closeFilterMenu()
105104

106105
// See folder is not visible
107106
getRowForFile('folder').should('not.exist')
108107

109108
// clear filter
110-
filesFilters.filterContainter()
111-
.findByRole('button', { name: 'Type' })
112-
.should('be.visible')
113-
.click()
114-
cy.findByRole('menuitem', { name: /clear filter/i })
115-
.should('be.visible')
116-
.click()
117-
filesFilters.filterContainter()
118-
.findByRole('button', { name: 'Type' })
109+
filesFilters.triggerFilter('Type')
110+
111+
cy.findByRole('button', { name: 'Spreadsheets' })
119112
.should('be.visible')
113+
.and('have.attr', 'aria-pressed', 'true')
114+
.as('spreadsheetsFilterButton')
120115
.click()
116+
cy.get('@spreadsheetsFilterButton')
117+
.should('have.attr', 'aria-pressed', 'false')
118+
119+
filesFilters.closeFilterMenu()
121120

122121
// See folder is visible again
123122
getRowForFile('folder').should('be.visible')
@@ -127,17 +126,16 @@ describe('files: Filter in files list', { testIsolation: true }, () => {
127126
// All are visible by default
128127
getRowForFile('folder').should('be.visible')
129128

130-
filesFilters.filterContainter()
131-
.findByRole('button', { name: 'Type' })
132-
.should('be.visible')
133-
.click()
134-
cy.findByRole('menuitemcheckbox', { name: 'Spreadsheets' })
135-
.should('be.visible')
136-
.click()
137-
filesFilters.filterContainter()
138-
.findByRole('button', { name: 'Type' })
129+
filesFilters.triggerFilter('Type')
130+
131+
cy.findByRole('button', { name: 'Spreadsheets' })
139132
.should('be.visible')
133+
.as('spreadsheetsFilterButton')
140134
.click()
135+
cy.get('@spreadsheetsFilterButton')
136+
.should('have.attr', 'aria-pressed', 'true')
137+
138+
filesFilters.closeFilterMenu()
141139

142140
// See folder is not visible
143141
getRowForFile('folder').should('not.exist')
@@ -154,16 +152,16 @@ describe('files: Filter in files list', { testIsolation: true }, () => {
154152
getRowForFile('folder').should('be.visible')
155153
getRowForFile('file.txt').should('be.visible')
156154

157-
filesFilters.filterContainter()
158-
.findByRole('button', { name: 'Type' })
159-
.should('be.visible')
160-
.click()
161-
cy.findByRole('menuitemcheckbox', { name: 'Folders' })
155+
filesFilters.triggerFilter('Type')
156+
157+
cy.findByRole('button', { name: 'Folders' })
162158
.should('be.visible')
159+
.as('spreadsheetsFilterButton')
163160
.click()
164-
filesFilters.filterContainter()
165-
.findByRole('button', { name: 'Type' })
166-
.click()
161+
cy.get('@spreadsheetsFilterButton')
162+
.should('have.attr', 'aria-pressed', 'true')
163+
164+
filesFilters.closeFilterMenu()
167165

168166
// See that only the folder is visible
169167
getRowForFile('folder').should('be.visible')
@@ -189,20 +187,16 @@ describe('files: Filter in files list', { testIsolation: true }, () => {
189187
getRowForFile('file.txt').should('be.visible')
190188

191189
// enable type filter for folders
192-
filesFilters.filterContainter()
193-
.findByRole('button', { name: 'Type' })
194-
.should('be.visible')
195-
.click()
196-
cy.findByRole('menuitemcheckbox', { name: 'Folders' })
190+
filesFilters.triggerFilter('Type')
191+
192+
cy.findByRole('button', { name: 'Folders' })
197193
.should('be.visible')
194+
.as('spreadsheetsFilterButton')
198195
.click()
199-
// assert the button is checked
200-
cy.findByRole('menuitemcheckbox', { name: 'Folders' })
201-
.should('have.attr', 'aria-checked', 'true')
202-
// close the menu
203-
filesFilters.filterContainter()
204-
.findByRole('button', { name: 'Type' })
205-
.click()
196+
cy.get('@spreadsheetsFilterButton')
197+
.should('have.attr', 'aria-pressed', 'true')
198+
199+
filesFilters.closeFilterMenu()
206200

207201
// See the chips are active
208202
filesFilters.activeFilters()
@@ -222,13 +216,13 @@ describe('files: Filter in files list', { testIsolation: true }, () => {
222216
.should('have.length', 1)
223217
.contains(/Folder/).should('be.visible')
224218
// And also the button should be active
225-
filesFilters.filterContainter()
226-
.findByRole('button', { name: 'Type' })
227-
.should('be.visible')
228-
.click()
229-
cy.findByRole('menuitemcheckbox', { name: 'Folders' })
219+
filesFilters.triggerFilter('Type')
220+
221+
cy.findByRole('button', { name: 'Folders' })
230222
.should('be.visible')
231-
.and('have.attr', 'aria-checked', 'true')
223+
.should('have.attr', 'aria-pressed', 'true')
224+
225+
filesFilters.closeFilterMenu()
232226
})
233227

234228
/** Regression test of https://github.com/nextcloud/server/issues/53038 */

cypress/e2e/files/files-settings.cy.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ describe('files: Set default view', { testIsolation: true }, () => {
1919

2020
// See URL and current view
2121
cy.url().should('match', /\/apps\/files\/files/)
22-
cy.get('[data-cy-files-content-breadcrumbs]')
23-
.findByRole('button', {
24-
name: 'All files',
25-
description: 'Reload current directory',
26-
})
22+
cy.findByRole('navigation', { name: 'Current directory path' })
23+
.findAllByRole('button')
24+
.first()
25+
.should('have.text', 'All files')
2726

2827
// See the option is also selected
2928
// Open the files settings
@@ -54,11 +53,10 @@ describe('files: Set default view', { testIsolation: true }, () => {
5453

5554
cy.visit('/apps/files')
5655
cy.url().should('match', /\/apps\/files\/personal/)
57-
cy.get('[data-cy-files-content-breadcrumbs]')
58-
.findByRole('button', {
59-
name: 'Personal files',
60-
description: 'Reload current directory',
61-
})
56+
cy.findByRole('navigation', { name: 'Current directory path' })
57+
.findAllByRole('button')
58+
.first()
59+
.should('have.text', 'Personal files')
6260
})
6361
})
6462

cypress/e2e/files/live_photos.cy.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
import type { User } from '@nextcloud/e2e-test-server/cypress'
77

88
import {
9-
clickOnBreadcrumbs,
109
copyFile,
1110
createFolder,
1211
getRowForFile,
1312
getRowForFileId,
1413
moveFile,
1514
navigateToFolder,
15+
reloadCurrentFolder,
1616
renameFile,
1717
triggerActionForFile,
1818
triggerInlineActionForFileId,
@@ -52,7 +52,7 @@ describe('Files: Live photos', { testIsolation: true }, () => {
5252

5353
it('Copies both files when copying the .jpg', () => {
5454
copyFile(`${randomFileName}.jpg`, '.')
55-
clickOnBreadcrumbs('All files')
55+
reloadCurrentFolder()
5656

5757
getRowForFile(`${randomFileName}.jpg`).should('have.length', 1)
5858
getRowForFile(`${randomFileName}.mov`).should('have.length', 1)
@@ -62,7 +62,7 @@ describe('Files: Live photos', { testIsolation: true }, () => {
6262

6363
it('Copies both files when copying the .mov', () => {
6464
copyFile(`${randomFileName}.mov`, '.')
65-
clickOnBreadcrumbs('All files')
65+
reloadCurrentFolder()
6666

6767
getRowForFile(`${randomFileName}.mov`).should('have.length', 1)
6868
getRowForFile(`${randomFileName} (copy).jpg`).should('have.length', 1)
@@ -100,23 +100,23 @@ describe('Files: Live photos', { testIsolation: true }, () => {
100100

101101
it('Moves files when moving the .jpg', () => {
102102
renameFile(`${randomFileName}.jpg`, `${randomFileName}_moved.jpg`)
103-
clickOnBreadcrumbs('All files')
103+
reloadCurrentFolder()
104104

105105
getRowForFileId(jpgFileId).invoke('attr', 'data-cy-files-list-row-name').should('equal', `${randomFileName}_moved.jpg`)
106106
getRowForFileId(movFileId).invoke('attr', 'data-cy-files-list-row-name').should('equal', `${randomFileName}_moved.mov`)
107107
})
108108

109109
it('Moves files when moving the .mov', () => {
110110
renameFile(`${randomFileName}.mov`, `${randomFileName}_moved.mov`)
111-
clickOnBreadcrumbs('All files')
111+
reloadCurrentFolder()
112112

113113
getRowForFileId(jpgFileId).invoke('attr', 'data-cy-files-list-row-name').should('equal', `${randomFileName}_moved.jpg`)
114114
getRowForFileId(movFileId).invoke('attr', 'data-cy-files-list-row-name').should('equal', `${randomFileName}_moved.mov`)
115115
})
116116

117117
it('Deletes files when deleting the .jpg', () => {
118118
triggerActionForFile(`${randomFileName}.jpg`, 'delete')
119-
clickOnBreadcrumbs('All files')
119+
reloadCurrentFolder()
120120

121121
getRowForFile(`${randomFileName}.jpg`).should('have.length', 0)
122122
getRowForFile(`${randomFileName}.mov`).should('have.length', 0)
@@ -129,7 +129,7 @@ describe('Files: Live photos', { testIsolation: true }, () => {
129129

130130
it('Block deletion when deleting the .mov', () => {
131131
triggerActionForFile(`${randomFileName}.mov`, 'delete')
132-
clickOnBreadcrumbs('All files')
132+
reloadCurrentFolder()
133133

134134
getRowForFile(`${randomFileName}.jpg`).should('have.length', 1)
135135
getRowForFile(`${randomFileName}.mov`).should('have.length', 1)
@@ -143,8 +143,9 @@ describe('Files: Live photos', { testIsolation: true }, () => {
143143
it('Restores files when restoring the .jpg', () => {
144144
triggerActionForFile(`${randomFileName}.jpg`, 'delete')
145145
cy.visit('/apps/files/trashbin')
146+
146147
triggerInlineActionForFileId(jpgFileId, 'restore')
147-
clickOnBreadcrumbs('Deleted files')
148+
reloadCurrentFolder()
148149

149150
getRowForFile(`${randomFileName}.jpg`).should('have.length', 0)
150151
getRowForFile(`${randomFileName}.mov`).should('have.length', 0)
@@ -158,8 +159,9 @@ describe('Files: Live photos', { testIsolation: true }, () => {
158159
it('Blocks restoration when restoring the .mov', () => {
159160
triggerActionForFile(`${randomFileName}.jpg`, 'delete')
160161
cy.visit('/apps/files/trashbin')
162+
161163
triggerInlineActionForFileId(movFileId, 'restore')
162-
clickOnBreadcrumbs('Deleted files')
164+
reloadCurrentFolder()
163165

164166
getRowForFileId(jpgFileId).should('have.length', 1)
165167
getRowForFileId(movFileId).should('have.length', 1)

0 commit comments

Comments
 (0)