123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- /**
- * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
- *
- * @author John Molakvoæ <skjnldsv@protonmail.com>
- *
- * @license AGPL-3.0-or-later
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * 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', { testIsolation: false }, function() {
- before(function() {
- cy.createRandomUser().then((user) => {
- cy.login(user)
- })
- })
- 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('See the file list sorting order is saved', function() {
- cy.intercept('PUT', /api\/v1\/views\/files\/sorting_direction$/).as('sorting_direction')
- cy.intercept('PUT', /api\/v1\/views\/files\/sorting_mode$/).as('sorting_mode')
- cy.visit('/apps/files')
- // default to sorting by name
- cy.get('.files-filestable th.column-name .sort-indicator').should('be.visible')
- cy.get('.files-filestable th.column-size .sort-indicator').should('not.be.visible')
- // change to size
- cy.get('.files-filestable th').contains('Size').click()
- // size sorting should be active
- cy.get('.files-filestable th.column-name .sort-indicator').should('not.be.visible')
- cy.get('.files-filestable th.column-size .sort-indicator').should('be.visible')
- cy.wait('@sorting_direction')
- cy.wait('@sorting_mode')
- // Re-visit
- cy.reload()
- cy.get('.files-fileList tr').should('contain', 'welcome.txt')
- // now sorting by name should be disabled and sorting by size should be enabled
- cy.get('.files-filestable th.column-name .sort-indicator').should('not.be.visible')
- cy.get('.files-filestable th.column-size .sort-indicator').should('be.visible')
- })
- })
- describe('Testing the copy move action (FilePicker)', () => {
- let currentUser: User
- beforeEach(function() {
- cy.createRandomUser().then((user) => {
- currentUser = user
- cy.login(user)
- })
- })
- afterEach(function() {
- cy.deleteUser(currentUser)
- })
- it('Copy a file in its same folder', () => {
- cy.visit('/apps/files')
- cy.intercept('COPY', /\/remote.php\/dav\/files\//).as('copyFile')
- // 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()
- cy.wait('@copyFile')
- // 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')
- cy.intercept('COPY', /\/remote.php\/dav\/files\//).as('copyFile')
- // 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()
- cy.wait('@copyFile')
- // 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()
- cy.wait('@copyFile')
- // 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')
- cy.intercept('COPY', /\/remote.php\/dav\/files\//).as('copyFile')
- // 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()
- cy.wait('@copyFile')
- // 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()
- cy.wait('@copyFile')
- // 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')
- })
- })
|