Skip to content

Commit 0e8599c

Browse files
committed
test: adjust cypress tests
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 15b82d2 commit 0e8599c

4 files changed

Lines changed: 30 additions & 22 deletions

File tree

cypress.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ export default defineConfig({
2525
viewportWidth: 1280,
2626
viewportHeight: 720,
2727

28-
// Tries again 2 more times on failure
28+
// Tries again when in run mode (cypress run) e.g. on CI
2929
retries: {
30-
runMode: 2,
30+
runMode: 3,
3131
// do not retry in `cypress open`
3232
openMode: 0,
3333
},

cypress/e2e/files/FilesUtils.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ export const getActionButtonForFile = (filename: string) => getActionsForFile(fi
2424
export function getActionEntryForFileId(fileid: number, actionId: string) {
2525
return getActionButtonForFileId(fileid)
2626
.should('have.attr', 'aria-controls')
27-
.then((menuId) => cy.get(`#${menuId}`).find(`[data-cy-files-list-row-action="${CSS.escape(actionId)}"]`))
27+
.then((menuId) => cy.get(`#${menuId}`)
28+
.should('exist')
29+
.find(`[data-cy-files-list-row-action="${CSS.escape(actionId)}"]`))
2830
}
2931

3032
/**
@@ -33,12 +35,11 @@ export function getActionEntryForFileId(fileid: number, actionId: string) {
3335
* @param actionId
3436
*/
3537
export function getActionEntryForFile(file: string, actionId: string) {
36-
getActionButtonForFile(file)
37-
.if('not.have.attr', 'aria-expanded', 'true')
38-
.click({ force: true })
39-
40-
return cy.findByRole('menu')
41-
.find(`[data-cy-files-list-row-action="${CSS.escape(actionId)}"]`)
38+
return getActionButtonForFile(file)
39+
.should('have.attr', 'aria-controls')
40+
.then((menuId) => cy.get(`#${menuId}`)
41+
.should('exist')
42+
.find(`[data-cy-files-list-row-action="${CSS.escape(actionId)}"]`))
4243
}
4344

4445
/**
@@ -85,8 +86,10 @@ export function triggerActionForFileId(fileid: number, actionId: string) {
8586
*/
8687
export function triggerActionForFile(filename: string, actionId: string) {
8788
getActionButtonForFile(filename)
88-
.should('have.attr', 'aria-expanded', 'false')
89-
.click({ force: true, scrollBehavior: 'nearest' }) // force to avoid issues with overlaying file list header
89+
.as('actionButton')
90+
.scrollIntoView()
91+
cy.get('@actionButton')
92+
.click({ force: true }) // force to avoid issues with overlaying file list header
9093
getActionEntryForFile(filename, actionId)
9194
.find('button')
9295
.should('be.visible')
@@ -290,7 +293,12 @@ export function closeSidebar() {
290293
cy.get('[data-cy-sidebar]')
291294
.should('not.be.visible')
292295
// eslint-disable-next-line cypress/no-unnecessary-waiting -- wait for the animation to finish
293-
cy.wait(300)
296+
cy.wait(500)
297+
// close all toasts
298+
cy.get('.toast-success')
299+
.if()
300+
.findAllByRole('button')
301+
.click({ force: true, multiple: true })
294302
}
295303

296304
/**

cypress/e2e/files_sharing/FilesSharingUtils.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,8 @@ export function createShare(fileName: string, username: string, shareSettings: P
3232
// HACK: Save the share and then update it, as permissions changes are currently not saved for new share.
3333
cy.get('[data-cy-files-sharing-share-editor-action="save"]').click({ scrollBehavior: 'nearest' })
3434
cy.wait('@createShare')
35-
cy.get('.toast-success')
36-
.findAllByRole('button')
37-
.click({ force: true, multiple: true })
38-
3935
closeSidebar()
36+
4037
updateShare(fileName, 0, shareSettings)
4138
}
4239

@@ -135,10 +132,7 @@ export function updateShare(fileName: string, index: number, shareSettings: Part
135132

136133
cy.wait('@updateShare')
137134
})
138-
// close all toasts
139-
cy.get('.toast-success')
140-
.findAllByRole('button')
141-
.click({ force: true, multiple: true })
135+
closeSidebar()
142136
}
143137

144138
export function openSharingPanel(fileName: string) {

cypress/e2e/files_versions/version_naming.cy.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,14 @@ describe('Versions naming', () => {
6868
setupTestSharedFileFromUser(user, randomFileName, { update: false })
6969
openVersionsPanel(randomFileName)
7070

71-
cy.get('[data-files-versions-version]').eq(0).find('.action-item__menutoggle').should('not.exist')
72-
cy.get('[data-files-versions-version]').eq(0).get('[data-cy-version-action="label"]').should('not.exist')
71+
cy.get('[data-files-versions-version]')
72+
.eq(0)
73+
.as('firstVersion')
74+
.find('.action-item__menutoggle')
75+
.should('not.exist')
76+
cy.get('@firstVersion')
77+
.find('[data-cy-version-action="label"]')
78+
.should('not.exist')
7379

7480
doesNotHaveAction(1, 'label')
7581
doesNotHaveAction(2, 'label')

0 commit comments

Comments
 (0)