Skip to content

Commit

Permalink
test(cypress): More flexible selectors for Nextcloud 25-28
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas <jonas@freesources.org>
  • Loading branch information
mejo- committed Sep 11, 2023
1 parent 23c3b85 commit d47f0d6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
3 changes: 2 additions & 1 deletion cypress/e2e/apps.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ describe('The apps', function() {
})

it('Renders the default files list', function() {
const fileListSelector = '.files-fileList a, [data-cy-files-list-row] a'
cy.login('jane', { route: 'apps/files' })
cy.get('.files-fileList tr, .files-list__tbody tr').should('contain', 'welcome.txt')
cy.get(fileListSelector).should('contain', 'welcome.txt')
})

})
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/pages.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ describe('Page', function() {
cy.get('.tippy-content .link-picker__item')
.contains('Collective pages')
.click()
cy.get('.reference-picker input[type="search"]')
cy.get('.reference-picker input[type="text"], .reference-picker input[type="search"]')
.type('Day 2')
cy.get('.search-result')
.contains('Day 2')
Expand Down
26 changes: 15 additions & 11 deletions cypress/e2e/settings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,36 @@ describe('Settings', function() {
describe('Collectives folder setting', function() {
it('Allows changing the collective user folder', function() {
const randomFolder = Math.random().toString(36).replace(/[^a-z]+/g, '').slice(0, 10)
const filePickerListSelector = '#picker-filestable tr, .file-picker__row'
const fileListSelector = 'files-fileList a, [data-cy-files-list-row] a'
const breadcrumbsSelector = '.files-controls .breadcrumb, [data-cy-files-content-breadcrumbs] a'
cy.login('bob')
cy.get('#app-settings')
.click()
cy.intercept('PROPFIND', '**/remote.php/dav/files/**').as('propfindFolder')
cy.get('input[name="userFolder"]')
.click()
cy.wait('@propfindFolder')
cy.get('[data-dir=""] > a')
cy.get('[data-dir=""] > a, a[title="Home"]')
.click()
cy.get('[data-dir="/Collectives"]').should('not.exist')
cy.get('#oc-dialog-filepicker-content > span > span > a.button-add')
cy.get('#oc-dialog-filepicker-content > span > span > a.button-add, .breadcrumb__actions button')
.click()
cy.intercept('MKCOL', `**/remote.php/dav/files/**/${randomFolder}`).as('createFolder')
cy.get('nav.newFolderMenu > ul > li > form > input[type="text"]')
cy.get('nav.newFolderMenu > ul > li > form > input[type="text"], input[placeholder="New folder name"], input[placeholder="New folder"]')
.type(`${randomFolder}{enter}`)
cy.wait('@createFolder')
cy.intercept('POST', '**/collectives/api/v1.0/settings/user').as('setCollectivesFolder')
cy.get('.oc-dialog-buttonrow > button').contains('Choose')
if (!['stable25', 'stable26', 'stable27'].includes(Cypress.env('ncVersion'))) {
cy.get(filePickerListSelector).contains(randomFolder).click()
}
cy.get('button').contains('Choose')
.click()
cy.wait('@setCollectivesFolder')
cy.log('Check if collectives are in configured user folder')
cy.visit('/apps/files')
cy.get('.files-fileList').should('contain', randomFolder)
cy.get('.files-fileList a').contains(randomFolder).click()
cy.get('.files-controls .breadcrumb').should('contain', randomFolder)
cy.get('.files-fileList').should('contain', 'A Collective')
cy.get(fileListSelector).contains(randomFolder).click()
cy.get(breadcrumbsSelector).should('contain', randomFolder)
cy.get(fileListSelector).should('contain', 'A Collective')
cy.log('Change user folder back to default')
cy.visit('/apps/collectives')
cy.get('#app-settings')
Expand All @@ -67,9 +71,9 @@ describe('Settings', function() {
.click()
cy.get('[data-dir=""] > a, a[title="Home"]')
.click()
cy.get('tr[data-entryname="Collectives"]')
cy.get(filePickerListSelector).contains('Collectives')
.click()
cy.get('.oc-dialog-buttonrow > button').contains('Choose')
cy.get('button').contains('Choose')
.click()
})
})
Expand Down

0 comments on commit d47f0d6

Please sign in to comment.