|
19 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 | 20 | * |
21 | 21 | */ |
| 22 | + |
| 23 | +import type { User } from "@nextcloud/cypress" |
| 24 | + |
| 25 | +const startCopyMove = (file: string) => { |
| 26 | + cy.get(`.files-fileList tr[data-file="${file}"`) |
| 27 | + .find('.fileactions [data-action="menu"]') |
| 28 | + .click() |
| 29 | + cy.get('.fileActionsMenu .action-movecopy').click() |
| 30 | +} |
| 31 | + |
22 | 32 | describe('Login with a new user and open the files app', function() { |
23 | | - before(function() { |
| 33 | + let currentUser: User |
| 34 | + beforeEach(function() { |
24 | 35 | cy.createRandomUser().then((user) => { |
| 36 | + currentUser = user |
25 | 37 | cy.login(user) |
26 | 38 | }) |
27 | 39 | }) |
28 | 40 |
|
29 | | - after(function() { |
30 | | - cy.logout() |
| 41 | + afterEach(function() { |
| 42 | + cy.deleteUser(currentUser) |
| 43 | + }) |
| 44 | + |
| 45 | + Cypress.on('uncaught:exception', (err) => { |
| 46 | + // This can happen because of blink engine & skeleton animation, its not a bug just engine related. |
| 47 | + if (err.message.includes('ResizeObserver loop limit exceeded')) { |
| 48 | + return false |
| 49 | + } |
31 | 50 | }) |
32 | 51 |
|
33 | 52 | it('See the default file welcome.txt in the files list', function() { |
34 | 53 | cy.visit('/apps/files') |
35 | 54 | cy.get('.files-fileList tr').should('contain', 'welcome.txt') |
36 | 55 | }) |
| 56 | + |
| 57 | + it('Copy a file in its same folder', () => { |
| 58 | + cy.visit('/apps/files') |
| 59 | + // When I start the move or copy operation for "welcome.txt" |
| 60 | + startCopyMove('welcome.txt') |
| 61 | + // And I copy to the last selected folder in the file picker |
| 62 | + cy.get('.dialog__actions button').contains('Copy').click() |
| 63 | + // Then I see that the file list contains a file named "welcome.txt" |
| 64 | + cy.get('.files-fileList tr').should('contain', 'welcome.txt') |
| 65 | + // And I see that the file list contains a file named "welcome (copy).txt" |
| 66 | + cy.get('.files-fileList tr').should('contain', 'welcome (copy).txt') |
| 67 | + }) |
| 68 | + |
| 69 | + it('copy a file twice in its same folder', () => { |
| 70 | + cy.visit('/apps/files') |
| 71 | + // When I start the move or copy operation for "welcome.txt" |
| 72 | + startCopyMove('welcome.txt') |
| 73 | + // And I copy to the last selected folder in the file picker |
| 74 | + cy.get('.dialog__actions button').contains('Copy').click() |
| 75 | + // When I start the move or copy operation for "welcome.txt" |
| 76 | + startCopyMove('welcome.txt') |
| 77 | + // And I copy to the last selected folder in the file picker |
| 78 | + cy.get('.dialog__actions button').contains('Copy').click() |
| 79 | + // Then I see that the file list contains a file named "welcome.txt" |
| 80 | + cy.get('.files-fileList tr').should('contain', 'welcome.txt') |
| 81 | + // And I see that the file list contains a file named "welcome (copy).txt" |
| 82 | + cy.get('.files-fileList tr').should('contain', 'welcome (copy).txt') |
| 83 | + // And I see that the file list contains a file named "welcome (copy 2).txt" |
| 84 | + cy.get('.files-fileList tr').should('contain', 'welcome (copy 2).txt') |
| 85 | + }) |
| 86 | + |
| 87 | + it('copy a copy of a file in its same folder', () => { |
| 88 | + cy.visit('/apps/files') |
| 89 | + // When I start the move or copy operation for "welcome.txt" |
| 90 | + startCopyMove('welcome.txt') |
| 91 | + // And I copy to the last selected folder in the file picker |
| 92 | + cy.get('.dialog__actions button').contains('Copy').click() |
| 93 | + // When I start the move or copy operation for "welcome (copy).txt" |
| 94 | + startCopyMove('welcome (copy).txt') |
| 95 | + // And I copy to the last selected folder in the file picker |
| 96 | + cy.get('.dialog__actions button').contains('Copy').click() |
| 97 | + // Then I see that the file list contains a file named "welcome.txt" |
| 98 | + cy.get('.files-fileList tr').should('contain', 'welcome.txt') |
| 99 | + // And I see that the file list contains a file named "welcome (copy).txt" |
| 100 | + cy.get('.files-fileList tr').should('contain', 'welcome (copy).txt') |
| 101 | + // And I see that the file list contains a file named "welcome (copy 2).txt" |
| 102 | + cy.get('.files-fileList tr').should('contain', 'welcome (copy 2).txt') |
| 103 | + }) |
37 | 104 | }) |
0 commit comments