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