diff options
author | John Molakvoæ <skjnldsv@protonmail.com> | 2022-11-30 17:45:58 +0100 |
---|---|---|
committer | John Molakvoæ <skjnldsv@protonmail.com> | 2022-11-30 18:39:57 +0100 |
commit | f26ee9c69d98b9208f709e0c7aa284755708adbd (patch) | |
tree | 1edfb8f4d680e6e4ff3940e3f1ac3f068326fd8e /cypress/support/commands.ts | |
parent | 8434259b1bfef22adbf30b166043e29763bf9507 (diff) | |
download | nextcloud-server-f26ee9c69d98b9208f709e0c7aa284755708adbd.tar.gz nextcloud-server-f26ee9c69d98b9208f709e0c7aa284755708adbd.zip |
Faster theming tests, better colours comparison and properly follow admin theming changes
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'cypress/support/commands.ts')
-rw-r--r-- | cypress/support/commands.ts | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 2b51f719452..eab26beda79 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -21,7 +21,7 @@ */ /* eslint-disable node/no-unpublished-import */ import axios from '@nextcloud/axios' -import { addCommands, type User} from '@nextcloud/cypress' +import { addCommands, User } from '@nextcloud/cypress' import { basename } from 'path' // Add custom commands @@ -33,7 +33,8 @@ 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> + uploadFile(user: User, fixture?: string, mimeType?: string, target ?: string): Cypress.Chainable<void>, + resetTheming(): Cypress.Chainable<void>, } } } @@ -50,7 +51,7 @@ Cypress.env('baseUrl', url) * @param {string} mimeType e.g. image/png * @param {string} [target] the target of the file relative to the user root */ -Cypress.Commands.add('uploadFile', (user, fixture, mimeType, target = `/${fixture}`) => { +Cypress.Commands.add('uploadFile', (user, fixture = 'image.jpg', mimeType = 'image/jpeg', target = `/${fixture}`) => { cy.clearCookies() const fileName = basename(target) @@ -84,3 +85,29 @@ Cypress.Commands.add('uploadFile', (user, fixture, mimeType, target = `/${fixtur } }) }) + +/** + * Reset the admin theming entirely + */ + Cypress.Commands.add('resetTheming', () => { + const admin = new User('admin', 'admin') + + cy.clearCookies() + cy.login(admin) + + // Clear all settings + cy.request('/csrftoken').then(({ body }) => { + const requestToken = body.token + + axios({ + method: 'POST', + url: '/index.php/apps/theming/ajax/undoAllChanges', + headers: { + 'requesttoken': requestToken, + }, + }) + }) + + // Clear admin session + cy.clearCookies() +}) |