aboutsummaryrefslogtreecommitdiffstats
path: root/cypress/support
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2023-08-02 14:42:57 +0200
committerFerdinand Thiessen <opensource@fthiessen.de>2023-08-02 15:21:34 +0200
commit650312580f330bdf43cce4fb91d9fd721ed115f0 (patch)
treefac713e8ba6a7bd83a8066d44a81c76d44622481 /cypress/support
parent9bf42fc3bf70bb7587af30e4a98089fdc46fa579 (diff)
downloadnextcloud-server-650312580f330bdf43cce4fb91d9fd721ed115f0.tar.gz
nextcloud-server-650312580f330bdf43cce4fb91d9fd721ed115f0.zip
fix(cypress): Really mock the initial state instead of trying to stub a module
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'cypress/support')
-rw-r--r--cypress/support/component.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/cypress/support/component.ts b/cypress/support/component.ts
index 3769caed46b..b1e0a1b2c0f 100644
--- a/cypress/support/component.ts
+++ b/cypress/support/component.ts
@@ -43,3 +43,20 @@ Cypress.Commands.add('mount', (component, optionsOrProps) => {
return cy.wrap(instance).as('component')
})
})
+
+Cypress.Commands.add('mockInitialState', (app: string, key: string, value: any) => {
+ 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))
+ })
+}) \ No newline at end of file