mirror of
https://github.com/nextcloud/server.git
synced 2026-02-20 00:12:30 -05:00
test(files): Add move and copy utils for e2e tests
Signed-off-by: Louis Chemineau <louis@chmn.me>
This commit is contained in:
parent
ebff12f60e
commit
83d08a293a
2 changed files with 69 additions and 70 deletions
|
|
@ -30,3 +30,61 @@ export const triggerActionForFile = (filename: string, actionId: string) => {
|
|||
getActionButtonForFile(filename).click()
|
||||
cy.get(`[data-cy-files-list-row-action="${CSS.escape(actionId)}"] > button`).should('exist').click()
|
||||
}
|
||||
|
||||
export const moveFile = (fileName: string, dirName: string) => {
|
||||
getRowForFile(fileName).should('be.visible')
|
||||
triggerActionForFile(fileName, 'move-copy')
|
||||
|
||||
cy.get('.file-picker').within(() => {
|
||||
// intercept the copy so we can wait for it
|
||||
cy.intercept('MOVE', /\/remote.php\/dav\/files\//).as('moveFile')
|
||||
|
||||
if (dirName === '/') {
|
||||
// select home folder
|
||||
cy.get('button[title="Home"]').should('be.visible').click()
|
||||
// click move
|
||||
cy.contains('button', 'Move').should('be.visible').click()
|
||||
} else if (dirName === '.') {
|
||||
// click move
|
||||
cy.contains('button', 'Copy').should('be.visible').click()
|
||||
} else {
|
||||
// select the folder
|
||||
cy.get(`[data-filename="${dirName}"]`).should('be.visible').click()
|
||||
// click move
|
||||
cy.contains('button', `Move to ${dirName}`).should('be.visible').click()
|
||||
}
|
||||
|
||||
cy.wait('@moveFile')
|
||||
})
|
||||
}
|
||||
|
||||
export const copyFile = (fileName: string, dirName: string) => {
|
||||
getRowForFile(fileName).should('be.visible')
|
||||
triggerActionForFile(fileName, 'move-copy')
|
||||
|
||||
cy.get('.file-picker').within(() => {
|
||||
// intercept the copy so we can wait for it
|
||||
cy.intercept('COPY', /\/remote.php\/dav\/files\//).as('copyFile')
|
||||
|
||||
if (dirName === '/') {
|
||||
// select home folder
|
||||
cy.get('button[title="Home"]').should('be.visible').click()
|
||||
// click copy
|
||||
cy.contains('button', 'Copy').should('be.visible').click()
|
||||
} else if (dirName === '.') {
|
||||
// click copy
|
||||
cy.contains('button', 'Copy').should('be.visible').click()
|
||||
} else {
|
||||
// select folder
|
||||
cy.get(`[data-filename="${dirName}"]`).should('be.visible').click()
|
||||
// click copy
|
||||
cy.contains('button', `Copy to ${dirName}`).should('be.visible').click()
|
||||
}
|
||||
|
||||
cy.wait('@copyFile')
|
||||
})
|
||||
}
|
||||
|
||||
export const navigateToFolder = (folderName: string) => {
|
||||
getRowForFile(folderName).should('be.visible').find('[data-cy-files-list-row-name-link]').click()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
import { getRowForFile, triggerActionForFile } from './FilesUtils.ts'
|
||||
import { getRowForFile, moveFile, copyFile, navigateToFolder } from './FilesUtils.ts'
|
||||
|
||||
describe('Files: Move or copy files', { testIsolation: true }, () => {
|
||||
let currentUser
|
||||
|
|
@ -42,22 +42,9 @@ describe('Files: Move or copy files', { testIsolation: true }, () => {
|
|||
cy.login(currentUser)
|
||||
cy.visit('/apps/files')
|
||||
|
||||
// intercept the copy so we can wait for it
|
||||
cy.intercept('COPY', /\/remote.php\/dav\/files\//).as('copyFile')
|
||||
copyFile('original.txt', 'new-folder')
|
||||
|
||||
// Open actions and trigger copy-move action
|
||||
getRowForFile('original.txt').should('be.visible')
|
||||
triggerActionForFile('original.txt', 'move-copy')
|
||||
|
||||
// select new folder
|
||||
cy.get('.file-picker [data-filename="new-folder"]').should('be.visible').click()
|
||||
// click copy
|
||||
cy.get('.file-picker').contains('button', 'Copy to new-folder').should('be.visible').click()
|
||||
|
||||
// wait for copy to finish
|
||||
cy.wait('@copyFile')
|
||||
|
||||
getRowForFile('new-folder').find('[data-cy-files-list-row-name-link]').click()
|
||||
navigateToFolder('new-folder')
|
||||
|
||||
cy.url().should('contain', 'dir=/new-folder')
|
||||
getRowForFile('original.txt').should('be.visible')
|
||||
|
|
@ -70,24 +57,14 @@ describe('Files: Move or copy files', { testIsolation: true }, () => {
|
|||
cy.login(currentUser)
|
||||
cy.visit('/apps/files')
|
||||
|
||||
// intercept the copy so we can wait for it
|
||||
cy.intercept('MOVE', /\/remote.php\/dav\/files\//).as('moveFile')
|
||||
moveFile('original.txt', 'new-folder')
|
||||
|
||||
getRowForFile('original.txt').should('be.visible')
|
||||
triggerActionForFile('original.txt', 'move-copy')
|
||||
|
||||
// select new folder
|
||||
cy.get('.file-picker [data-filename="new-folder"]').should('be.visible').click()
|
||||
// click copy
|
||||
cy.get('.file-picker').contains('button', 'Move to new-folder').should('be.visible').click()
|
||||
|
||||
cy.wait('@moveFile')
|
||||
// wait until visible again
|
||||
getRowForFile('new-folder').should('be.visible')
|
||||
|
||||
// original should be moved -> not exist anymore
|
||||
getRowForFile('original.txt').should('not.exist')
|
||||
getRowForFile('new-folder').should('be.visible').find('[data-cy-files-list-row-name-link]').click()
|
||||
navigateToFolder('new-folder')
|
||||
|
||||
cy.url().should('contain', 'dir=/new-folder')
|
||||
getRowForFile('original.txt').should('be.visible')
|
||||
|
|
@ -101,24 +78,14 @@ describe('Files: Move or copy files', { testIsolation: true }, () => {
|
|||
cy.login(currentUser)
|
||||
cy.visit('/apps/files')
|
||||
|
||||
// intercept the copy so we can wait for it
|
||||
cy.intercept('MOVE', /\/remote.php\/dav\/files\//).as('moveFile')
|
||||
moveFile('original', 'original folder')
|
||||
|
||||
getRowForFile('original').should('be.visible')
|
||||
triggerActionForFile('original', 'move-copy')
|
||||
|
||||
// select new folder
|
||||
cy.get('.file-picker [data-filename="original folder"]').should('be.visible').click()
|
||||
// click copy
|
||||
cy.get('.file-picker').contains('button', 'Move to original folder').should('be.visible').click()
|
||||
|
||||
cy.wait('@moveFile')
|
||||
// wait until visible again
|
||||
getRowForFile('original folder').should('be.visible')
|
||||
|
||||
// original should be moved -> not exist anymore
|
||||
getRowForFile('original').should('not.exist')
|
||||
getRowForFile('original folder').should('be.visible').find('[data-cy-files-list-row-name-link]').click()
|
||||
navigateToFolder('original folder')
|
||||
|
||||
cy.url().should('contain', 'dir=/original%20folder')
|
||||
getRowForFile('original').should('be.visible')
|
||||
|
|
@ -131,21 +98,11 @@ describe('Files: Move or copy files', { testIsolation: true }, () => {
|
|||
cy.login(currentUser)
|
||||
cy.visit('/apps/files')
|
||||
|
||||
// intercept the copy so we can wait for it
|
||||
cy.intercept('MOVE', /\/remote.php\/dav\/files\//).as('moveFile')
|
||||
|
||||
getRowForFile('new-folder').should('be.visible').find('[data-cy-files-list-row-name-link]').click()
|
||||
navigateToFolder('new-folder')
|
||||
cy.url().should('contain', 'dir=/new-folder')
|
||||
|
||||
getRowForFile('original.txt').should('be.visible')
|
||||
triggerActionForFile('original.txt', 'move-copy')
|
||||
moveFile('original.txt', '/')
|
||||
|
||||
// select new folder
|
||||
cy.get('.file-picker button[title="Home"]').should('be.visible').click()
|
||||
// click move
|
||||
cy.get('.file-picker').contains('button', 'Move').should('be.visible').click()
|
||||
|
||||
cy.wait('@moveFile')
|
||||
// wait until visible again
|
||||
cy.get('main').contains('No files in here').should('be.visible')
|
||||
|
||||
|
|
@ -162,16 +119,8 @@ describe('Files: Move or copy files', { testIsolation: true }, () => {
|
|||
cy.login(currentUser)
|
||||
cy.visit('/apps/files')
|
||||
|
||||
// intercept the copy so we can wait for it
|
||||
cy.intercept('COPY', /\/remote.php\/dav\/files\//).as('copyFile')
|
||||
copyFile('original.txt', '.')
|
||||
|
||||
getRowForFile('original.txt').should('be.visible')
|
||||
triggerActionForFile('original.txt', 'move-copy')
|
||||
|
||||
// click copy
|
||||
cy.get('.file-picker').contains('button', 'Copy').should('be.visible').click()
|
||||
|
||||
cy.wait('@copyFile')
|
||||
getRowForFile('original.txt').should('be.visible')
|
||||
getRowForFile('original (copy).txt').should('be.visible')
|
||||
})
|
||||
|
|
@ -182,16 +131,8 @@ describe('Files: Move or copy files', { testIsolation: true }, () => {
|
|||
cy.login(currentUser)
|
||||
cy.visit('/apps/files')
|
||||
|
||||
// intercept the copy so we can wait for it
|
||||
cy.intercept('COPY', /\/remote.php\/dav\/files\//).as('copyFile')
|
||||
copyFile('original.txt', '.')
|
||||
|
||||
getRowForFile('original.txt').should('be.visible')
|
||||
triggerActionForFile('original.txt', 'move-copy')
|
||||
|
||||
// click copy
|
||||
cy.get('.file-picker').contains('button', 'Copy').should('be.visible').click()
|
||||
|
||||
cy.wait('@copyFile')
|
||||
getRowForFile('original.txt').should('be.visible')
|
||||
getRowForFile('original (copy 2).txt').should('be.visible')
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue