2022-12-28 14:29:54 +00:00
|
|
|
/**
|
2024-05-24 17:43:47 +00:00
|
|
|
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2022-12-28 14:29:54 +00:00
|
|
|
*/
|
2024-10-15 23:07:31 +00:00
|
|
|
|
|
|
|
import '@testing-library/cypress/add-commands'
|
2023-10-05 12:55:22 +00:00
|
|
|
import 'cypress-axe'
|
|
|
|
|
2024-10-16 10:04:52 +00:00
|
|
|
// styles
|
|
|
|
import '../../apps/theming/css/default.css'
|
|
|
|
import '../../core/css/server.css'
|
|
|
|
|
2023-01-13 16:32:57 +00:00
|
|
|
/* eslint-disable */
|
2023-04-21 09:04:08 +00:00
|
|
|
import { mount } from '@cypress/vue2'
|
|
|
|
|
2024-10-15 23:07:31 +00:00
|
|
|
Cypress.Commands.add('mount', (component, options = {}) => {
|
|
|
|
// Setup options object
|
|
|
|
options.extensions = options.extensions || {}
|
|
|
|
options.extensions.plugins = options.extensions.plugins || []
|
|
|
|
options.extensions.components = options.extensions.components || {}
|
2023-01-04 18:06:52 +00:00
|
|
|
|
2024-10-15 23:07:31 +00:00
|
|
|
return mount(component, options)
|
2023-01-04 18:06:52 +00:00
|
|
|
})
|
2023-08-02 12:42:57 +00:00
|
|
|
|
2024-10-15 23:07:31 +00:00
|
|
|
Cypress.Commands.add('mockInitialState', (app: string, key: string, value: unknown) => {
|
2023-08-02 12:42:57 +00:00
|
|
|
cy.document().then(($document) => {
|
|
|
|
const input = $document.createElement('input')
|
|
|
|
input.setAttribute('type', 'hidden')
|
|
|
|
input.setAttribute('id', `initial-state-${app}-${key}`)
|
|
|
|
input.setAttribute('value', btoa(JSON.stringify(value)))
|
|
|
|
$document.body.appendChild(input)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
Cypress.Commands.add('unmockInitialState', (app?: string, key?: string) => {
|
|
|
|
cy.document().then(($document) => {
|
|
|
|
$document.querySelectorAll('body > input[type="hidden"]' + (app ? `[id="initial-state-${app}-${key}"]` : ''))
|
|
|
|
.forEach((node) => $document.body.removeChild(node))
|
|
|
|
})
|
2024-10-15 23:07:31 +00:00
|
|
|
})
|