Skip to content

Commit 376f46e

Browse files
committed
fix: Move broken filepicker selenium tests to cypress
Signed-off-by: Ferdinand Thiessen <[email protected]>
1 parent 631a1f9 commit 376f46e

File tree

3 files changed

+107
-40
lines changed

3 files changed

+107
-40
lines changed

cypress/e2e/files.cy.ts

Lines changed: 70 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,86 @@
1919
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2020
*
2121
*/
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+
2232
describe('Login with a new user and open the files app', function() {
23-
before(function() {
33+
let currentUser: User
34+
beforeEach(function() {
2435
cy.createRandomUser().then((user) => {
36+
currentUser = user
2537
cy.login(user)
2638
})
2739
})
2840

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+
}
3150
})
3251

3352
it('See the default file welcome.txt in the files list', function() {
3453
cy.visit('/apps/files')
3554
cy.get('.files-fileList tr').should('contain', 'welcome.txt')
3655
})
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+
})
37104
})

tests/acceptance/features/app-files.feature

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -204,38 +204,38 @@ Feature: app-files
204204
# And I see that the file list contains a file named "Folder"
205205
# And I see that the file list contains a file named "Not selected folder"
206206

207-
Scenario: copy a file in its same folder
208-
Given I am logged in
209-
When I start the move or copy operation for "welcome.txt"
210-
# No folder was explicitly selected, so the last selected folder is the
211-
# current folder.
212-
And I copy to the last selected folder in the file picker
213-
Then I see that the file list contains a file named "welcome.txt"
214-
And I see that the file list contains a file named "welcome (copy).txt"
215-
216-
Scenario: copy a file twice in its same folder
217-
Given I am logged in
218-
And I start the move or copy operation for "welcome.txt"
219-
# No folder was explicitly selected, so the last selected folder is the
220-
# current folder.
221-
And I copy to the last selected folder in the file picker
222-
When I start the move or copy operation for "welcome.txt"
223-
And I copy to the last selected folder in the file picker
224-
Then I see that the file list contains a file named "welcome.txt"
225-
And I see that the file list contains a file named "welcome (copy).txt"
226-
And I see that the file list contains a file named "welcome (copy 2).txt"
227-
228-
Scenario: copy a copy of a file in its same folder
229-
Given I am logged in
230-
And I start the move or copy operation for "welcome.txt"
231-
# No folder was explicitly selected, so the last selected folder is the
232-
# current folder.
233-
And I copy to the last selected folder in the file picker
234-
When I start the move or copy operation for "welcome (copy).txt"
235-
And I copy to the last selected folder in the file picker
236-
Then I see that the file list contains a file named "welcome.txt"
237-
And I see that the file list contains a file named "welcome (copy).txt"
238-
And I see that the file list contains a file named "welcome (copy 2).txt"
207+
# Scenario: copy a file in its same folder
208+
# Given I am logged in
209+
# When I start the move or copy operation for "welcome.txt"
210+
# # No folder was explicitly selected, so the last selected folder is the
211+
# # current folder.
212+
# And I copy to the last selected folder in the file picker
213+
# Then I see that the file list contains a file named "welcome.txt"
214+
# And I see that the file list contains a file named "welcome (copy).txt"
215+
#
216+
# Scenario: copy a file twice in its same folder
217+
# Given I am logged in
218+
# And I start the move or copy operation for "welcome.txt"
219+
# # No folder was explicitly selected, so the last selected folder is the
220+
# # current folder.
221+
# And I copy to the last selected folder in the file picker
222+
# When I start the move or copy operation for "welcome.txt"
223+
# And I copy to the last selected folder in the file picker
224+
# Then I see that the file list contains a file named "welcome.txt"
225+
# And I see that the file list contains a file named "welcome (copy).txt"
226+
# And I see that the file list contains a file named "welcome (copy 2).txt"
227+
#
228+
# Scenario: copy a copy of a file in its same folder
229+
# Given I am logged in
230+
# And I start the move or copy operation for "welcome.txt"
231+
# # No folder was explicitly selected, so the last selected folder is the
232+
# # current folder.
233+
# And I copy to the last selected folder in the file picker
234+
# When I start the move or copy operation for "welcome (copy).txt"
235+
# And I copy to the last selected folder in the file picker
236+
# Then I see that the file list contains a file named "welcome.txt"
237+
# And I see that the file list contains a file named "welcome (copy).txt"
238+
# And I see that the file list contains a file named "welcome (copy 2).txt"
239239

240240
# Scenario: rename a file with the details view open
241241
# Given I am logged in

tests/acceptance/features/bootstrap/FilePickerContext.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ class FilePickerContext implements Context, ActorAwareInterface {
3030
* @return Locator
3131
*/
3232
public static function dialog() {
33-
return Locator::forThe()->css(".oc-dialog")->
33+
return Locator::forThe()->css(".modal-container")->
3434
describedAs("File picker dialog");
3535
}
3636

3737
/**
3838
* @return Locator
3939
*/
4040
public static function fileListContainer() {
41-
return Locator::forThe()->css("#oc-dialog-filepicker-content")->
41+
return Locator::forThe()->css(".file-picker__files")->
4242
descendantOf(self::dialog())->
4343
describedAs("File list container in the file picker dialog");
4444
}
@@ -49,7 +49,7 @@ public static function fileListContainer() {
4949
public static function rowForFile($fileName) {
5050
// File names in the file picker are split in two span elements, so
5151
// their texts need to be concatenated to get the full file name.
52-
return Locator::forThe()->xpath("//*[@id = 'picker-filestable']//*[contains(concat(' ', normalize-space(@class), ' '), ' filename-parts ') and concat(span[1], span[2]) = '$fileName']/ancestor::tr")->
52+
return Locator::forThe()->xpath("//*[concat(span[1], span[2]) = '$fileName']/ancestor::tr")->
5353
descendantOf(self::fileListContainer())->
5454
describedAs("Row for file $fileName in the file picker dialog");
5555
}
@@ -58,7 +58,7 @@ public static function rowForFile($fileName) {
5858
* @return Locator
5959
*/
6060
public static function buttonRow() {
61-
return Locator::forThe()->css(".oc-dialog-buttonrow")->
61+
return Locator::forThe()->css(".dialog__actions")->
6262
descendantOf(self::dialog())->
6363
describedAs("Button row in the file picker dialog");
6464
}
@@ -69,7 +69,7 @@ public static function buttonRow() {
6969
private static function buttonFor($buttonText) {
7070
// "Copy" and "Move" buttons text is set to "Copy to XXX" and "Move to
7171
// XXX" when a folder is selected.
72-
return Locator::forThe()->xpath("//button[starts-with(normalize-space(), '$buttonText')]")->
72+
return Locator::forThe()->xpath("//button[contains(normalize-space(), '$buttonText')]")->
7373
descendantOf(self::buttonRow())->
7474
describedAs($buttonText . " button in the file picker dialog");
7575
}

0 commit comments

Comments
 (0)