diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2023-08-10 19:39:08 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2023-08-10 23:47:56 +0200 |
commit | 376f46e4755202da15ed7b1721d2bff618c6564d (patch) | |
tree | 58ba92eb92601895da3b9c38cb6302771de65bf3 | |
parent | 631a1f917bdae6f5a79116a1fa2220a24a2fbfd4 (diff) | |
download | nextcloud-server-376f46e4755202da15ed7b1721d2bff618c6564d.tar.gz nextcloud-server-376f46e4755202da15ed7b1721d2bff618c6564d.zip |
fix: Move broken filepicker selenium tests to cypress
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
-rw-r--r-- | cypress/e2e/files.cy.ts | 73 | ||||
-rw-r--r-- | tests/acceptance/features/app-files.feature | 64 | ||||
-rw-r--r-- | tests/acceptance/features/bootstrap/FilePickerContext.php | 10 |
3 files changed, 107 insertions, 40 deletions
diff --git a/cypress/e2e/files.cy.ts b/cypress/e2e/files.cy.ts index 7b3a4ff7a56..ab2c22a8776 100644 --- a/cypress/e2e/files.cy.ts +++ b/cypress/e2e/files.cy.ts @@ -19,19 +19,86 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ + +import type { User } from "@nextcloud/cypress" + +const startCopyMove = (file: string) => { + cy.get(`.files-fileList tr[data-file="${file}"`) + .find('.fileactions [data-action="menu"]') + .click() + cy.get('.fileActionsMenu .action-movecopy').click() +} + describe('Login with a new user and open the files app', function() { - before(function() { + let currentUser: User + beforeEach(function() { cy.createRandomUser().then((user) => { + currentUser = user cy.login(user) }) }) - after(function() { - cy.logout() + afterEach(function() { + cy.deleteUser(currentUser) + }) + + Cypress.on('uncaught:exception', (err) => { + // This can happen because of blink engine & skeleton animation, its not a bug just engine related. + if (err.message.includes('ResizeObserver loop limit exceeded')) { + return false + } }) it('See the default file welcome.txt in the files list', function() { cy.visit('/apps/files') cy.get('.files-fileList tr').should('contain', 'welcome.txt') }) + + it('Copy a file in its same folder', () => { + cy.visit('/apps/files') + // When I start the move or copy operation for "welcome.txt" + startCopyMove('welcome.txt') + // And I copy to the last selected folder in the file picker + cy.get('.dialog__actions button').contains('Copy').click() + // Then I see that the file list contains a file named "welcome.txt" + cy.get('.files-fileList tr').should('contain', 'welcome.txt') + // And I see that the file list contains a file named "welcome (copy).txt" + cy.get('.files-fileList tr').should('contain', 'welcome (copy).txt') + }) + + it('copy a file twice in its same folder', () => { + cy.visit('/apps/files') + // When I start the move or copy operation for "welcome.txt" + startCopyMove('welcome.txt') + // And I copy to the last selected folder in the file picker + cy.get('.dialog__actions button').contains('Copy').click() + // When I start the move or copy operation for "welcome.txt" + startCopyMove('welcome.txt') + // And I copy to the last selected folder in the file picker + cy.get('.dialog__actions button').contains('Copy').click() + // Then I see that the file list contains a file named "welcome.txt" + cy.get('.files-fileList tr').should('contain', 'welcome.txt') + // And I see that the file list contains a file named "welcome (copy).txt" + cy.get('.files-fileList tr').should('contain', 'welcome (copy).txt') + // And I see that the file list contains a file named "welcome (copy 2).txt" + cy.get('.files-fileList tr').should('contain', 'welcome (copy 2).txt') + }) + + it('copy a copy of a file in its same folder', () => { + cy.visit('/apps/files') + // When I start the move or copy operation for "welcome.txt" + startCopyMove('welcome.txt') + // And I copy to the last selected folder in the file picker + cy.get('.dialog__actions button').contains('Copy').click() + // When I start the move or copy operation for "welcome (copy).txt" + startCopyMove('welcome (copy).txt') + // And I copy to the last selected folder in the file picker + cy.get('.dialog__actions button').contains('Copy').click() + // Then I see that the file list contains a file named "welcome.txt" + cy.get('.files-fileList tr').should('contain', 'welcome.txt') + // And I see that the file list contains a file named "welcome (copy).txt" + cy.get('.files-fileList tr').should('contain', 'welcome (copy).txt') + // And I see that the file list contains a file named "welcome (copy 2).txt" + cy.get('.files-fileList tr').should('contain', 'welcome (copy 2).txt') + }) }) diff --git a/tests/acceptance/features/app-files.feature b/tests/acceptance/features/app-files.feature index 793504443da..f9db7cc8465 100644 --- a/tests/acceptance/features/app-files.feature +++ b/tests/acceptance/features/app-files.feature @@ -204,38 +204,38 @@ Feature: app-files # And I see that the file list contains a file named "Folder" # And I see that the file list contains a file named "Not selected folder" - Scenario: copy a file in its same folder - Given I am logged in - When I start the move or copy operation for "welcome.txt" - # No folder was explicitly selected, so the last selected folder is the - # current folder. - And I copy to the last selected folder in the file picker - Then I see that the file list contains a file named "welcome.txt" - And I see that the file list contains a file named "welcome (copy).txt" - - Scenario: copy a file twice in its same folder - Given I am logged in - And I start the move or copy operation for "welcome.txt" - # No folder was explicitly selected, so the last selected folder is the - # current folder. - And I copy to the last selected folder in the file picker - When I start the move or copy operation for "welcome.txt" - And I copy to the last selected folder in the file picker - Then I see that the file list contains a file named "welcome.txt" - And I see that the file list contains a file named "welcome (copy).txt" - And I see that the file list contains a file named "welcome (copy 2).txt" - - Scenario: copy a copy of a file in its same folder - Given I am logged in - And I start the move or copy operation for "welcome.txt" - # No folder was explicitly selected, so the last selected folder is the - # current folder. - And I copy to the last selected folder in the file picker - When I start the move or copy operation for "welcome (copy).txt" - And I copy to the last selected folder in the file picker - Then I see that the file list contains a file named "welcome.txt" - And I see that the file list contains a file named "welcome (copy).txt" - And I see that the file list contains a file named "welcome (copy 2).txt" +# Scenario: copy a file in its same folder +# Given I am logged in +# When I start the move or copy operation for "welcome.txt" +# # No folder was explicitly selected, so the last selected folder is the +# # current folder. +# And I copy to the last selected folder in the file picker +# Then I see that the file list contains a file named "welcome.txt" +# And I see that the file list contains a file named "welcome (copy).txt" +# +# Scenario: copy a file twice in its same folder +# Given I am logged in +# And I start the move or copy operation for "welcome.txt" +# # No folder was explicitly selected, so the last selected folder is the +# # current folder. +# And I copy to the last selected folder in the file picker +# When I start the move or copy operation for "welcome.txt" +# And I copy to the last selected folder in the file picker +# Then I see that the file list contains a file named "welcome.txt" +# And I see that the file list contains a file named "welcome (copy).txt" +# And I see that the file list contains a file named "welcome (copy 2).txt" +# +# Scenario: copy a copy of a file in its same folder +# Given I am logged in +# And I start the move or copy operation for "welcome.txt" +# # No folder was explicitly selected, so the last selected folder is the +# # current folder. +# And I copy to the last selected folder in the file picker +# When I start the move or copy operation for "welcome (copy).txt" +# And I copy to the last selected folder in the file picker +# Then I see that the file list contains a file named "welcome.txt" +# And I see that the file list contains a file named "welcome (copy).txt" +# And I see that the file list contains a file named "welcome (copy 2).txt" # Scenario: rename a file with the details view open # Given I am logged in diff --git a/tests/acceptance/features/bootstrap/FilePickerContext.php b/tests/acceptance/features/bootstrap/FilePickerContext.php index b9d82090eaa..bed0ee9e566 100644 --- a/tests/acceptance/features/bootstrap/FilePickerContext.php +++ b/tests/acceptance/features/bootstrap/FilePickerContext.php @@ -30,7 +30,7 @@ class FilePickerContext implements Context, ActorAwareInterface { * @return Locator */ public static function dialog() { - return Locator::forThe()->css(".oc-dialog")-> + return Locator::forThe()->css(".modal-container")-> describedAs("File picker dialog"); } @@ -38,7 +38,7 @@ class FilePickerContext implements Context, ActorAwareInterface { * @return Locator */ public static function fileListContainer() { - return Locator::forThe()->css("#oc-dialog-filepicker-content")-> + return Locator::forThe()->css(".file-picker__files")-> descendantOf(self::dialog())-> describedAs("File list container in the file picker dialog"); } @@ -49,7 +49,7 @@ class FilePickerContext implements Context, ActorAwareInterface { public static function rowForFile($fileName) { // File names in the file picker are split in two span elements, so // their texts need to be concatenated to get the full file name. - return Locator::forThe()->xpath("//*[@id = 'picker-filestable']//*[contains(concat(' ', normalize-space(@class), ' '), ' filename-parts ') and concat(span[1], span[2]) = '$fileName']/ancestor::tr")-> + return Locator::forThe()->xpath("//*[concat(span[1], span[2]) = '$fileName']/ancestor::tr")-> descendantOf(self::fileListContainer())-> describedAs("Row for file $fileName in the file picker dialog"); } @@ -58,7 +58,7 @@ class FilePickerContext implements Context, ActorAwareInterface { * @return Locator */ public static function buttonRow() { - return Locator::forThe()->css(".oc-dialog-buttonrow")-> + return Locator::forThe()->css(".dialog__actions")-> descendantOf(self::dialog())-> describedAs("Button row in the file picker dialog"); } @@ -69,7 +69,7 @@ class FilePickerContext implements Context, ActorAwareInterface { private static function buttonFor($buttonText) { // "Copy" and "Move" buttons text is set to "Copy to XXX" and "Move to // XXX" when a folder is selected. - return Locator::forThe()->xpath("//button[starts-with(normalize-space(), '$buttonText')]")-> + return Locator::forThe()->xpath("//button[contains(normalize-space(), '$buttonText')]")-> descendantOf(self::buttonRow())-> describedAs($buttonText . " button in the file picker dialog"); } |