Show users in voice channels before joining
This commit is contained in:
1 parent
a29bd58b0c
commit
dee8ef4f7c
3 files changed
+185
-82
No files matched your search
@@ -38,15 +38,23 @@ test('server HTTP and WebSocket signaling endpoints', async (t) => {
|
||||
const healthText = await resHealth.text();
|
||||
assert.strictEqual(healthText, 'ok');
|
||||
|
||||
// test /api/rooms initially empty
|
||||
const resRoomsInit = await fetch(`http://127.0.0.1:${port}/api/rooms`);
|
||||
assert.strictEqual(resRoomsInit.status, 200);
|
||||
const roomsInit = await resRoomsInit.json();
|
||||
assert.deepStrictEqual(roomsInit, {});
|
||||
|
||||
// test WebSocket signaling /ws
|
||||
const { WebSocket } = require('ws');
|
||||
const ws = new WebSocket(`ws://127.0.0.1:${port}/ws?room=testroom&name=tester`);
|
||||
|
||||
const messages = [];
|
||||
const helloPromise = new Promise((resolve, reject) => {
|
||||
ws.on('message', (raw) => {
|
||||
try {
|
||||
const msg = JSON.parse(raw.toString());
|
||||
resolve(msg);
|
||||
messages.push(msg);
|
||||
if (msg.type === 'hello') resolve(msg);
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
@@ -55,10 +63,19 @@ test('server HTTP and WebSocket signaling endpoints', async (t) => {
|
||||
});
|
||||
|
||||
const msg = await helloPromise;
|
||||
ws.close();
|
||||
assert.strictEqual(msg.type, 'hello');
|
||||
assert.strictEqual(msg.room, 'testroom');
|
||||
assert.ok(msg.id, 'client id assigned');
|
||||
|
||||
// test /api/rooms while tester is connected
|
||||
const resRoomsActive = await fetch(`http://127.0.0.1:${port}/api/rooms`);
|
||||
assert.strictEqual(resRoomsActive.status, 200);
|
||||
const roomsActive = await resRoomsActive.json();
|
||||
assert.ok(roomsActive.testroom, 'testroom present in /api/rooms');
|
||||
assert.strictEqual(roomsActive.testroom.length, 1);
|
||||
assert.strictEqual(roomsActive.testroom[0].name, 'tester');
|
||||
|
||||
ws.close();
|
||||
});
|
||||
|
||||
test('TURN credentials generation with TURN_SECRET', () => {
|
||||
|
||||
Reference in new issue
Block a user