1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
/**
* @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', function() {
let currentUser: User
beforeEach(function() {
cy.createRandomUser().then((user) => {
currentUser = user
cy.login(user)
})
})
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')
})
})
|