aboutsummaryrefslogtreecommitdiffstats
path: root/cypress/e2e
diff options
context:
space:
mode:
authorGrigorii K. Shartsev <me@shgk.me>2024-01-16 18:40:33 +0100
committerGrigorii K. Shartsev <me@shgk.me>2024-01-24 14:35:31 +0100
commit6df488df212757e246032f4eef972cfe47603c44 (patch)
tree680f5f12ce494835d81b6e47d76d1cc65e5b80ad /cypress/e2e
parent544357d0028b5237d901c252a0c7d1cc2955cb74 (diff)
downloadnextcloud-server-6df488df212757e246032f4eef972cfe47603c44.tar.gz
nextcloud-server-6df488df212757e246032f4eef972cfe47603c44.zip
test(theming): update e2e tests after separating color button and preview
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
Diffstat (limited to 'cypress/e2e')
-rw-r--r--cypress/e2e/theming/admin-settings.cy.ts11
-rw-r--r--cypress/e2e/theming/themingUtils.ts14
-rw-r--r--cypress/e2e/theming/user-background.cy.ts4
3 files changed, 14 insertions, 15 deletions
diff --git a/cypress/e2e/theming/admin-settings.cy.ts b/cypress/e2e/theming/admin-settings.cy.ts
index 6825e0045c2..1c4e3458aae 100644
--- a/cypress/e2e/theming/admin-settings.cy.ts
+++ b/cypress/e2e/theming/admin-settings.cy.ts
@@ -41,7 +41,7 @@ describe('Admin theming settings visibility check', function() {
})
it('See the default settings', function() {
- cy.get('[data-admin-theming-setting-primary-color-picker]').should('contain.text', defaultPrimary)
+ cy.get('[data-admin-theming-setting-primary-color-picker]').should('exist')
cy.get('[data-admin-theming-setting-primary-color-reset]').should('not.exist')
cy.get('[data-admin-theming-setting-file-reset]').should('not.exist')
cy.get('[data-admin-theming-setting-file-remove]').should('be.visible')
@@ -66,8 +66,7 @@ describe('Change the primary color and reset it', function() {
it('Change the primary color', function() {
cy.intercept('*/apps/theming/ajax/updateStylesheet').as('setColor')
- pickRandomColor('[data-admin-theming-setting-primary-color-picker]')
- .then(color => { selectedColor = color })
+ pickRandomColor().then(color => { selectedColor = color })
cy.wait('@setColor')
cy.waitUntil(() => validateBodyThemingCss(selectedColor, defaultBackground))
@@ -151,8 +150,7 @@ describe('Remove the default background with a custom primary color', function()
it('Change the primary color', function() {
cy.intercept('*/apps/theming/ajax/updateStylesheet').as('setColor')
- pickRandomColor('[data-admin-theming-setting-primary-color-picker]')
- .then((color) => { selectedColor = color })
+ pickRandomColor().then(color => { selectedColor = color })
cy.wait('@setColor')
cy.waitUntil(() => validateBodyThemingCss(selectedColor, defaultBackground))
@@ -372,8 +370,7 @@ describe('The user default background settings reflect the admin theming setting
it('Change the primary color', function() {
cy.intercept('*/apps/theming/ajax/updateStylesheet').as('setColor')
- pickRandomColor('[data-admin-theming-setting-primary-color-picker]')
- .then(color => { selectedColor = color })
+ pickRandomColor().then(color => { selectedColor = color })
cy.wait('@setColor')
cy.waitUntil(() => cy.window().then(($window) => {
diff --git a/cypress/e2e/theming/themingUtils.ts b/cypress/e2e/theming/themingUtils.ts
index 1cbab439012..7b570a8cb55 100644
--- a/cypress/e2e/theming/themingUtils.ts
+++ b/cypress/e2e/theming/themingUtils.ts
@@ -75,12 +75,14 @@ export const pickRandomColor = function(): Cypress.Chainable<string> {
// Pick one of the first 8 options
const randColour = Math.floor(Math.random() * 8)
+ const colorPreviewSelector = '[data-user-theming-background-color],[data-admin-theming-setting-primary-color]'
+
// Open picker
- cy.get('button').contains('Change color').click()
+ cy.contains('button', 'Change color').click()
+
+ // Click on random color
+ cy.get('.color-picker__simple-color-circle').eq(randColour).click()
- // Return selected colour
- return cy.get('.color-picker__simple-color-circle').eq(randColour).then(($el) => {
- $el.trigger('click')
- return $el.css('background-color')
- })
+ // Get the selected color from the color preview block
+ return cy.get(colorPreviewSelector).then(($el) => $el.css('background-color'))
}
diff --git a/cypress/e2e/theming/user-background.cy.ts b/cypress/e2e/theming/user-background.cy.ts
index ce8a50821ef..e024ea4b5e9 100644
--- a/cypress/e2e/theming/user-background.cy.ts
+++ b/cypress/e2e/theming/user-background.cy.ts
@@ -168,7 +168,7 @@ describe('User select a bright custom color and remove background', function() {
cy.intercept('*/apps/theming/background/color').as('setColor')
// Pick one of the bright color preset
- cy.get('button').contains('Change color').click()
+ cy.contains('button', 'Change color').click()
cy.get('.color-picker__simple-color-circle:eq(4)').click()
// Validate custom colour change
@@ -286,7 +286,7 @@ describe('User changes settings and reload the page', function() {
it('Select a custom color', function() {
cy.intercept('*/apps/theming/background/color').as('setColor')
- cy.get('button').contains('Change color').click()
+ cy.contains('button', 'Change color').click()
cy.get('.color-picker__simple-color-circle:eq(5)').click()
// Validate clear background