Skip to content

Commit

Permalink
test(cy): introduce fileList and openFile commands
Browse files Browse the repository at this point in the history
Signed-off-by: Max <[email protected]>
  • Loading branch information
max-nextcloud committed Oct 23, 2023
1 parent 1ff3655 commit 0c1dfcb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
3 changes: 1 addition & 2 deletions cypress/e2e/apps.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ 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(fileListSelector).should('contain', 'welcome')
cy.fileList().should('contain', 'welcome')
})

})
Expand Down
11 changes: 4 additions & 7 deletions cypress/e2e/collective.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,13 @@ describe('Collective', function() {
cy.login('bob', { route: '/apps/files' })
})
it('has a matching folder', function() {
const fileListSelector = '.files-fileList a, [data-cy-files-list-row] a'
const breadcrumbsSelector = '.files-controls .breadcrumb, [data-cy-files-content-breadcrumbs] a'
cy.get(fileListSelector).should('contain', 'Collectives')
cy.get(fileListSelector).contains('Collectives').click()
cy.openFile('Collectives')
cy.get(breadcrumbsSelector).should('contain', 'Collectives')
cy.get(fileListSelector).should('contain', 'Preexisting Collective')
cy.get(fileListSelector).contains('Preexisting Collective').click()
cy.openFile('Preexisting Collective')
cy.get(breadcrumbsSelector).should('contain', 'Preexisting Collective')
cy.get(fileListSelector).should('contain', 'Readme')
cy.get(fileListSelector).should('contain', '.md')
cy.fileList().should('contain', 'Readme')
cy.fileList().should('contain', '.md')
cy.get('.filelist-collectives-wrapper')
.should('contain', 'The content of this folder is best viewed in the Collectives app.')
})
Expand Down
5 changes: 2 additions & 3 deletions cypress/e2e/settings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ describe('Settings', 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')

Expand Down Expand Up @@ -68,9 +67,9 @@ describe('Settings', function() {
// Check if collectives are found in new folder in Files app
cy.log('Check if collectives are in configured user folder')
cy.visit('/apps/files')
cy.get(fileListSelector).contains(randomFolder).click()
cy.openFile(randomFolder)
cy.get(breadcrumbsSelector).should('contain', randomFolder)
cy.get(fileListSelector).should('contain', 'A Collective')
cy.fileList().should('contain', 'A Collective')

// Change user folder back to default
cy.log('Change user folder back to default')
Expand Down
5 changes: 5 additions & 0 deletions cypress/support/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ Cypress.Commands.add('clickMenuButton', (title) => {
.contains(title)
.click()
})

const FILE_LIST_SELECTOR = '.files-fileList a, [data-cy-files-list-row] a'
Cypress.Commands.add('fileList', () => cy.get(FILE_LIST_SELECTOR))

Cypress.Commands.add('openFile', (name) => cy.fileList().contains(name).click())

0 comments on commit 0c1dfcb

Please sign in to comment.