test(files): adjust mocking initial state for updated library

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
Ferdinand Thiessen
2025-08-11 16:16:21 +02:00
parent 4d1051891e
commit 9ad5214fce
2 changed files with 8 additions and 5 deletions

View File

@ -26,11 +26,7 @@ describe('hasPersonalFilesView', () => {
}) })
describe('defaultView', () => { describe('defaultView', () => {
beforeEach(() => { beforeEach(removeInitialState)
document.querySelectorAll('input[type="hidden"]').forEach((el) => {
el.remove()
})
})
test('Returns files view if set', () => { test('Returns files view if set', () => {
mockInitialState('files', 'config', { default_view: 'files' }) mockInitialState('files', 'config', { default_view: 'files' })
@ -57,6 +53,8 @@ function removeInitialState(): void {
document.querySelectorAll('input[type="hidden"]').forEach((el) => { document.querySelectorAll('input[type="hidden"]').forEach((el) => {
el.remove() el.remove()
}) })
// clear the cache
delete globalThis._nc_initial_state
} }
/** /**

View File

@ -33,6 +33,11 @@ Cypress.Commands.add('mockInitialState', (app: string, key: string, value: unkno
}) })
Cypress.Commands.add('unmockInitialState', (app?: string, key?: string) => { Cypress.Commands.add('unmockInitialState', (app?: string, key?: string) => {
cy.window().then(($window) => {
// @ts-expect-error internal value
delete $window._nc_initial_state
})
cy.document().then(($document) => { cy.document().then(($document) => {
$document.querySelectorAll('body > input[type="hidden"]' + (app ? `[id="initial-state-${app}-${key}"]` : '')) $document.querySelectorAll('body > input[type="hidden"]' + (app ? `[id="initial-state-${app}-${key}"]` : ''))
.forEach((node) => $document.body.removeChild(node)) .forEach((node) => $document.body.removeChild(node))