tests: Fix broken tests by changing expected error responses and reorganize imports
This commit is contained in:
parent
94d526df07
commit
5a66b2f623
@ -1,6 +1,7 @@
|
|||||||
import { afterAll, beforeAll, beforeEach, describe, expect, it } from '@jest/globals';
|
import { afterAll, beforeAll, beforeEach, describe, expect, it } from '@jest/globals';
|
||||||
import { container } from '../../../../src/config';
|
import { container } from '../../../../src/config';
|
||||||
import { MeetStorageService } from '../../../../src/services';
|
import { MeetStorageService } from '../../../../src/services';
|
||||||
|
import { MeetRoom } from '../../../../src/typings/ce';
|
||||||
import { expectValidationError, expectValidStartRecordingResponse } from '../../../helpers/assertion-helpers';
|
import { expectValidationError, expectValidStartRecordingResponse } from '../../../helpers/assertion-helpers';
|
||||||
import {
|
import {
|
||||||
deleteAllRecordings,
|
deleteAllRecordings,
|
||||||
@ -12,7 +13,6 @@ import {
|
|||||||
stopRecording
|
stopRecording
|
||||||
} from '../../../helpers/request-helpers';
|
} from '../../../helpers/request-helpers';
|
||||||
import { setupMultiRecordingsTestContext } from '../../../helpers/test-scenarios';
|
import { setupMultiRecordingsTestContext } from '../../../helpers/test-scenarios';
|
||||||
import { MeetRoom } from '../../../../src/typings/ce';
|
|
||||||
|
|
||||||
describe('Recording API Tests', () => {
|
describe('Recording API Tests', () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
|
|||||||
@ -1,18 +1,17 @@
|
|||||||
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, jest } from '@jest/globals';
|
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, jest } from '@jest/globals';
|
||||||
|
import { EgressInfo, EgressStatus, Room } from 'livekit-server-sdk';
|
||||||
import ms from 'ms';
|
import ms from 'ms';
|
||||||
|
import { Lock } from 'redlock';
|
||||||
|
import { container } from '../../../../src/config/index.js';
|
||||||
|
import INTERNAL_CONFIG from '../../../../src/config/internal-config.js';
|
||||||
import { MeetLock } from '../../../../src/helpers/index.js';
|
import { MeetLock } from '../../../../src/helpers/index.js';
|
||||||
import {
|
import {
|
||||||
RecordingService,
|
|
||||||
MutexService,
|
|
||||||
LiveKitService,
|
LiveKitService,
|
||||||
LoggerService,
|
LoggerService,
|
||||||
|
MutexService,
|
||||||
|
RecordingService,
|
||||||
RedisLock
|
RedisLock
|
||||||
} from '../../../../src/services/index.js';
|
} from '../../../../src/services/index.js';
|
||||||
|
|
||||||
import { container } from '../../../../src/config/dependency-injector.config.js';
|
|
||||||
import { EgressInfo, EgressStatus, Room } from 'livekit-server-sdk';
|
|
||||||
import INTERNAL_CONFIG from '../../../../src/config/internal-config.js';
|
|
||||||
import { Lock } from 'redlock';
|
|
||||||
import { startTestServer } from '../../../helpers/request-helpers.js';
|
import { startTestServer } from '../../../helpers/request-helpers.js';
|
||||||
|
|
||||||
describe('Recording Garbage Collector Tests', () => {
|
describe('Recording Garbage Collector Tests', () => {
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { afterAll, beforeAll, describe, expect, it } from '@jest/globals';
|
import { afterAll, beforeAll, describe, expect, it } from '@jest/globals';
|
||||||
|
import { MeetRoom } from '../../../../src/typings/ce';
|
||||||
import { expectSuccessRecordingMediaResponse, expectValidationError } from '../../../helpers/assertion-helpers';
|
import { expectSuccessRecordingMediaResponse, expectValidationError } from '../../../helpers/assertion-helpers';
|
||||||
import {
|
import {
|
||||||
deleteAllRecordings,
|
deleteAllRecordings,
|
||||||
@ -9,7 +10,6 @@ import {
|
|||||||
stopRecording
|
stopRecording
|
||||||
} from '../../../helpers/request-helpers';
|
} from '../../../helpers/request-helpers';
|
||||||
import { setupMultiRecordingsTestContext } from '../../../helpers/test-scenarios';
|
import { setupMultiRecordingsTestContext } from '../../../helpers/test-scenarios';
|
||||||
import { MeetRoom } from '../../../../src/typings/ce';
|
|
||||||
|
|
||||||
describe('Recording API Tests', () => {
|
describe('Recording API Tests', () => {
|
||||||
let room: MeetRoom, recordingId: string, moderatorCookie: string;
|
let room: MeetRoom, recordingId: string, moderatorCookie: string;
|
||||||
@ -27,6 +27,7 @@ describe('Recording API Tests', () => {
|
|||||||
await stopAllRecordings(moderatorCookie);
|
await stopAllRecordings(moderatorCookie);
|
||||||
await Promise.all([deleteAllRecordings(), deleteAllRooms()]);
|
await Promise.all([deleteAllRecordings(), deleteAllRooms()]);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Recording Media Tests', () => {
|
describe('Recording Media Tests', () => {
|
||||||
it('should return 200 when requesting the full media content', async () => {
|
it('should return 200 when requesting the full media content', async () => {
|
||||||
const response = await getRecordingMedia(recordingId);
|
const response = await getRecordingMedia(recordingId);
|
||||||
@ -157,7 +158,7 @@ describe('Recording API Tests', () => {
|
|||||||
// Request a range beyond the file size
|
// Request a range beyond the file size
|
||||||
const response = await getRecordingMedia(recordingId, `bytes=${fullSize + 1}-${fullSize + 1000}`);
|
const response = await getRecordingMedia(recordingId, `bytes=${fullSize + 1}-${fullSize + 1000}`);
|
||||||
expect(response.status).toBe(416);
|
expect(response.status).toBe(416);
|
||||||
expect(response.body).toHaveProperty('name', 'Recording Error');
|
expect(response.body).toHaveProperty('error', 'Recording Error');
|
||||||
expect(response.body).toHaveProperty('message');
|
expect(response.body).toHaveProperty('message');
|
||||||
expect(response.body.message).toContain(`Recording '${recordingId}' range not satisfiable`);
|
expect(response.body.message).toContain(`Recording '${recordingId}' range not satisfiable`);
|
||||||
expect(response.body.message).toMatch(/File size: \d+/);
|
expect(response.body.message).toMatch(/File size: \d+/);
|
||||||
@ -170,7 +171,7 @@ describe('Recording API Tests', () => {
|
|||||||
// Attempt to get the media of an active recording
|
// Attempt to get the media of an active recording
|
||||||
const response = await getRecordingMedia(activeRecordingId);
|
const response = await getRecordingMedia(activeRecordingId);
|
||||||
expect(response.status).toBe(409);
|
expect(response.status).toBe(409);
|
||||||
expect(response.body).toHaveProperty('name', 'Recording Error');
|
expect(response.body).toHaveProperty('error', 'Recording Error');
|
||||||
expect(response.body).toHaveProperty('message');
|
expect(response.body).toHaveProperty('message');
|
||||||
expect(response.body.message).toContain(`Recording '${activeRecordingId}' is not stopped yet`);
|
expect(response.body.message).toContain(`Recording '${activeRecordingId}' is not stopped yet`);
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
import { afterAll, beforeAll, describe, expect, it } from '@jest/globals';
|
import { afterAll, beforeAll, describe, expect, it } from '@jest/globals';
|
||||||
|
import { errorRecordingNotFound } from '../../../../src/models/error.model.js';
|
||||||
|
import { MeetRecordingStatus, MeetRoom } from '../../../../src/typings/ce/index.js';
|
||||||
|
import { expectValidationError, expectValidGetRecordingResponse } from '../../../helpers/assertion-helpers.js';
|
||||||
import {
|
import {
|
||||||
deleteAllRecordings,
|
deleteAllRecordings,
|
||||||
deleteAllRooms,
|
deleteAllRooms,
|
||||||
@ -7,11 +10,6 @@ import {
|
|||||||
startTestServer,
|
startTestServer,
|
||||||
stopAllRecordings
|
stopAllRecordings
|
||||||
} from '../../../helpers/request-helpers.js';
|
} from '../../../helpers/request-helpers.js';
|
||||||
|
|
||||||
import { errorRecordingNotFound } from '../../../../src/models/error.model.js';
|
|
||||||
import { MeetRecordingStatus } from '../../../../src/typings/ce/recording.model.js';
|
|
||||||
import { MeetRoom } from '../../../../src/typings/ce/room.js';
|
|
||||||
import { expectValidationError, expectValidGetRecordingResponse } from '../../../helpers/assertion-helpers.js';
|
|
||||||
import { setupMultiRecordingsTestContext, TestContext } from '../../../helpers/test-scenarios.js';
|
import { setupMultiRecordingsTestContext, TestContext } from '../../../helpers/test-scenarios.js';
|
||||||
|
|
||||||
describe('Recording API Tests', () => {
|
describe('Recording API Tests', () => {
|
||||||
|
|||||||
@ -1,4 +1,11 @@
|
|||||||
import { describe, it, expect, beforeAll, afterEach, afterAll } from '@jest/globals';
|
import { afterAll, afterEach, beforeAll, describe, expect, it } from '@jest/globals';
|
||||||
|
import { MeetRecordingInfo, MeetRecordingStatus, MeetRoom } from '../../../../src/typings/ce/index.js';
|
||||||
|
import {
|
||||||
|
expectSuccessListRecordingResponse,
|
||||||
|
expectValidationError,
|
||||||
|
expectValidRecording,
|
||||||
|
expectValidRecordingWithFields
|
||||||
|
} from '../../../helpers/assertion-helpers.js';
|
||||||
import {
|
import {
|
||||||
deleteAllRecordings,
|
deleteAllRecordings,
|
||||||
deleteAllRooms,
|
deleteAllRooms,
|
||||||
@ -6,16 +13,7 @@ import {
|
|||||||
getAllRecordings,
|
getAllRecordings,
|
||||||
startTestServer
|
startTestServer
|
||||||
} from '../../../helpers/request-helpers.js';
|
} from '../../../helpers/request-helpers.js';
|
||||||
|
|
||||||
import {
|
|
||||||
expectValidationError,
|
|
||||||
expectSuccessListRecordingResponse,
|
|
||||||
expectValidRecordingWithFields,
|
|
||||||
expectValidRecording
|
|
||||||
} from '../../../helpers/assertion-helpers.js';
|
|
||||||
import { RoomData, setupMultiRecordingsTestContext, TestContext } from '../../../helpers/test-scenarios.js';
|
import { RoomData, setupMultiRecordingsTestContext, TestContext } from '../../../helpers/test-scenarios.js';
|
||||||
import { MeetRoom } from '../../../../src/typings/ce/room.js';
|
|
||||||
import { MeetRecordingInfo, MeetRecordingStatus } from '../../../../src/typings/ce/recording.model.js';
|
|
||||||
|
|
||||||
describe('Recordings API Tests', () => {
|
describe('Recordings API Tests', () => {
|
||||||
let context: TestContext | null = null;
|
let context: TestContext | null = null;
|
||||||
|
|||||||
@ -1,35 +1,34 @@
|
|||||||
import { describe, it, expect, beforeAll, afterAll, afterEach, jest } from '@jest/globals';
|
import { afterEach, beforeAll, describe, expect, it, jest } from '@jest/globals';
|
||||||
|
import { container } from '../../../../src/config/index.js';
|
||||||
|
import { RecordingService, TaskSchedulerService } from '../../../../src/services';
|
||||||
|
import {
|
||||||
|
expectValidStartRecordingResponse,
|
||||||
|
expectValidStopRecordingResponse
|
||||||
|
} from '../../../helpers/assertion-helpers';
|
||||||
import { eventController } from '../../../helpers/event-controller';
|
import { eventController } from '../../../helpers/event-controller';
|
||||||
import {
|
import {
|
||||||
startRecording,
|
bulkDeleteRecordings,
|
||||||
sleep,
|
|
||||||
deleteAllRecordings,
|
deleteAllRecordings,
|
||||||
deleteAllRooms,
|
deleteAllRooms,
|
||||||
startTestServer,
|
|
||||||
stopRecording,
|
|
||||||
stopAllRecordings,
|
|
||||||
getRecordingMedia,
|
|
||||||
deleteRecording,
|
deleteRecording,
|
||||||
bulkDeleteRecordings
|
getRecordingMedia,
|
||||||
|
sleep,
|
||||||
|
startRecording,
|
||||||
|
startTestServer,
|
||||||
|
stopAllRecordings,
|
||||||
|
stopRecording
|
||||||
} from '../../../helpers/request-helpers';
|
} from '../../../helpers/request-helpers';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
setupMultiRecordingsTestContext,
|
setupMultiRecordingsTestContext,
|
||||||
setupMultiRoomTestContext,
|
setupMultiRoomTestContext,
|
||||||
TestContext
|
TestContext
|
||||||
} from '../../../helpers/test-scenarios';
|
} from '../../../helpers/test-scenarios';
|
||||||
import {
|
|
||||||
expectValidStartRecordingResponse,
|
|
||||||
expectValidStopRecordingResponse
|
|
||||||
} from '../../../helpers/assertion-helpers';
|
|
||||||
import { RecordingService, TaskSchedulerService } from '../../../../src/services';
|
|
||||||
import { container } from '../../../../src/config/dependency-injector.config';
|
|
||||||
|
|
||||||
describe('Recording API Race Conditions Tests', () => {
|
describe('Recording API Race Conditions Tests', () => {
|
||||||
let context: TestContext | null = null;
|
let context: TestContext | null = null;
|
||||||
let recordingService: RecordingService;
|
let recordingService: RecordingService;
|
||||||
let taskSchedulerService: TaskSchedulerService;
|
let taskSchedulerService: TaskSchedulerService;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
startTestServer();
|
startTestServer();
|
||||||
recordingService = container.get(RecordingService);
|
recordingService = container.get(RecordingService);
|
||||||
@ -48,8 +47,6 @@ describe('Recording API Race Conditions Tests', () => {
|
|||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async () => {});
|
|
||||||
|
|
||||||
it('should start recordings concurrently in two rooms and stop one before RECORDING_ACTIVE is received for the other', async () => {
|
it('should start recordings concurrently in two rooms and stop one before RECORDING_ACTIVE is received for the other', async () => {
|
||||||
context = await setupMultiRoomTestContext(2, true);
|
context = await setupMultiRoomTestContext(2, true);
|
||||||
const roomDataA = context.getRoomByIndex(0);
|
const roomDataA = context.getRoomByIndex(0);
|
||||||
|
|||||||
@ -1,5 +1,13 @@
|
|||||||
import { afterAll, afterEach, beforeAll, describe, expect, it } from '@jest/globals';
|
import { afterAll, afterEach, beforeAll, describe, expect, it } from '@jest/globals';
|
||||||
import { setInternalConfig } from '../../../../src/config/internal-config.js';
|
import { setInternalConfig } from '../../../../src/config/internal-config.js';
|
||||||
|
import { errorRoomNotFound } from '../../../../src/models/error.model.js';
|
||||||
|
import { MeetRoom } from '../../../../src/typings/ce/index.js';
|
||||||
|
import {
|
||||||
|
expectValidationError,
|
||||||
|
expectValidRecordingLocationHeader,
|
||||||
|
expectValidStartRecordingResponse,
|
||||||
|
expectValidStopRecordingResponse
|
||||||
|
} from '../../../helpers/assertion-helpers.js';
|
||||||
import {
|
import {
|
||||||
deleteAllRecordings,
|
deleteAllRecordings,
|
||||||
deleteAllRooms,
|
deleteAllRooms,
|
||||||
@ -10,15 +18,6 @@ import {
|
|||||||
stopAllRecordings,
|
stopAllRecordings,
|
||||||
stopRecording
|
stopRecording
|
||||||
} from '../../../helpers/request-helpers.js';
|
} from '../../../helpers/request-helpers.js';
|
||||||
|
|
||||||
import { errorRoomNotFound } from '../../../../src/models/error.model.js';
|
|
||||||
import { MeetRoom } from '../../../../src/typings/ce/room.js';
|
|
||||||
import {
|
|
||||||
expectValidationError,
|
|
||||||
expectValidRecordingLocationHeader,
|
|
||||||
expectValidStartRecordingResponse,
|
|
||||||
expectValidStopRecordingResponse
|
|
||||||
} from '../../../helpers/assertion-helpers.js';
|
|
||||||
import { setupMultiRoomTestContext, TestContext } from '../../../helpers/test-scenarios.js';
|
import { setupMultiRoomTestContext, TestContext } from '../../../helpers/test-scenarios.js';
|
||||||
|
|
||||||
describe('Recording API Tests', () => {
|
describe('Recording API Tests', () => {
|
||||||
@ -117,7 +116,7 @@ describe('Recording API Tests', () => {
|
|||||||
const response = await startRecording(room.roomId, moderatorCookie);
|
const response = await startRecording(room.roomId, moderatorCookie);
|
||||||
// Room exists but it has no participants
|
// Room exists but it has no participants
|
||||||
expect(response.status).toBe(409);
|
expect(response.status).toBe(409);
|
||||||
expect(response.body.message).toContain(`The room '${room.roomId}' has no participants`);
|
expect(response.body.message).toContain(`Room '${room.roomId}' has no participants`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should sanitize roomId and reject the request with 409 due to no participants', async () => {
|
it('should sanitize roomId and reject the request with 409 due to no participants', async () => {
|
||||||
@ -126,7 +125,7 @@ describe('Recording API Tests', () => {
|
|||||||
|
|
||||||
console.log('Response:', response.body);
|
console.log('Response:', response.body);
|
||||||
expect(response.status).toBe(409);
|
expect(response.status).toBe(409);
|
||||||
expect(response.body.message).toContain(`The room '${room.roomId}' has no participants`);
|
expect(response.body.message).toContain(`Room '${room.roomId}' has no participants`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reject request with roomId that becomes empty after sanitization', async () => {
|
it('should reject request with roomId that becomes empty after sanitization', async () => {
|
||||||
@ -152,7 +151,7 @@ describe('Recording API Tests', () => {
|
|||||||
const error = errorRoomNotFound('non-existing-room-id');
|
const error = errorRoomNotFound('non-existing-room-id');
|
||||||
expect(response.status).toBe(404);
|
expect(response.status).toBe(404);
|
||||||
expect(response.body).toEqual({
|
expect(response.body).toEqual({
|
||||||
name: error.name,
|
error: error.name,
|
||||||
message: error.message
|
message: error.message
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
import { describe, it, expect, beforeAll, afterAll } from '@jest/globals';
|
import { afterAll, beforeAll, describe, expect, it } from '@jest/globals';
|
||||||
import { expectValidStopRecordingResponse, expectErrorResponse } from '../../../helpers/assertion-helpers';
|
import { MeetRoom } from '../../../../src/typings/ce';
|
||||||
|
import { expectErrorResponse, expectValidStopRecordingResponse } from '../../../helpers/assertion-helpers';
|
||||||
import {
|
import {
|
||||||
startRecording,
|
|
||||||
disconnectFakeParticipants,
|
|
||||||
stopAllRecordings,
|
|
||||||
stopRecording,
|
|
||||||
deleteAllRecordings,
|
deleteAllRecordings,
|
||||||
deleteAllRooms,
|
deleteAllRooms,
|
||||||
startTestServer
|
disconnectFakeParticipants,
|
||||||
|
startRecording,
|
||||||
|
startTestServer,
|
||||||
|
stopAllRecordings,
|
||||||
|
stopRecording
|
||||||
} from '../../../helpers/request-helpers';
|
} from '../../../helpers/request-helpers';
|
||||||
import { MeetRoom } from '../../../../src/typings/ce';
|
|
||||||
import { setupMultiRoomTestContext, TestContext } from '../../../helpers/test-scenarios';
|
import { setupMultiRoomTestContext, TestContext } from '../../../helpers/test-scenarios';
|
||||||
|
|
||||||
describe('Recording API Tests', () => {
|
describe('Recording API Tests', () => {
|
||||||
@ -19,6 +19,7 @@ describe('Recording API Tests', () => {
|
|||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
startTestServer();
|
startTestServer();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
await stopAllRecordings(moderatorCookie);
|
await stopAllRecordings(moderatorCookie);
|
||||||
await disconnectFakeParticipants();
|
await disconnectFakeParticipants();
|
||||||
@ -67,7 +68,7 @@ describe('Recording API Tests', () => {
|
|||||||
it('should return 404 when recordingId does not exist', async () => {
|
it('should return 404 when recordingId does not exist', async () => {
|
||||||
const response = await stopRecording(`${room.roomId}--EG_123--444`, moderatorCookie);
|
const response = await stopRecording(`${room.roomId}--EG_123--444`, moderatorCookie);
|
||||||
expect(response.status).toBe(404);
|
expect(response.status).toBe(404);
|
||||||
expect(response.body.name).toBe('Recording Error');
|
expect(response.body.error).toBe('Recording Error');
|
||||||
expect(response.body.message).toContain('not found');
|
expect(response.body.message).toContain('not found');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -130,7 +130,7 @@ describe('Room API Tests', () => {
|
|||||||
|
|
||||||
expect(response.status).toBe(202);
|
expect(response.status).toBe(202);
|
||||||
|
|
||||||
expect(response.body.message).toContain(`Rooms ${room1.roomId}, ${room2.roomId} marked for deletion`);
|
expect(response.body.message).toContain(`Rooms '${room1.roomId}, ${room2.roomId}' marked for deletion`);
|
||||||
expect(response.body.deleted).toBeUndefined();
|
expect(response.body.deleted).toBeUndefined();
|
||||||
|
|
||||||
// Verify that the rooms are marked for deletion
|
// Verify that the rooms are marked for deletion
|
||||||
|
|||||||
@ -187,7 +187,7 @@ describe('Room API Tests', () => {
|
|||||||
.expect(400);
|
.expect(400);
|
||||||
|
|
||||||
expect(response.body.error).toContain('Bad Request');
|
expect(response.body.error).toContain('Bad Request');
|
||||||
expect(response.body.message).toContain('Malformed Body');
|
expect(response.body.message).toContain('Malformed body');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail when roomIdPrefix is too long', async () => {
|
it('should fail when roomIdPrefix is too long', async () => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user