diff options
author | John Molakvoæ <skjnldsv@protonmail.com> | 2022-12-08 09:46:59 +0100 |
---|---|---|
committer | John Molakvoæ <skjnldsv@protonmail.com> | 2022-12-08 17:52:50 +0100 |
commit | 1acd42e10ce13d253516efb722f7d05e74fa46e9 (patch) | |
tree | fa04592316f60f454794d761567e25038fc80ce0 /cypress/support | |
parent | fabcd68a5e2c4909dc58d35e756acb0675e61311 (diff) | |
download | nextcloud-server-1acd42e10ce13d253516efb722f7d05e74fa46e9.tar.gz nextcloud-server-1acd42e10ce13d253516efb722f7d05e74fa46e9.zip |
Invert header if primary is bright and background disabled
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'cypress/support')
-rw-r--r-- | cypress/support/commands.ts | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index eab26beda79..ad3f665cade 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -33,8 +33,24 @@ declare global { // eslint-disable-next-line @typescript-eslint/no-namespace namespace Cypress { interface Chainable<Subject = any> { - uploadFile(user: User, fixture?: string, mimeType?: string, target ?: string): Cypress.Chainable<void>, - resetTheming(): Cypress.Chainable<void>, + /** + * Upload a file from the fixtures folder to a given user storage. + * **Warning**: Using this function will reset the previous session + */ + uploadFile(user: User, fixture?: string, mimeType?: string, target?: string): Cypress.Chainable<void>, + + /** + * Reset the admin theming entirely. + * **Warning**: Using this function will reset the previous session + */ + resetAdminTheming(): Cypress.Chainable<void>, + + /** + * Reset the user theming settings. + * If provided, will clear session and login as the given user. + * **Warning**: Providing a user will reset the previous session. + */ + resetUserTheming(user?: User): Cypress.Chainable<void>, } } } @@ -89,7 +105,7 @@ Cypress.Commands.add('uploadFile', (user, fixture = 'image.jpg', mimeType = 'ima /** * Reset the admin theming entirely */ - Cypress.Commands.add('resetTheming', () => { + Cypress.Commands.add('resetAdminTheming', () => { const admin = new User('admin', 'admin') cy.clearCookies() @@ -111,3 +127,33 @@ Cypress.Commands.add('uploadFile', (user, fixture = 'image.jpg', mimeType = 'ima // Clear admin session cy.clearCookies() }) + +/** + * Reset the current or provided user theming settings + * It does not reset the theme config as it is enforced in the + * server config for cypress testing. + */ +Cypress.Commands.add('resetUserTheming', (user?: User) => { + if (user) { + cy.clearCookies() + cy.login(user) + } + + // Reset background config + cy.request('/csrftoken').then(({ body }) => { + const requestToken = body.token + + cy.request({ + method: 'POST', + url: '/apps/theming/background/default', + headers: { + 'requesttoken': requestToken, + }, + }) + }) + + if (user) { + // Clear current session + cy.clearCookies() + } +}) |