From d47f0d64eae49359d66483d0bf1fce40980beb78 Mon Sep 17 00:00:00 2001 From: Jonas Date: Mon, 11 Sep 2023 10:18:43 +0200 Subject: [PATCH] test(cypress): More flexible selectors for Nextcloud 25-28 Signed-off-by: Jonas --- cypress/e2e/apps.spec.js | 3 ++- cypress/e2e/pages.spec.js | 2 +- cypress/e2e/settings.spec.js | 26 +++++++++++++++----------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/cypress/e2e/apps.spec.js b/cypress/e2e/apps.spec.js index eb5e1d6ce..a6f315636 100644 --- a/cypress/e2e/apps.spec.js +++ b/cypress/e2e/apps.spec.js @@ -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') }) }) diff --git a/cypress/e2e/pages.spec.js b/cypress/e2e/pages.spec.js index 6b6194c61..641921026 100644 --- a/cypress/e2e/pages.spec.js +++ b/cypress/e2e/pages.spec.js @@ -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') diff --git a/cypress/e2e/settings.spec.js b/cypress/e2e/settings.spec.js index 688db6e62..a336b8cb1 100644 --- a/cypress/e2e/settings.spec.js +++ b/cypress/e2e/settings.spec.js @@ -33,6 +33,9 @@ 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() @@ -40,25 +43,26 @@ describe('Settings', function() { 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') @@ -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() }) })