test: Enhance recording API tests with additional validation and status checks
This commit is contained in:
parent
02e16f85ee
commit
68f809c690
@ -37,10 +37,23 @@ describe('Recording API Tests', () => {
|
||||
it('should return 200 when recording exists', async () => {
|
||||
const response = await getRecording(recordingId);
|
||||
|
||||
console.log(response.body);
|
||||
expectValidGetRecordingResponse(response, recordingId, room.roomId, MeetRecordingStatus.COMPLETE, 1);
|
||||
});
|
||||
|
||||
it('should get an ACTIVE recording status', async () => {
|
||||
const contextAux = await setupMultiRecordingsTestContext(1, 1, 0, '0s');
|
||||
const {
|
||||
room: roomAux,
|
||||
recordingId: recordingIdAux = '',
|
||||
moderatorCookie: moderatorCookieAux
|
||||
} = contextAux.getRoomByIndex(0)!;
|
||||
const response = await getRecording(recordingIdAux);
|
||||
|
||||
expectValidGetRecordingResponse(response, recordingIdAux, roomAux.roomId, MeetRecordingStatus.ACTIVE);
|
||||
|
||||
await stopAllRecordings(moderatorCookieAux);
|
||||
});
|
||||
|
||||
it('should return 404 when recording does not exist', async () => {
|
||||
const response = await getRecording('nonexistent--EG_222--4s444');
|
||||
expect(response.status).toBe(404);
|
||||
|
||||
@ -1,6 +1,12 @@
|
||||
import { expect } from '@jest/globals';
|
||||
import INTERNAL_CONFIG from '../../src/config/internal-config';
|
||||
import { MeetRecordingAccess, MeetRecordingStatus, MeetRoom, MeetRoomPreferences } from '../../src/typings/ce';
|
||||
import {
|
||||
MeetRecordingAccess,
|
||||
MeetRecordingInfo,
|
||||
MeetRecordingStatus,
|
||||
MeetRoom,
|
||||
MeetRoomPreferences
|
||||
} from '../../src/typings/ce';
|
||||
|
||||
const RECORDINGS_PATH = `${INTERNAL_CONFIG.INTERNAL_API_BASE_PATH_V1}/recordings`;
|
||||
|
||||
@ -133,11 +139,34 @@ export const expectValidRoom = (
|
||||
}
|
||||
};
|
||||
|
||||
export const expectValidRecording = (
|
||||
recording: MeetRecordingInfo,
|
||||
recordingId: string,
|
||||
roomId: string,
|
||||
status: MeetRecordingStatus
|
||||
) => {
|
||||
expect(recording).toBeDefined();
|
||||
expect(recording.recordingId).toBeDefined();
|
||||
expect(recording.roomId).toBeDefined();
|
||||
expect(recording.recordingId).toBe(recordingId);
|
||||
expect(recording.roomId).toBe(roomId);
|
||||
expect(recording.startDate).toBeDefined();
|
||||
expect(recording.status).toBeDefined();
|
||||
expect(recording.status).toBe(status);
|
||||
expect(recording.filename).toBeDefined();
|
||||
expect(recording.details).toBeDefined();
|
||||
};
|
||||
|
||||
export const expectValidRoomWithFields = (room: MeetRoom, fields: string[] = []) => {
|
||||
expect(room).toBeDefined();
|
||||
expectObjectFields(room, fields);
|
||||
};
|
||||
|
||||
export const expectValidRecordingWithFields = (rec: MeetRecordingInfo, fields: string[] = []) => {
|
||||
expect(rec).toBeDefined();
|
||||
expectObjectFields(rec, fields);
|
||||
};
|
||||
|
||||
const expectObjectFields = (obj: any, present: string[] = [], absent: string[] = []) => {
|
||||
present.forEach((key) => {
|
||||
expect(obj).toHaveProperty(key);
|
||||
@ -198,29 +227,35 @@ export const expectValidGetRecordingResponse = (
|
||||
|
||||
expect(body).toMatchObject({ recordingId, roomId });
|
||||
|
||||
const isRecFinished =
|
||||
status &&
|
||||
(status === MeetRecordingStatus.COMPLETE ||
|
||||
status === MeetRecordingStatus.ABORTED ||
|
||||
status === MeetRecordingStatus.FAILED ||
|
||||
status === MeetRecordingStatus.LIMIT_REACHED);
|
||||
expect(body).toEqual(
|
||||
expect.objectContaining({
|
||||
duration: expect.any(Number),
|
||||
startDate: expect.any(Number),
|
||||
endDate: expect.any(Number),
|
||||
size: expect.any(Number),
|
||||
...(isRecFinished ? { duration: expect.any(Number) } : {}),
|
||||
...(isRecFinished ? { startDate: expect.any(Number) } : {}),
|
||||
...(isRecFinished ? { endDate: expect.any(Number) } : {}),
|
||||
...(isRecFinished ? { size: expect.any(Number) } : {}),
|
||||
filename: expect.any(String),
|
||||
details: expect.any(String)
|
||||
...(isRecFinished ? { details: expect.any(Number) } : {})
|
||||
})
|
||||
);
|
||||
|
||||
expect(body.duration).toBeGreaterThanOrEqual(0);
|
||||
expect(body.status).toBeDefined();
|
||||
|
||||
if (status !== undefined) {
|
||||
expect(body.status).toBe(status);
|
||||
} else {
|
||||
expect(body.status).toBe('COMPLETE');
|
||||
}
|
||||
|
||||
expect(body.endDate).toBeGreaterThanOrEqual(body.startDate);
|
||||
if (isRecFinished) {
|
||||
expect(body.endDate).toBeGreaterThanOrEqual(body.startDate);
|
||||
expect(body.duration).toBeGreaterThanOrEqual(0);
|
||||
}
|
||||
|
||||
if (maxSecDuration) {
|
||||
if (isRecFinished && maxSecDuration) {
|
||||
expect(body.duration).toBeLessThanOrEqual(maxSecDuration);
|
||||
|
||||
const computedSec = (body.endDate - body.startDate) / 1000;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user