1
0

component.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /**
  2. * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
  3. * SPDX-License-Identifier: AGPL-3.0-or-later
  4. */
  5. import '@testing-library/cypress/add-commands'
  6. import 'cypress-axe'
  7. // styles
  8. import '../../apps/theming/css/default.css'
  9. import '../../core/css/server.css'
  10. /* eslint-disable */
  11. import { mount } from '@cypress/vue2'
  12. Cypress.Commands.add('mount', (component, options = {}) => {
  13. // Setup options object
  14. options.extensions = options.extensions || {}
  15. options.extensions.plugins = options.extensions.plugins || []
  16. options.extensions.components = options.extensions.components || {}
  17. return mount(component, options)
  18. })
  19. Cypress.Commands.add('mockInitialState', (app: string, key: string, value: unknown) => {
  20. cy.document().then(($document) => {
  21. const input = $document.createElement('input')
  22. input.setAttribute('type', 'hidden')
  23. input.setAttribute('id', `initial-state-${app}-${key}`)
  24. input.setAttribute('value', btoa(JSON.stringify(value)))
  25. $document.body.appendChild(input)
  26. })
  27. })
  28. Cypress.Commands.add('unmockInitialState', (app?: string, key?: string) => {
  29. cy.document().then(($document) => {
  30. $document.querySelectorAll('body > input[type="hidden"]' + (app ? `[id="initial-state-${app}-${key}"]` : ''))
  31. .forEach((node) => $document.body.removeChild(node))
  32. })
  33. })