diff --git a/web/tests/recordingsAPI.spec.js b/web/tests/recordingsAPI.spec.js index 1eb57ebe1..ea77fabc1 100644 --- a/web/tests/recordingsAPI.spec.js +++ b/web/tests/recordingsAPI.spec.js @@ -339,12 +339,23 @@ describe('recordingsAPI', () => { describe('archive batch deletion outcomes', () => { const { useMutation, useQueryClient } = require('../js/query-client.ts'); + let previousWindow; + let hadWindow; beforeEach(() => { jest.clearAllMocks(); fetchJSON.mockReset(); + hadWindow = Object.prototype.hasOwnProperty.call(global, 'window'); + previousWindow = global.window; global.window = {}; }); - afterEach(() => { jest.restoreAllMocks(); delete global.window; }); + afterEach(() => { + jest.restoreAllMocks(); + if (hadWindow) { + global.window = previousWindow; + } else { + delete global.window; + } + }); test('mutation waits for the durable job outcome before resolving and refreshing', async () => { const invalidateQueries = jest.fn();