Skip to content

Commit

Permalink
test(cypress): Use flexible selectors in settings.spec.js for Nextclo…
Browse files Browse the repository at this point in the history
…ud 25-28

Signed-off-by: Jonas <[email protected]>
  • Loading branch information
mejo- committed Sep 11, 2023
1 parent 23c3b85 commit ff4e62f
Showing 1 changed file with 15 additions and 11 deletions.
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"]')
.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 ff4e62f

Please sign in to comment.