aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cypress/e2e/files/FilesUtils.ts58
-rw-r--r--cypress/e2e/files/files_copy-move.cy.ts81
2 files changed, 69 insertions, 70 deletions
diff --git a/cypress/e2e/files/FilesUtils.ts b/cypress/e2e/files/FilesUtils.ts
index 0bad38693ae..7f61584bcde 100644
--- a/cypress/e2e/files/FilesUtils.ts
+++ b/cypress/e2e/files/FilesUtils.ts
@@ -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()
+}
diff --git a/cypress/e2e/files/files_copy-move.cy.ts b/cypress/e2e/files/files_copy-move.cy.ts
index 9fee5eb44d5..823e8b9c38b 100644
--- a/cypress/e2e/files/files_copy-move.cy.ts
+++ b/cypress/e2e/files/files_copy-move.cy.ts
@@ -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')
-
- 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()
+ moveFile('original.txt', 'new-folder')
- 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')
-
- 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()
+ moveFile('original', 'original folder')
- 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')
-
- // 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()
+ moveFile('original.txt', '/')
- cy.wait('@moveFile')
// wait until visible again
cy.get('main').contains('No files in here').should('be.visible')
@@ -162,17 +119,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', '.')
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')
-
- getRowForFile('original.txt').should('be.visible')
- triggerActionForFile('original.txt', 'move-copy')
-
- // click copy
- cy.get('.file-picker').contains('button', 'Copy').should('be.visible').click()
+ copyFile('original.txt', '.')
- cy.wait('@copyFile')
getRowForFile('original.txt').should('be.visible')
getRowForFile('original (copy 2).txt').should('be.visible')
})