From 9ad5214fce01edfad36e5f79df6cc8daedea74e8 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Mon, 11 Aug 2025 16:16:21 +0200 Subject: [PATCH] test(files): adjust mocking initial state for updated library Signed-off-by: Ferdinand Thiessen --- apps/files/src/utils/filesViews.spec.ts | 8 +++----- cypress/support/component.ts | 5 +++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/apps/files/src/utils/filesViews.spec.ts b/apps/files/src/utils/filesViews.spec.ts index e8c2ab3a6c1..03b0bb9aeb0 100644 --- a/apps/files/src/utils/filesViews.spec.ts +++ b/apps/files/src/utils/filesViews.spec.ts @@ -26,11 +26,7 @@ describe('hasPersonalFilesView', () => { }) describe('defaultView', () => { - beforeEach(() => { - document.querySelectorAll('input[type="hidden"]').forEach((el) => { - el.remove() - }) - }) + beforeEach(removeInitialState) test('Returns files view if set', () => { mockInitialState('files', 'config', { default_view: 'files' }) @@ -57,6 +53,8 @@ function removeInitialState(): void { document.querySelectorAll('input[type="hidden"]').forEach((el) => { el.remove() }) + // clear the cache + delete globalThis._nc_initial_state } /** diff --git a/cypress/support/component.ts b/cypress/support/component.ts index eecb55c69e7..853609bb4dd 100644 --- a/cypress/support/component.ts +++ b/cypress/support/component.ts @@ -33,6 +33,11 @@ Cypress.Commands.add('mockInitialState', (app: string, key: string, value: unkno }) 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) => { $document.querySelectorAll('body > input[type="hidden"]' + (app ? `[id="initial-state-${app}-${key}"]` : '')) .forEach((node) => $document.body.removeChild(node))