test: Remove moderatorToken from start and stop recording tests
This commit is contained in:
parent
3f91e281b3
commit
2fe720c90b
@ -24,7 +24,7 @@ import { TestContext } from '../../../interfaces/scenarios.js';
|
||||
|
||||
describe('Recording API Tests', () => {
|
||||
let context: TestContext | null = null;
|
||||
let room: MeetRoom, moderatorToken: string;
|
||||
let room: MeetRoom;
|
||||
|
||||
beforeAll(async () => {
|
||||
await startTestServer();
|
||||
@ -40,7 +40,7 @@ describe('Recording API Tests', () => {
|
||||
beforeAll(async () => {
|
||||
// Create a room and join a participant
|
||||
context = await setupMultiRoomTestContext(1, true);
|
||||
({ room, moderatorToken } = context.getRoomByIndex(0)!);
|
||||
({ room } = context.getRoomByIndex(0)!);
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
@ -50,16 +50,16 @@ describe('Recording API Tests', () => {
|
||||
});
|
||||
|
||||
it('should return 201 with proper response and location header when recording starts successfully', async () => {
|
||||
const response = await startRecording(room.roomId, moderatorToken);
|
||||
const response = await startRecording(room.roomId);
|
||||
const recordingId = response.body.recordingId;
|
||||
expectValidStartRecordingResponse(response, room.roomId, room.roomName);
|
||||
|
||||
const stopResponse = await stopRecording(recordingId, moderatorToken);
|
||||
const stopResponse = await stopRecording(recordingId);
|
||||
expectValidStopRecordingResponse(stopResponse, recordingId, room.roomId, room.roomName);
|
||||
});
|
||||
|
||||
it('should create secrets when recording starts', async () => {
|
||||
const response = await startRecording(room.roomId, moderatorToken);
|
||||
const response = await startRecording(room.roomId);
|
||||
const recordingId = response.body.recordingId;
|
||||
expectValidStartRecordingResponse(response, room.roomId, room.roomName);
|
||||
|
||||
@ -70,24 +70,24 @@ describe('Recording API Tests', () => {
|
||||
expect(recSecrets?.publicAccessSecret).toBeDefined();
|
||||
expect(recSecrets?.privateAccessSecret).toBeDefined();
|
||||
|
||||
const stopResponse = await stopRecording(recordingId, moderatorToken);
|
||||
const stopResponse = await stopRecording(recordingId);
|
||||
expectValidStopRecordingResponse(stopResponse, recordingId, room.roomId, room.roomName);
|
||||
});
|
||||
|
||||
it('should successfully start recording, stop it, and start again (sequential operations)', async () => {
|
||||
const firstStartResponse = await startRecording(room.roomId, moderatorToken);
|
||||
const firstStartResponse = await startRecording(room.roomId);
|
||||
const firstRecordingId = firstStartResponse.body.recordingId;
|
||||
|
||||
expectValidStartRecordingResponse(firstStartResponse, room.roomId, room.roomName);
|
||||
|
||||
const firstStopResponse = await stopRecording(firstRecordingId, moderatorToken);
|
||||
const firstStopResponse = await stopRecording(firstRecordingId);
|
||||
expectValidStopRecordingResponse(firstStopResponse, firstRecordingId, room.roomId, room.roomName);
|
||||
|
||||
const secondStartResponse = await startRecording(room.roomId, moderatorToken);
|
||||
const secondStartResponse = await startRecording(room.roomId);
|
||||
expectValidStartRecordingResponse(secondStartResponse, room.roomId, room.roomName);
|
||||
const secondRecordingId = secondStartResponse.body.recordingId;
|
||||
|
||||
const secondStopResponse = await stopRecording(secondRecordingId, moderatorToken);
|
||||
const secondStopResponse = await stopRecording(secondRecordingId);
|
||||
expectValidStopRecordingResponse(secondStopResponse, secondRecordingId, room.roomId, room.roomName);
|
||||
});
|
||||
|
||||
@ -97,8 +97,8 @@ describe('Recording API Tests', () => {
|
||||
const roomDataA = context.getRoomByIndex(0)!;
|
||||
const roomDataB = context.getRoomByIndex(1)!;
|
||||
|
||||
const firstResponse = await startRecording(roomDataA.room.roomId, roomDataA.moderatorToken);
|
||||
const secondResponse = await startRecording(roomDataB.room.roomId, roomDataB.moderatorToken);
|
||||
const firstResponse = await startRecording(roomDataA.room.roomId);
|
||||
const secondResponse = await startRecording(roomDataB.room.roomId);
|
||||
|
||||
expectValidStartRecordingResponse(firstResponse, roomDataA.room.roomId, roomDataA.room.roomName);
|
||||
expectValidStartRecordingResponse(secondResponse, roomDataB.room.roomId, roomDataB.room.roomName);
|
||||
@ -107,8 +107,8 @@ describe('Recording API Tests', () => {
|
||||
const secondRecordingId = secondResponse.body.recordingId;
|
||||
|
||||
const [firstStopResponse, secondStopResponse] = await Promise.all([
|
||||
stopRecording(firstRecordingId, roomDataA.moderatorToken),
|
||||
stopRecording(secondRecordingId, roomDataB.moderatorToken)
|
||||
stopRecording(firstRecordingId),
|
||||
stopRecording(secondRecordingId)
|
||||
]);
|
||||
expectValidStopRecordingResponse(
|
||||
firstStopResponse,
|
||||
@ -129,16 +129,16 @@ describe('Recording API Tests', () => {
|
||||
beforeAll(async () => {
|
||||
// Create a room without participants
|
||||
context = await setupMultiRoomTestContext(1, false);
|
||||
({ room, moderatorToken } = context.getRoomByIndex(0)!);
|
||||
({ room } = context.getRoomByIndex(0)!);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await disconnectFakeParticipants();
|
||||
await stopAllRecordings(moderatorToken);
|
||||
await stopAllRecordings();
|
||||
});
|
||||
|
||||
it('should accept valid roomId but reject with 409', async () => {
|
||||
const response = await startRecording(room.roomId, moderatorToken);
|
||||
const response = await startRecording(room.roomId);
|
||||
// Room exists but it has no participants
|
||||
expect(response.status).toBe(409);
|
||||
expect(response.body.message).toContain(`Room '${room.roomId}' has no participants`);
|
||||
@ -146,7 +146,7 @@ describe('Recording API Tests', () => {
|
||||
|
||||
it('should sanitize roomId and reject the request with 409 due to no participants', async () => {
|
||||
const malformedRoomId = ' .<!?' + room.roomId + ' ';
|
||||
const response = await startRecording(malformedRoomId, moderatorToken);
|
||||
const response = await startRecording(malformedRoomId);
|
||||
|
||||
console.log('Response:', response.body);
|
||||
expect(response.status).toBe(409);
|
||||
@ -154,25 +154,25 @@ describe('Recording API Tests', () => {
|
||||
});
|
||||
|
||||
it('should reject request with roomId that becomes empty after sanitization', async () => {
|
||||
const response = await startRecording('!@#$%^&*()', moderatorToken);
|
||||
const response = await startRecording('!@#$%^&*()');
|
||||
|
||||
expectValidationError(response, 'roomId', 'cannot be empty after sanitization');
|
||||
});
|
||||
|
||||
it('should reject request with non-string roomId', async () => {
|
||||
const response = await startRecording(123 as unknown as string, moderatorToken);
|
||||
const response = await startRecording(123 as unknown as string);
|
||||
expectValidationError(response, 'roomId', 'Expected string');
|
||||
});
|
||||
|
||||
it('should reject request with very long roomId', async () => {
|
||||
const longRoomId = 'a'.repeat(101);
|
||||
const response = await startRecording(longRoomId, moderatorToken);
|
||||
const response = await startRecording(longRoomId);
|
||||
|
||||
expectValidationError(response, 'roomId', 'cannot exceed 100 characters');
|
||||
});
|
||||
|
||||
it('should handle room that does not exist', async () => {
|
||||
const response = await startRecording('non-existing-room-id', moderatorToken);
|
||||
const response = await startRecording('non-existing-room-id');
|
||||
const error = errorRoomNotFound('non-existing-room-id');
|
||||
expect(response.status).toBe(404);
|
||||
expect(response.body).toEqual({
|
||||
@ -183,14 +183,14 @@ describe('Recording API Tests', () => {
|
||||
|
||||
it('should return 409 when recording is already in progress', async () => {
|
||||
await joinFakeParticipant(room.roomId, 'fakeParticipantId');
|
||||
const firstResponse = await startRecording(room.roomId, moderatorToken);
|
||||
const firstResponse = await startRecording(room.roomId);
|
||||
const recordingId = firstResponse.body.recordingId;
|
||||
expectValidStartRecordingResponse(firstResponse, room.roomId, room.roomName);
|
||||
|
||||
const secondResponse = await startRecording(room!.roomId, moderatorToken);
|
||||
const secondResponse = await startRecording(room!.roomId);
|
||||
expect(secondResponse.status).toBe(409);
|
||||
expect(secondResponse.body.message).toContain('already');
|
||||
const stopResponse = await stopRecording(recordingId, moderatorToken);
|
||||
const stopResponse = await stopRecording(recordingId);
|
||||
expectValidStopRecordingResponse(stopResponse, recordingId, room.roomId, room.roomName);
|
||||
});
|
||||
|
||||
@ -199,7 +199,7 @@ describe('Recording API Tests', () => {
|
||||
RECORDING_STARTED_TIMEOUT: '1s'
|
||||
});
|
||||
await joinFakeParticipant(room.roomId, 'fakeParticipantId');
|
||||
const response = await startRecording(room.roomId, moderatorToken);
|
||||
const response = await startRecording(room.roomId);
|
||||
expect(response.status).toBe(503);
|
||||
expect(response.body.message).toContain('timed out while starting');
|
||||
setInternalConfig({
|
||||
|
||||
@ -15,7 +15,7 @@ import { TestContext } from '../../../interfaces/scenarios';
|
||||
|
||||
describe('Recording API Tests', () => {
|
||||
let context: TestContext | null = null;
|
||||
let room: MeetRoom, moderatorToken: string;
|
||||
let room: MeetRoom;
|
||||
|
||||
beforeAll(async () => {
|
||||
await startTestServer();
|
||||
@ -23,7 +23,7 @@ describe('Recording API Tests', () => {
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await stopAllRecordings(moderatorToken);
|
||||
await stopAllRecordings();
|
||||
await disconnectFakeParticipants();
|
||||
await Promise.all([deleteAllRooms(), deleteAllRecordings()]);
|
||||
});
|
||||
@ -33,13 +33,13 @@ describe('Recording API Tests', () => {
|
||||
beforeAll(async () => {
|
||||
// Create a room and join a participant
|
||||
context = await setupMultiRoomTestContext(1, true);
|
||||
({ room, moderatorToken } = context.getRoomByIndex(0)!);
|
||||
const response = await startRecording(room.roomId, moderatorToken);
|
||||
({ room } = context.getRoomByIndex(0)!);
|
||||
const response = await startRecording(room.roomId);
|
||||
recordingId = response.body.recordingId;
|
||||
});
|
||||
|
||||
it('should stop an active recording and return 202', async () => {
|
||||
const response = await stopRecording(recordingId, moderatorToken);
|
||||
const response = await stopRecording(recordingId);
|
||||
expectValidStopRecordingResponse(response, recordingId, room.roomId, room.roomName);
|
||||
});
|
||||
|
||||
@ -47,18 +47,18 @@ describe('Recording API Tests', () => {
|
||||
const context = await setupMultiRoomTestContext(2, true);
|
||||
const roomDataA = context.getRoomByIndex(0);
|
||||
const roomDataB = context.getRoomByIndex(1);
|
||||
const responseA = await startRecording(roomDataA!.room.roomId, roomDataA!.moderatorToken);
|
||||
const responseB = await startRecording(roomDataB!.room.roomId, roomDataB!.moderatorToken);
|
||||
const responseA = await startRecording(roomDataA!.room.roomId);
|
||||
const responseB = await startRecording(roomDataB!.room.roomId);
|
||||
const recordingIdA = responseA.body.recordingId;
|
||||
const recordingIdB = responseB.body.recordingId;
|
||||
const stopResponseA = await stopRecording(recordingIdA, roomDataA!.moderatorToken);
|
||||
const stopResponseA = await stopRecording(recordingIdA);
|
||||
expectValidStopRecordingResponse(
|
||||
stopResponseA,
|
||||
recordingIdA,
|
||||
roomDataA!.room.roomId,
|
||||
roomDataA!.room.roomName
|
||||
);
|
||||
const stopResponseB = await stopRecording(recordingIdB, roomDataB!.moderatorToken);
|
||||
const stopResponseB = await stopRecording(recordingIdB);
|
||||
expectValidStopRecordingResponse(
|
||||
stopResponseB,
|
||||
recordingIdB,
|
||||
@ -69,7 +69,7 @@ describe('Recording API Tests', () => {
|
||||
|
||||
describe('Stop Recording Validation failures', () => {
|
||||
it('should return 404 when recordingId does not exist', async () => {
|
||||
const response = await stopRecording(`${room.roomId}--EG_123--444`, moderatorToken);
|
||||
const response = await stopRecording(`${room.roomId}--EG_123--444`);
|
||||
expect(response.status).toBe(404);
|
||||
expect(response.body.error).toBe('Recording Error');
|
||||
expect(response.body.message).toContain('not found');
|
||||
@ -77,17 +77,17 @@ describe('Recording API Tests', () => {
|
||||
|
||||
it('should return 400 when recording is already stopped', async () => {
|
||||
// First stop the recording
|
||||
await stopRecording(recordingId, moderatorToken);
|
||||
await stopRecording(recordingId);
|
||||
|
||||
// Try to stop it again
|
||||
const response = await stopRecording(recordingId, moderatorToken);
|
||||
const response = await stopRecording(recordingId);
|
||||
|
||||
console.log('Response:', response.body);
|
||||
expectErrorResponse(response, 409, '', `Recording '${recordingId}' is already stopped`);
|
||||
});
|
||||
|
||||
it('should return 404 when recordingId is not in the correct format', async () => {
|
||||
const response = await stopRecording('invalid-recording-id', moderatorToken);
|
||||
const response = await stopRecording('invalid-recording-id');
|
||||
expect(response.status).toBe(422);
|
||||
expect(response.body.error).toBe('Unprocessable Entity');
|
||||
expect(response.body.message).toContain('Invalid request');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user