test: Enhance bulk delete recording tests and add validation for room metadata deletion
This commit is contained in:
parent
51ed2faa12
commit
b8ed0faf90
@ -3,11 +3,14 @@ import {
|
|||||||
bulkDeleteRecordings,
|
bulkDeleteRecordings,
|
||||||
deleteAllRecordings,
|
deleteAllRecordings,
|
||||||
deleteAllRooms,
|
deleteAllRooms,
|
||||||
|
startRecording,
|
||||||
startTestServer,
|
startTestServer,
|
||||||
stopRecording
|
stopRecording
|
||||||
} from '../../../utils/helpers';
|
} from '../../../utils/helpers';
|
||||||
import { setupMultiRecordingsTestContext } from '../../../utils/test-scenarios';
|
import { setupMultiRecordingsTestContext } from '../../../utils/test-scenarios';
|
||||||
import { expectValidationError } from '../../../utils/assertion-helpers';
|
import { expectValidationError, expectValidStartRecordingResponse } from '../../../utils/assertion-helpers';
|
||||||
|
import { container } from '../../../../src/config/dependency-injector.config';
|
||||||
|
import { MeetStorageService } from '../../../../src/services';
|
||||||
|
|
||||||
describe('Recording API Tests', () => {
|
describe('Recording API Tests', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
@ -116,6 +119,53 @@ describe('Recording API Tests', () => {
|
|||||||
expect(deleteResponse.status).toBe(204);
|
expect(deleteResponse.status).toBe(204);
|
||||||
expect(deleteResponse.body).toStrictEqual({});
|
expect(deleteResponse.body).toStrictEqual({});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should delete room metadata when deleting the last recording', async () => {
|
||||||
|
const meetStorageService = container.get<MeetStorageService>(MeetStorageService);
|
||||||
|
// Create two recordings in the same room
|
||||||
|
const testContext = await setupMultiRecordingsTestContext(1, 1, 1, '0s');
|
||||||
|
const { room, recordingId: firstRecordingId, moderatorCookie } = testContext.rooms[0];
|
||||||
|
|
||||||
|
let roomMetadata = await meetStorageService.getArchivedRoomMetadata(room.roomId);
|
||||||
|
|
||||||
|
expect(roomMetadata).toBeDefined();
|
||||||
|
expect(roomMetadata!.moderatorRoomUrl).toContain(room.roomId);
|
||||||
|
expect(roomMetadata!.publisherRoomUrl).toContain(room.roomId);
|
||||||
|
|
||||||
|
roomMetadata = await meetStorageService.getArchivedRoomMetadata(room.roomId);
|
||||||
|
|
||||||
|
expect(roomMetadata).toBeDefined();
|
||||||
|
expect(roomMetadata!.moderatorRoomUrl).toContain(room.roomId);
|
||||||
|
expect(roomMetadata!.publisherRoomUrl).toContain(room.roomId);
|
||||||
|
|
||||||
|
const response = await startRecording(room.roomId, moderatorCookie);
|
||||||
|
console.log('Start recording response:', response.body);
|
||||||
|
expectValidStartRecordingResponse(response, room.roomId);
|
||||||
|
const secondRecordingId = response.body.recordingId;
|
||||||
|
|
||||||
|
await stopRecording(secondRecordingId, moderatorCookie);
|
||||||
|
// Delete first recording - room metadata should remain
|
||||||
|
const bulkResponse = await bulkDeleteRecordings([firstRecordingId, secondRecordingId]);
|
||||||
|
expect(bulkResponse.status).toBe(204);
|
||||||
|
|
||||||
|
// // Verify second recording still exists
|
||||||
|
// const secondRecordingResponse = await getRecording(secondRecordingId);
|
||||||
|
// console.log('Second recording response:', secondRecordingId);
|
||||||
|
// console.log('Second recording response:', secondRecordingResponse.body);
|
||||||
|
// expectValidGetRecordingResponse(
|
||||||
|
// secondRecordingResponse,
|
||||||
|
// secondRecordingId,
|
||||||
|
// room.roomId,
|
||||||
|
// MeetRecordingStatus.COMPLETE,
|
||||||
|
// 3
|
||||||
|
// );
|
||||||
|
|
||||||
|
// // Delete second recording - room metadata should be deleted
|
||||||
|
// await bulkDeleteRecordings([secondRecordingId]);
|
||||||
|
|
||||||
|
roomMetadata = await meetStorageService.getArchivedRoomMetadata(room.roomId);
|
||||||
|
expect(roomMetadata).toBe(null);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Bulk Delete Recording Validation', () => {
|
describe('Bulk Delete Recording Validation', () => {
|
||||||
|
|||||||
@ -185,14 +185,14 @@ export const expectValidGetRecordingResponse = (
|
|||||||
response: any,
|
response: any,
|
||||||
recordingId: string,
|
recordingId: string,
|
||||||
roomId: string,
|
roomId: string,
|
||||||
status: MeetRecordingStatus,
|
status?: MeetRecordingStatus,
|
||||||
maxSecDuration: number
|
maxSecDuration?: number
|
||||||
) => {
|
) => {
|
||||||
expect(response.status).toBe(200);
|
expect(response.status).toBe(200);
|
||||||
expect(response.body).toBeDefined();
|
expect(response.body).toBeDefined();
|
||||||
const body = response.body;
|
const body = response.body;
|
||||||
|
|
||||||
expect(body).toMatchObject({ recordingId, roomId, status });
|
expect(body).toMatchObject({ recordingId, roomId });
|
||||||
|
|
||||||
expect(body).toEqual(
|
expect(body).toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
@ -206,12 +206,49 @@ export const expectValidGetRecordingResponse = (
|
|||||||
);
|
);
|
||||||
|
|
||||||
expect(body.duration).toBeGreaterThanOrEqual(0);
|
expect(body.duration).toBeGreaterThanOrEqual(0);
|
||||||
expect(body.duration).toBeLessThanOrEqual(maxSecDuration);
|
expect(body.status).toBeDefined();
|
||||||
|
|
||||||
|
if (status !== undefined) {
|
||||||
|
expect(body.status).toBe(status);
|
||||||
|
} else {
|
||||||
|
expect(body.status).toBe('COMPLETE');
|
||||||
|
}
|
||||||
|
|
||||||
expect(body.endDate).toBeGreaterThanOrEqual(body.startDate);
|
expect(body.endDate).toBeGreaterThanOrEqual(body.startDate);
|
||||||
|
|
||||||
const computedSec = (body.endDate - body.startDate) / 1000;
|
if (maxSecDuration) {
|
||||||
const diffSec = Math.abs(body.duration - computedSec);
|
expect(body.duration).toBeLessThanOrEqual(maxSecDuration);
|
||||||
// Estimate 5 seconds of tolerace because of time to start/stop recording
|
|
||||||
expect(diffSec).toBeLessThanOrEqual(5);
|
const computedSec = (body.endDate - body.startDate) / 1000;
|
||||||
|
const diffSec = Math.abs(maxSecDuration - computedSec);
|
||||||
|
// Estimate 5 seconds of tolerace because of time to start/stop recording
|
||||||
|
expect(diffSec).toBeLessThanOrEqual(5);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const expectSuccessListRecordingResponse = (
|
||||||
|
response: any,
|
||||||
|
recordingLength: number,
|
||||||
|
isTruncated: boolean,
|
||||||
|
nextPageToken: boolean,
|
||||||
|
maxItems = 10
|
||||||
|
) => {
|
||||||
|
expect(response.status).toBe(200);
|
||||||
|
expect(response.body).toBeDefined();
|
||||||
|
expect(response.body.recordings).toBeDefined();
|
||||||
|
expect(Array.isArray(response.body.recordings)).toBe(true);
|
||||||
|
expect(response.body.recordings.length).toBe(recordingLength);
|
||||||
|
expect(response.body.pagination).toBeDefined();
|
||||||
|
expect(response.body.pagination.isTruncated).toBe(isTruncated);
|
||||||
|
|
||||||
|
if (nextPageToken) {
|
||||||
|
expect(response.body.pagination.nextPageToken).toBeDefined();
|
||||||
|
} else {
|
||||||
|
expect(response.body.pagination.nextPageToken).toBeUndefined();
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(response.body.pagination.maxItems).toBeDefined();
|
||||||
|
expect(response.body.pagination.maxItems).toBeGreaterThan(0);
|
||||||
|
expect(response.body.pagination.maxItems).toBeLessThanOrEqual(100);
|
||||||
|
expect(response.body.pagination.maxItems).toBe(maxItems);
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user