Skip to content

Commit 5d2d343

Browse files
authored
Merge pull request #2559 from nextcloud/fix/cypress-stability
test(cypress): improve e2e test stability
2 parents b008de6 + c469007 commit 5d2d343

4 files changed

Lines changed: 16 additions & 11 deletions

File tree

cypress/e2e/filesUtils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ export function toggleMenuAction(filename: string, action: 'details'|'favorite'|
130130
.find('[data-cy-files-list-row-actions]')
131131
.findByRole('button', { name: 'Actions' })
132132
.should('be.visible')
133-
.click()
133+
.click({ force: true })
134134

135-
cy.get(`[data-cy-files-list-row-action="${CSS.escape(action)}"]`)
135+
cy.get(`[data-cy-files-list-row-action="${CSS.escape(action)}"]`, { timeout: 10000 })
136136
.should('be.visible')
137137
.findByRole('menuitem')
138-
.click()
138+
.click({ force: true })
139139
}

cypress/e2e/settings.cy.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ describe('Check that user\'s settings survive a reload', () => {
1919
})
2020

2121
it('Form survive a reload', () => {
22+
cy.intercept({ method: 'POST', url: '**/activity/settings' }).as('apiCall')
23+
2224
cy.get("#app-content input[type='checkbox']").uncheck({ force: true })
2325
cy.get("#app-content input[type='checkbox']").should('not.be.checked')
26+
cy.wait('@apiCall')
2427

2528
cy.reload()
2629

@@ -34,6 +37,7 @@ describe('Check that user\'s settings survive a reload', () => {
3437
cy.get('#calendar_notification').check({ force: true })
3538
cy.get('#personal_settings_email').check({ force: true })
3639
cy.get('#personal_settings_notification').check({ force: true })
40+
cy.wait('@apiCall')
3741
cy.reload()
3842

3943
cy.get('#file_changed_email').should('not.be.checked')

cypress/e2e/sidebar.cy.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ describe('Check activity listing in the sidebar', { testIsolation: true }, () =>
3838

3939
it('Has share activity', () => {
4040
createPublicShare('welcome.txt')
41-
cy.visit('/apps/files')
42-
getFileListRow('welcome.txt').should('be.visible')
43-
41+
// No re-navigation needed — createPublicShare already waits for the share API
42+
// and closes the sidebar, so the activity is recorded and the page is stable.
43+
// Re-navigating triggers an async share-badge update that closes the Actions menu.
4444
showActivityTab('welcome.txt')
4545
cy.get('.activity-entry').first().should('contains.text', 'Shared as public link')
4646
})

cypress/e2e/sidebarUtils.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6-
import { toggleMenuAction, triggerActionForFile } from './filesUtils.ts'
6+
import { getRowForFile, toggleMenuAction, triggerActionForFile } from './filesUtils.ts'
77

88
function showSidebarForFile(fileName: string) {
99
toggleMenuAction(fileName, 'details')
@@ -60,8 +60,6 @@ export function toggleFavorite(fileName: string) {
6060
* @param fileName Name of the file to share
6161
*/
6262
export function createPublicShare(fileName: string) {
63-
cy.intercept('POST', '/ocs/v2.php/apps/files_sharing/api/v1/shares').as('createPublicShare')
64-
6563
showSidebarForFile(fileName)
6664
cy.get('#app-sidebar-vue')
6765
.findByRole('tab', { name: 'Sharing' })
@@ -77,8 +75,6 @@ export function createPublicShare(fileName: string) {
7775

7876
cy.wait('@createShare')
7977
closeSidebar()
80-
81-
cy.wait('@createPublicShare')
8278
}
8379

8480
/**
@@ -88,6 +84,11 @@ export function createPublicShare(fileName: string) {
8884
* @param newTag - The new tag
8985
*/
9086
export function addTag(fileName: string, newTag: string) {
87+
getRowForFile(fileName)
88+
.should('be.visible')
89+
.find('.files-list__row-icon-preview--loaded')
90+
.should('exist')
91+
9192
triggerActionForFile(fileName, 'systemtags:bulk')
9293

9394
cy.intercept('POST', '/remote.php/dav/systemtags').as('createTag')

0 commit comments

Comments
 (0)