Skip to content

Commit

Permalink
test: Fix cypress utils to wait for HTTP requests before continue
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Jul 12, 2024
1 parent 0c0b53d commit c91577d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cypress/e2e/filesUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,32 @@ export function renameFile(fileName: string, newName: string) {

export function goToDir(dirName: string) {
cy.get(`[data-cy-files-list] [data-cy-files-list-row-name="${dirName}"]`).click()
cy.wait(500)
cy.url().should('match', new RegExp(`\\?dir=(.*/)?${encodeURI(dirName)}`))
}

export function createFolder (dirName: string) {
cy.intercept('MKCOL', '**/remote.php/dav/files/**').as('mkdir')

cy.get('.files-list__header .breadcrumb__actions button.action-item__menutoggle').click()
cy.get('.v-popper__popper').contains('New folder').click()
cy.contains('Folder name').siblings('input').clear()
cy.contains('Folder name').siblings('input').type(`${dirName}{enter}`)

cy.wait('@mkdir')
cy.log('Created folder', dirName)
cy.wait(500)
}

export function moveFile (fileName: string, dirName: string) {
cy.intercept('MOVE', '**/remote.php/dav/files/**').as('moveFile')

toggleMenuAction(fileName)
cy.get(`[data-cy-files-list] [data-cy-files-list-row-action="move-copy"]`).click()
cy.get('.file-picker').within(() => {
cy.get(`[data-filename="${dirName}"]`).click()
cy.contains(`Move to ${dirName}`).click()
cy.wait(500)
})

cy.wait('@moveFile')
}

export function toggleMenuAction(fileName: string) {
Expand Down

0 comments on commit c91577d

Please sign in to comment.