backend: Update room test cases to use await for participant joining
This commit is contained in:
parent
dae12bcbe4
commit
28fb0a594e
@ -48,9 +48,8 @@ describe('OpenVidu Meet Room API Tests', () => {
|
||||
it('should mark room for deletion (202) with invalid force parameter when participants exist', async () => {
|
||||
const { roomId } = await createRoom({ roomIdPrefix: 'test-invalid-force' });
|
||||
|
||||
joinFakeParticipant(roomId, 'test-participant-1');
|
||||
await joinFakeParticipant(roomId, 'test-participant-1');
|
||||
|
||||
await sleep(1000);
|
||||
const response = await bulkDeleteRooms([roomId]);
|
||||
|
||||
//The bulk operation for only one room should be the same as deleting the room
|
||||
@ -71,9 +70,8 @@ describe('OpenVidu Meet Room API Tests', () => {
|
||||
it('should delete room (204) with force=true parameter when participants exist', async () => {
|
||||
const { roomId } = await createRoom({ roomIdPrefix: 'test-force' });
|
||||
|
||||
joinFakeParticipant(roomId, 'test-participant-1');
|
||||
await joinFakeParticipant(roomId, 'test-participant-1');
|
||||
|
||||
await sleep(1000);
|
||||
const response = await bulkDeleteRooms([roomId], true);
|
||||
|
||||
//The bulk operation for only one room should be the same as deleting the room
|
||||
@ -128,9 +126,10 @@ describe('OpenVidu Meet Room API Tests', () => {
|
||||
createRoom({ roomIdPrefix: 'test-bulk-2' })
|
||||
]);
|
||||
|
||||
joinFakeParticipant(room1.roomId, 'test-participant-1');
|
||||
joinFakeParticipant(room2.roomId, 'test-participant-2');
|
||||
await sleep(1000);
|
||||
await Promise.all([
|
||||
joinFakeParticipant(room1.roomId, 'test-participant-1'),
|
||||
joinFakeParticipant(room2.roomId, 'test-participant-2')
|
||||
]);
|
||||
|
||||
// Delete both rooms
|
||||
const response = await bulkDeleteRooms([room1.roomId, room2.roomId]);
|
||||
@ -171,10 +170,10 @@ describe('OpenVidu Meet Room API Tests', () => {
|
||||
]);
|
||||
|
||||
// Join a participant to the room
|
||||
joinFakeParticipant(room1.roomId, 'test-participant-1');
|
||||
joinFakeParticipant(room2.roomId, 'test-participant-2');
|
||||
|
||||
await sleep(1000);
|
||||
await Promise.all([
|
||||
joinFakeParticipant(room1.roomId, 'test-participant-1'),
|
||||
joinFakeParticipant(room2.roomId, 'test-participant-2')
|
||||
]);
|
||||
|
||||
// Attempt to delete the room with force=false
|
||||
const response = await bulkDeleteRooms([room1.roomId, room2.roomId], true);
|
||||
@ -197,8 +196,7 @@ describe('OpenVidu Meet Room API Tests', () => {
|
||||
const room2 = await createRoom({ roomIdPrefix: 'occupied-room' });
|
||||
|
||||
// Add participant to only one room
|
||||
joinFakeParticipant(room2.roomId, 'test-participant');
|
||||
await sleep(1000);
|
||||
await joinFakeParticipant(room2.roomId, 'test-participant');
|
||||
|
||||
// Delete both rooms (without force)
|
||||
const response = await bulkDeleteRooms([room1.roomId, room2.roomId], false);
|
||||
@ -239,8 +237,7 @@ describe('OpenVidu Meet Room API Tests', () => {
|
||||
Array.from({ length: 20 }, (_, i) => createRoom({ roomIdPrefix: `bulk-${i}` }))
|
||||
);
|
||||
|
||||
joinFakeParticipant(rooms[0].roomId, 'test-participant-1');
|
||||
await sleep(1000);
|
||||
await joinFakeParticipant(rooms[0].roomId, 'test-participant-1');
|
||||
|
||||
const response = await bulkDeleteRooms([
|
||||
...rooms.map((r) => r.roomId),
|
||||
|
||||
@ -53,9 +53,7 @@ describe('OpenVidu Meet Room API Tests', () => {
|
||||
roomIdPrefix: 'test-room'
|
||||
});
|
||||
|
||||
joinFakeParticipant(roomId, 'test-participant');
|
||||
|
||||
await sleep(500);
|
||||
await joinFakeParticipant(roomId, 'test-participant');
|
||||
|
||||
// The force parameter is not a boolean so it should be defined as false
|
||||
// and the room should be marked for deletion
|
||||
@ -122,9 +120,7 @@ describe('OpenVidu Meet Room API Tests', () => {
|
||||
autoDeletionDate: Date.now() + ms('5h')
|
||||
});
|
||||
|
||||
joinFakeParticipant(roomId, 'test-participant');
|
||||
|
||||
await sleep(500);
|
||||
await joinFakeParticipant(roomId, 'test-participant');
|
||||
|
||||
const response = await deleteRoom(roomId, { force: false });
|
||||
|
||||
@ -148,9 +144,7 @@ describe('OpenVidu Meet Room API Tests', () => {
|
||||
roomIdPrefix: 'test-room'
|
||||
});
|
||||
|
||||
joinFakeParticipant(roomId, 'test-participant');
|
||||
|
||||
await sleep(500);
|
||||
await joinFakeParticipant(roomId, 'test-participant');
|
||||
|
||||
const response = await deleteRoom(roomId, { force: true });
|
||||
|
||||
@ -165,8 +159,8 @@ describe('OpenVidu Meet Room API Tests', () => {
|
||||
const { roomId } = await createRoom({ roomIdPrefix: 'test-marked' });
|
||||
|
||||
// First mark it for deletion
|
||||
joinFakeParticipant(roomId, 'test-participant');
|
||||
await sleep(500);
|
||||
await joinFakeParticipant(roomId, 'test-participant');
|
||||
|
||||
await deleteRoom(roomId, { force: false });
|
||||
|
||||
// Then try to delete it again
|
||||
|
||||
@ -12,11 +12,11 @@ import {
|
||||
getRooms
|
||||
} from '../../../utils/helpers.js';
|
||||
import ms from 'ms';
|
||||
import { setPrivateConfig } from '../../../../src/config/internal-config.js';
|
||||
import { setInternalConfig } from '../../../../src/config/internal-config.js';
|
||||
|
||||
describe('OpenVidu Meet Room Garbage Collector Tests', () => {
|
||||
beforeAll(async () => {
|
||||
setPrivateConfig({
|
||||
setInternalConfig({
|
||||
MIN_FUTURE_TIME_FOR_ROOM_AUTODELETION_DATE: '0s'
|
||||
});
|
||||
await startTestServer();
|
||||
@ -56,8 +56,7 @@ describe('OpenVidu Meet Room Garbage Collector Tests', () => {
|
||||
autoDeletionDate: Date.now() + ms('1s')
|
||||
});
|
||||
|
||||
joinFakeParticipant(createdRoom.roomId, 'test-participant');
|
||||
await sleep(2000);
|
||||
await joinFakeParticipant(createdRoom.roomId, 'test-participant');
|
||||
|
||||
await runRoomGarbageCollector();
|
||||
|
||||
@ -86,7 +85,7 @@ describe('OpenVidu Meet Room Garbage Collector Tests', () => {
|
||||
autoDeletionDate: Date.now() + ms('1s')
|
||||
});
|
||||
|
||||
joinFakeParticipant(createdRoom.roomId, 'test-participant');
|
||||
await joinFakeParticipant(createdRoom.roomId, 'test-participant');
|
||||
|
||||
// Wait for the auto-deletion date to pass
|
||||
await sleep(1000);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user