From 5cbd05be111bb0a044a309cf4a88de2388aef0d4 Mon Sep 17 00:00:00 2001 From: juancarmore Date: Mon, 23 Feb 2026 10:14:51 +0100 Subject: [PATCH] backend: refactor test cleanup to sequentially delete rooms and recordings --- .../api/analytics/get-analytics.test.ts | 3 ++- .../recordings/bulk-delete-recording.test.ts | 3 ++- .../api/recordings/delete-recording.test.ts | 9 ++++++--- .../recordings/download-recordings.test.ts | 3 ++- .../recordings/get-media-recording.test.ts | 3 ++- .../api/recordings/get-recording-url.test.ts | 7 ++++--- .../api/recordings/get-recordings.test.ts | 19 +++++++++++++++---- .../api/recordings/race-conditions.test.ts | 3 ++- .../recording-header-fields.test.ts | 16 ++++------------ .../api/recordings/start-recording.test.ts | 12 ++++++++---- .../api/recordings/stop-recording.test.ts | 3 ++- .../api/rooms/e2ee-room-config.test.ts | 2 +- .../api/security/recording-security.test.ts | 3 ++- .../integration/webhooks/webhook.test.ts | 3 ++- 14 files changed, 54 insertions(+), 35 deletions(-) diff --git a/meet-ce/backend/tests/integration/api/analytics/get-analytics.test.ts b/meet-ce/backend/tests/integration/api/analytics/get-analytics.test.ts index e5c6baf0..d42ce414 100644 --- a/meet-ce/backend/tests/integration/api/analytics/get-analytics.test.ts +++ b/meet-ce/backend/tests/integration/api/analytics/get-analytics.test.ts @@ -18,7 +18,8 @@ describe('Analytics API Tests', () => { afterEach(async () => { await disconnectFakeParticipants(); - await Promise.all([deleteAllRooms(), deleteAllRecordings()]); + await deleteAllRooms(); + await deleteAllRecordings(); }); describe('Get analytics', () => { diff --git a/meet-ce/backend/tests/integration/api/recordings/bulk-delete-recording.test.ts b/meet-ce/backend/tests/integration/api/recordings/bulk-delete-recording.test.ts index 7d5f6912..cbff64cb 100644 --- a/meet-ce/backend/tests/integration/api/recordings/bulk-delete-recording.test.ts +++ b/meet-ce/backend/tests/integration/api/recordings/bulk-delete-recording.test.ts @@ -21,7 +21,8 @@ describe('Recording API Tests', () => { afterEach(async () => { // Ensure a clean state after each test await disconnectFakeParticipants(); - await Promise.all([deleteAllRooms(), deleteAllRecordings()]); + await deleteAllRooms(); + await deleteAllRecordings(); const recordings = await getAllRecordings(); expect(recordings.body.recordings).toHaveLength(0); }); diff --git a/meet-ce/backend/tests/integration/api/recordings/delete-recording.test.ts b/meet-ce/backend/tests/integration/api/recordings/delete-recording.test.ts index e0f44c20..88bb3fba 100644 --- a/meet-ce/backend/tests/integration/api/recordings/delete-recording.test.ts +++ b/meet-ce/backend/tests/integration/api/recordings/delete-recording.test.ts @@ -20,7 +20,8 @@ describe('Recording API Tests', () => { afterAll(async () => { await disconnectFakeParticipants(); - await Promise.all([deleteAllRooms(), deleteAllRecordings()]); + await deleteAllRooms(); + await deleteAllRecordings(); }); describe('Delete Recording Tests', () => { @@ -35,7 +36,8 @@ describe('Recording API Tests', () => { afterAll(async () => { await stopAllRecordings(); - await Promise.all([deleteAllRecordings(), deleteAllRooms()]); + await deleteAllRooms(); + await deleteAllRecordings(); }); it('should delete a recording successfully', async () => { @@ -61,7 +63,8 @@ describe('Recording API Tests', () => { afterAll(async () => { await stopAllRecordings(); - await Promise.all([deleteAllRecordings(), deleteAllRooms()]); + await deleteAllRooms(); + await deleteAllRecordings(); }); it('should fail when recordingId has incorrect format', async () => { diff --git a/meet-ce/backend/tests/integration/api/recordings/download-recordings.test.ts b/meet-ce/backend/tests/integration/api/recordings/download-recordings.test.ts index 619f7f0d..d95920b3 100644 --- a/meet-ce/backend/tests/integration/api/recordings/download-recordings.test.ts +++ b/meet-ce/backend/tests/integration/api/recordings/download-recordings.test.ts @@ -20,7 +20,8 @@ describe('Recording API Tests', () => { afterAll(async () => { await disconnectFakeParticipants(); - await Promise.all([deleteAllRecordings(), deleteAllRooms()]); + await deleteAllRooms(); + await deleteAllRecordings(); }); const getZipEntries = async (buffer: Buffer) => { diff --git a/meet-ce/backend/tests/integration/api/recordings/get-media-recording.test.ts b/meet-ce/backend/tests/integration/api/recordings/get-media-recording.test.ts index 94749de7..b4435367 100644 --- a/meet-ce/backend/tests/integration/api/recordings/get-media-recording.test.ts +++ b/meet-ce/backend/tests/integration/api/recordings/get-media-recording.test.ts @@ -26,7 +26,8 @@ describe('Recording API Tests', () => { afterAll(async () => { await disconnectFakeParticipants(); - await Promise.all([deleteAllRecordings(), deleteAllRooms()]); + await deleteAllRooms(); + await deleteAllRecordings(); }); describe('Recording Media Tests', () => { diff --git a/meet-ce/backend/tests/integration/api/recordings/get-recording-url.test.ts b/meet-ce/backend/tests/integration/api/recordings/get-recording-url.test.ts index 5db4c387..57bd7f61 100644 --- a/meet-ce/backend/tests/integration/api/recordings/get-recording-url.test.ts +++ b/meet-ce/backend/tests/integration/api/recordings/get-recording-url.test.ts @@ -1,7 +1,9 @@ import { afterAll, beforeAll, describe, expect, it } from '@jest/globals'; import { Express } from 'express'; import request from 'supertest'; +import { INTERNAL_CONFIG } from '../../../../src/config/internal-config.js'; import { errorRecordingNotFound } from '../../../../src/models/error.model.js'; +import { expectValidGetRecordingUrlResponse } from '../../../helpers/assertion-helpers.js'; import { deleteAllRecordings, deleteAllRooms, @@ -11,8 +13,6 @@ import { startTestServer } from '../../../helpers/request-helpers.js'; import { setupSingleRoomWithRecording } from '../../../helpers/test-scenarios.js'; -import { expectValidGetRecordingUrlResponse } from '../../../helpers/assertion-helpers.js'; -import { INTERNAL_CONFIG } from '../../../../src/config/internal-config.js'; describe('Recording API Tests', () => { let app: Express; @@ -28,7 +28,8 @@ describe('Recording API Tests', () => { afterAll(async () => { await disconnectFakeParticipants(); - await Promise.all([deleteAllRooms(), deleteAllRecordings()]); + await deleteAllRooms(); + await deleteAllRecordings(); }); describe('Get Recording URL Tests', () => { diff --git a/meet-ce/backend/tests/integration/api/recordings/get-recordings.test.ts b/meet-ce/backend/tests/integration/api/recordings/get-recordings.test.ts index febb92d1..d5c5fe75 100644 --- a/meet-ce/backend/tests/integration/api/recordings/get-recordings.test.ts +++ b/meet-ce/backend/tests/integration/api/recordings/get-recordings.test.ts @@ -30,7 +30,8 @@ describe('Recordings API Tests', () => { describe('List Recordings Tests', () => { beforeEach(async () => { - await Promise.all([deleteAllRooms(), deleteAllRecordings()]); + await deleteAllRooms(); + await deleteAllRecordings(); const response = await getAllRecordings(); expect(response.status).toBe(200); expectSuccessListRecordingResponse(response, 0, false, false); @@ -38,7 +39,8 @@ describe('Recordings API Tests', () => { afterAll(async () => { await disconnectFakeParticipants(); - await Promise.all([deleteAllRooms(), deleteAllRecordings()]); + await deleteAllRooms(); + await deleteAllRecordings(); context = null; }); @@ -184,7 +186,8 @@ describe('Recordings API Tests', () => { // Disconnect participants and clean up await disconnectFakeParticipants(); - await Promise.all([deleteAllRooms(), deleteAllRecordings()]); + await deleteAllRooms(); + await deleteAllRecordings(); }); it('should sort recordings by startDate ascending and descending', async () => { @@ -289,10 +292,18 @@ describe('Recordings API Tests', () => { describe('List recordings - Fields filtering', () => { beforeAll(async () => { - await Promise.all([deleteAllRooms(), deleteAllRecordings()]); + await deleteAllRooms(); + await deleteAllRecordings(); context = await setupMultiRecordingsTestContext(2, 2, 2); }); + afterAll(async () => { + await disconnectFakeParticipants(); + await deleteAllRooms(); + await deleteAllRecordings(); + context = null; + }); + it('should filter fields using X-Fields header', async () => { const response = await getAllRecordings({}, { xFields: 'recordingId,roomId' }); expectSuccessListRecordingResponse(response, 2, false, false); diff --git a/meet-ce/backend/tests/integration/api/recordings/race-conditions.test.ts b/meet-ce/backend/tests/integration/api/recordings/race-conditions.test.ts index 5a619d4d..b54e7d24 100644 --- a/meet-ce/backend/tests/integration/api/recordings/race-conditions.test.ts +++ b/meet-ce/backend/tests/integration/api/recordings/race-conditions.test.ts @@ -43,7 +43,8 @@ describe('Recording API Race Conditions Tests', () => { eventController.reset(); await disconnectFakeParticipants(); - await Promise.all([deleteAllRecordings(), deleteAllRooms()]); + await deleteAllRooms(); + await deleteAllRecordings(); jest.clearAllMocks(); }); diff --git a/meet-ce/backend/tests/integration/api/recordings/recording-header-fields.test.ts b/meet-ce/backend/tests/integration/api/recordings/recording-header-fields.test.ts index 2a00d843..8766ba29 100644 --- a/meet-ce/backend/tests/integration/api/recordings/recording-header-fields.test.ts +++ b/meet-ce/backend/tests/integration/api/recordings/recording-header-fields.test.ts @@ -11,7 +11,6 @@ import { stopRecording } from '../../../helpers/request-helpers.js'; import { setupSingleRoomWithRecording } from '../../../helpers/test-scenarios.js'; -import { TestContext } from '../../../interfaces/scenarios.js'; /** * Tests for X-Fields header and fields query parameter support across all recording operations. @@ -22,28 +21,21 @@ import { TestContext } from '../../../interfaces/scenarios.js'; * When both are provided, values are merged (union of unique fields). */ describe('Recording Header Fields Tests', () => { - let context: TestContext | null = null; - beforeAll(async () => { await startTestServer(); }); afterAll(async () => { await disconnectFakeParticipants(); - await Promise.all([deleteAllRooms(), deleteAllRecordings()]); - context = null; + await deleteAllRooms(); + await deleteAllRecordings(); }); - - - - - - describe('POST /recordings/:recordingId/stop - X-Fields header and fields query param', () => { afterAll(async () => { await disconnectFakeParticipants(); - await Promise.all([deleteAllRooms(), deleteAllRecordings()]); + await deleteAllRooms(); + await deleteAllRecordings(); }); it('should filter response fields using X-Fields header on stop recording', async () => { diff --git a/meet-ce/backend/tests/integration/api/recordings/start-recording.test.ts b/meet-ce/backend/tests/integration/api/recordings/start-recording.test.ts index 4c07407d..a7c55d4b 100644 --- a/meet-ce/backend/tests/integration/api/recordings/start-recording.test.ts +++ b/meet-ce/backend/tests/integration/api/recordings/start-recording.test.ts @@ -42,7 +42,8 @@ describe('Recording API Tests', () => { afterAll(async () => { await disconnectFakeParticipants(); - await Promise.all([deleteAllRooms(), deleteAllRecordings()]); + await deleteAllRooms(); + await deleteAllRecordings(); }); describe('Start Recording Tests', () => { @@ -54,7 +55,8 @@ describe('Recording API Tests', () => { afterAll(async () => { await disconnectFakeParticipants(); - await Promise.all([deleteAllRooms(), deleteAllRecordings()]); + await deleteAllRooms(); + await deleteAllRecordings(); context = null; }); @@ -145,7 +147,8 @@ describe('Recording API Tests', () => { afterAll(async () => { await disconnectFakeParticipants(); - await Promise.all([deleteAllRooms(), deleteAllRecordings()]); + await deleteAllRooms(); + await deleteAllRecordings(); context = null; }); @@ -544,7 +547,8 @@ describe('Recording API Tests', () => { afterAll(async () => { await disconnectFakeParticipants(); - await Promise.all([deleteAllRooms(), deleteAllRecordings()]); + await deleteAllRooms(); + await deleteAllRecordings(); context = null; }); diff --git a/meet-ce/backend/tests/integration/api/recordings/stop-recording.test.ts b/meet-ce/backend/tests/integration/api/recordings/stop-recording.test.ts index 722d0a92..9c745dc1 100644 --- a/meet-ce/backend/tests/integration/api/recordings/stop-recording.test.ts +++ b/meet-ce/backend/tests/integration/api/recordings/stop-recording.test.ts @@ -30,7 +30,8 @@ describe('Recording API Tests', () => { afterAll(async () => { await stopAllRecordings(); await disconnectFakeParticipants(); - await Promise.all([deleteAllRooms(), deleteAllRecordings()]); + await deleteAllRooms(); + await deleteAllRecordings(); }); describe('Stop Recording Tests', () => { diff --git a/meet-ce/backend/tests/integration/api/rooms/e2ee-room-config.test.ts b/meet-ce/backend/tests/integration/api/rooms/e2ee-room-config.test.ts index 19d9f988..e960f9ed 100644 --- a/meet-ce/backend/tests/integration/api/rooms/e2ee-room-config.test.ts +++ b/meet-ce/backend/tests/integration/api/rooms/e2ee-room-config.test.ts @@ -26,8 +26,8 @@ describe('E2EE Room Configuration Tests', () => { }); afterAll(async () => { - await deleteAllRecordings(); await deleteAllRooms(); + await deleteAllRecordings(); }); describe('E2EE Default Configuration', () => { diff --git a/meet-ce/backend/tests/integration/api/security/recording-security.test.ts b/meet-ce/backend/tests/integration/api/security/recording-security.test.ts index c0974ec5..991b3961 100644 --- a/meet-ce/backend/tests/integration/api/security/recording-security.test.ts +++ b/meet-ce/backend/tests/integration/api/security/recording-security.test.ts @@ -41,7 +41,8 @@ describe('Recording API Security Tests', () => { afterAll(async () => { await disconnectFakeParticipants(); - await Promise.all([deleteAllRooms(), deleteAllRecordings()]); + await deleteAllRooms(); + await deleteAllRecordings(); await deleteAllUsers(); }); diff --git a/meet-ce/backend/tests/integration/webhooks/webhook.test.ts b/meet-ce/backend/tests/integration/webhooks/webhook.test.ts index d8ee2556..4cf4f0ec 100644 --- a/meet-ce/backend/tests/integration/webhooks/webhook.test.ts +++ b/meet-ce/backend/tests/integration/webhooks/webhook.test.ts @@ -70,7 +70,8 @@ describe('Webhook Integration Tests', () => { await restoreDefaultGlobalConfig(); await disconnectFakeParticipants(); - await Promise.all([deleteAllRooms(), deleteAllRecordings()]); + await deleteAllRooms(); + await deleteAllRecordings(); }); const expectValidSignature = (webhook: { headers: http.IncomingHttpHeaders; body: MeetWebhookEvent }) => {