test: update room configuration methods to accept partial configurations and enhance related tests
This commit is contained in:
parent
496591695a
commit
3f25ba6f74
@ -278,7 +278,7 @@ export const getRoomConfig = async (roomId: string): Promise<Response> => {
|
||||
.send();
|
||||
};
|
||||
|
||||
export const updateRoomConfig = async (roomId: string, config: MeetRoomConfig) => {
|
||||
export const updateRoomConfig = async (roomId: string, config: Partial<MeetRoomConfig>) => {
|
||||
checkAppIsRunning();
|
||||
|
||||
return await request(app)
|
||||
@ -292,12 +292,6 @@ export const updateRecordingAccessConfigInRoom = async (roomId: string, recordin
|
||||
recording: {
|
||||
enabled: true,
|
||||
allowAccessTo: recordingAccess
|
||||
},
|
||||
chat: {
|
||||
enabled: true
|
||||
},
|
||||
virtualBackground: {
|
||||
enabled: true
|
||||
}
|
||||
});
|
||||
expect(response.status).toBe(200);
|
||||
|
||||
@ -41,7 +41,7 @@ export interface TestContext {
|
||||
export const setupSingleRoom = async (
|
||||
withParticipant = false,
|
||||
roomName = 'TEST_ROOM',
|
||||
config?: MeetRoomConfig
|
||||
config?: Partial<MeetRoomConfig>
|
||||
): Promise<RoomData> => {
|
||||
const room = await createRoom({
|
||||
roomName,
|
||||
@ -79,7 +79,7 @@ export const setupSingleRoom = async (
|
||||
export const setupMultiRoomTestContext = async (
|
||||
numRooms: number,
|
||||
withParticipants: boolean,
|
||||
roomConfig?: MeetRoomConfig
|
||||
roomConfig?: Partial<MeetRoomConfig>
|
||||
): Promise<TestContext> => {
|
||||
const rooms: RoomData[] = [];
|
||||
|
||||
|
||||
@ -79,6 +79,58 @@ describe('Room API Tests', () => {
|
||||
payload.autoDeletionPolicy
|
||||
);
|
||||
});
|
||||
|
||||
it('Should create a room when sending partial config', async () => {
|
||||
const payload = {
|
||||
roomName: 'Partial Config Room',
|
||||
autoDeletionDate: validAutoDeletionDate,
|
||||
config: {
|
||||
recording: {
|
||||
enabled: false
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const room = await createRoom(payload);
|
||||
|
||||
const expectedConfig = {
|
||||
recording: {
|
||||
enabled: false
|
||||
},
|
||||
chat: { enabled: true }, // Default value
|
||||
virtualBackground: { enabled: true }, // Default value
|
||||
e2ee: { enabled: false } // Default value
|
||||
};
|
||||
expectValidRoom(room, 'Partial Config Room', 'partial_config_room', expectedConfig, validAutoDeletionDate);
|
||||
});
|
||||
|
||||
it('Should create a room when sending partial config with two fields', async () => {
|
||||
const payload = {
|
||||
roomName: 'Partial Config Room',
|
||||
autoDeletionDate: validAutoDeletionDate,
|
||||
config: {
|
||||
chat: {
|
||||
enabled: false
|
||||
},
|
||||
virtualBackground: {
|
||||
enabled: false
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const room = await createRoom(payload);
|
||||
|
||||
const expectedConfig = {
|
||||
recording: {
|
||||
enabled: true, // Default value
|
||||
allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_SPEAKER // Default value
|
||||
},
|
||||
chat: { enabled: false },
|
||||
virtualBackground: { enabled: false },
|
||||
e2ee: { enabled: false } // Default value
|
||||
};
|
||||
expectValidRoom(room, 'Partial Config Room', 'partial_config_room', expectedConfig, validAutoDeletionDate);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Room Name Sanitization Tests', () => {
|
||||
|
||||
@ -38,7 +38,7 @@ describe('E2EE Room Configuration Tests', () => {
|
||||
|
||||
expectValidRoom(room, 'Test E2EE Default');
|
||||
expect(room.config.e2ee).toBeDefined();
|
||||
expect(room.config.e2ee?.enabled).toBe(false);
|
||||
expect(room.config.e2ee.enabled).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@ -60,7 +60,7 @@ describe('E2EE Room Configuration Tests', () => {
|
||||
const room = await createRoom(payload);
|
||||
|
||||
expect(room.roomName).toBe('Test E2EE Enabled');
|
||||
expect(room.config.e2ee?.enabled).toBe(true);
|
||||
expect(room.config.e2ee.enabled).toBe(true);
|
||||
expect(room.config.recording.enabled).toBe(false); // Recording should be disabled
|
||||
});
|
||||
});
|
||||
@ -68,12 +68,6 @@ describe('E2EE Room Configuration Tests', () => {
|
||||
describe('E2EE and Recording Interaction', () => {
|
||||
it('Should not allow starting recording in a room with E2EE enabled', async () => {
|
||||
const context = await setupMultiRoomTestContext(1, true, {
|
||||
recording: {
|
||||
enabled: true,
|
||||
allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_SPEAKER
|
||||
},
|
||||
chat: { enabled: true },
|
||||
virtualBackground: { enabled: true },
|
||||
e2ee: { enabled: true }
|
||||
});
|
||||
|
||||
@ -107,15 +101,8 @@ describe('E2EE Room Configuration Tests', () => {
|
||||
|
||||
// Update room to enable E2EE (recording should be automatically disabled)
|
||||
const updatedConfig = {
|
||||
recording: {
|
||||
enabled: true, // This should be automatically disabled
|
||||
allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_SPEAKER
|
||||
},
|
||||
chat: { enabled: true },
|
||||
virtualBackground: { enabled: true },
|
||||
e2ee: { enabled: true }
|
||||
};
|
||||
|
||||
const response = await updateRoomConfig(room.roomId, updatedConfig);
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
@ -124,11 +111,9 @@ describe('E2EE Room Configuration Tests', () => {
|
||||
const { status, body: config } = await getRoomConfig(room.roomId);
|
||||
|
||||
expect(status).toBe(200);
|
||||
expect(config.e2ee?.enabled).toBe(true);
|
||||
expect(config.e2ee.enabled).toBe(true);
|
||||
expect(config.recording.enabled).toBe(false);
|
||||
});
|
||||
|
||||
// TODO: Add test for enabling E2EE when there are active recordings in the room
|
||||
});
|
||||
|
||||
describe('E2EE Validation Tests', () => {
|
||||
@ -185,7 +170,7 @@ describe('E2EE Room Configuration Tests', () => {
|
||||
roomName: 'Test E2EE Update Enabled'
|
||||
});
|
||||
|
||||
expect(room.config.e2ee?.enabled).toBe(false);
|
||||
expect(room.config.e2ee.enabled).toBe(false);
|
||||
|
||||
const { status, body } = await updateRoomConfig(room.roomId, {
|
||||
recording: {
|
||||
@ -203,7 +188,7 @@ describe('E2EE Room Configuration Tests', () => {
|
||||
// Fetch the updated room to verify changes
|
||||
const { body: config } = await getRoomConfig(room.roomId);
|
||||
|
||||
expect(config.e2ee?.enabled).toBe(true);
|
||||
expect(config.e2ee.enabled).toBe(true);
|
||||
expect(config.recording.enabled).toBe(false);
|
||||
});
|
||||
});
|
||||
@ -253,10 +238,10 @@ describe('E2EE Room Configuration Tests', () => {
|
||||
const e2eeEnabledRoom = testRooms.find((r: MeetRoom) => r.roomId === room1.roomId);
|
||||
const e2eeDisabledRoom = testRooms.find((r: MeetRoom) => r.roomId === room2.roomId);
|
||||
|
||||
expect(e2eeEnabledRoom.config.e2ee?.enabled).toBe(true);
|
||||
expect(e2eeEnabledRoom.config.e2ee.enabled).toBe(true);
|
||||
expect(e2eeEnabledRoom.config.recording.enabled).toBe(false);
|
||||
|
||||
expect(e2eeDisabledRoom.config.e2ee?.enabled).toBe(false);
|
||||
expect(e2eeDisabledRoom.config.e2ee.enabled).toBe(false);
|
||||
expect(e2eeDisabledRoom.config.recording.enabled).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@ -97,12 +97,8 @@ describe('Room API Tests', () => {
|
||||
// Update only one config field
|
||||
const partialConfig = {
|
||||
recording: {
|
||||
enabled: false,
|
||||
allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_SPEAKER
|
||||
},
|
||||
chat: { enabled: true },
|
||||
virtualBackground: { enabled: true },
|
||||
e2ee: { enabled: false }
|
||||
enabled: false
|
||||
}
|
||||
};
|
||||
const updateResponse = await updateRoomConfig(createdRoom.roomId, partialConfig);
|
||||
|
||||
@ -113,7 +109,16 @@ describe('Room API Tests', () => {
|
||||
// Verify with a get request
|
||||
const getResponse = await getRoom(createdRoom.roomId);
|
||||
expect(getResponse.status).toBe(200);
|
||||
expect(getResponse.body.config).toEqual(partialConfig);
|
||||
|
||||
const expectedConfig: MeetRoomConfig = {
|
||||
recording: {
|
||||
enabled: false
|
||||
},
|
||||
chat: { enabled: true },
|
||||
virtualBackground: { enabled: true },
|
||||
e2ee: { enabled: false }
|
||||
};
|
||||
expect(getResponse.body.config).toEqual(expectedConfig);
|
||||
});
|
||||
|
||||
it('should reject room config update when there is an active meeting', async () => {
|
||||
@ -161,26 +166,6 @@ describe('Room API Tests', () => {
|
||||
});
|
||||
|
||||
describe('Update Room Config Validation failures', () => {
|
||||
it('should fail when config has incorrect structure', async () => {
|
||||
const { roomId } = await createRoom({
|
||||
roomName: 'validation-test'
|
||||
});
|
||||
|
||||
// Invalid config (missing required fields)
|
||||
const invalidConfig = {
|
||||
recording: {
|
||||
enabled: false
|
||||
},
|
||||
// Missing chat config
|
||||
virtualBackground: { enabled: false }
|
||||
};
|
||||
const response = await updateRoomConfig(roomId, invalidConfig as unknown as MeetRoomConfig);
|
||||
|
||||
expect(response.status).toBe(422);
|
||||
expect(response.body.error).toContain('Unprocessable Entity');
|
||||
expect(JSON.stringify(response.body.details)).toContain('chat');
|
||||
});
|
||||
|
||||
it('should fail when config has incorrect types', async () => {
|
||||
const createdRoom = await createRoom({
|
||||
roomName: 'type-test'
|
||||
@ -202,18 +187,6 @@ describe('Room API Tests', () => {
|
||||
expect(JSON.stringify(response.body.details)).toContain('recording.enabled');
|
||||
});
|
||||
|
||||
it('should fail when config is missing required properties', async () => {
|
||||
const createdRoom = await createRoom({
|
||||
roomName: 'missing-props'
|
||||
});
|
||||
|
||||
const emptyConfig = {};
|
||||
const response = await updateRoomConfig(createdRoom.roomId, emptyConfig as unknown as MeetRoomConfig);
|
||||
|
||||
expect(response.status).toBe(422);
|
||||
expect(response.body.error).toContain('Unprocessable Entity');
|
||||
});
|
||||
|
||||
it('should fail when recording is enabled but allowAccessTo is missing', async () => {
|
||||
const createdRoom = await createRoom({
|
||||
roomName: 'missing-access'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user