- Add Next.js app structure with base configs, linting, and formatting - Implement LiveKit Meet page, types, and utility functions - Add Docker, Compose, and deployment scripts for backend and token server - Provide E2E and smoke test scaffolding with Puppeteer and Playwright helpers - Include CSS modules and global styles for UI - Add postMessage and studio integration utilities - Update package.json with dependencies and scripts for development and testing
62 lines
1.7 KiB
JavaScript
62 lines
1.7 KiB
JavaScript
// e2e/ws-test.js
|
|
// Simple WebSocket handshake tester using 'ws'
|
|
// Usage:
|
|
// node e2e/ws-test.js <wss://host:port/path?query> [--insecure]
|
|
// Or set env TOKEN to attach: TOKEN=abc node e2e/ws-test.js wss://host:port
|
|
|
|
const url = process.argv[2] || process.env.WS_URL;
|
|
const insecure = process.argv.includes('--insecure');
|
|
const token = process.env.TOKEN || process.argv.find(a => a.startsWith('token='))?.split('=')[1];
|
|
|
|
if (!url) {
|
|
console.error('Usage: node e2e/ws-test.js <wss://host:port> [--insecure]');
|
|
process.exit(2);
|
|
}
|
|
|
|
const WebSocket = require('ws');
|
|
const finalUrl = token && !url.includes('?') ? `${url}?token=${token}` : (token ? `${url}&token=${token}` : url);
|
|
console.log('Connecting to', finalUrl, 'insecure=', insecure);
|
|
|
|
const opts = {};
|
|
if (insecure) opts.rejectUnauthorized = false;
|
|
|
|
const ws = new WebSocket(finalUrl, opts);
|
|
|
|
let opened = false;
|
|
const timer = setTimeout(() => {
|
|
if (!opened) {
|
|
console.error('TIMEOUT waiting for open (10s)');
|
|
ws.terminate();
|
|
process.exit(3);
|
|
}
|
|
}, 10000);
|
|
|
|
ws.on('open', () => {
|
|
opened = true;
|
|
clearTimeout(timer);
|
|
console.log('WS_OPEN');
|
|
try {
|
|
const ping = JSON.stringify({ type: 'ping', ts: Date.now() });
|
|
ws.send(ping);
|
|
} catch(e){}
|
|
// Wait for message or close within 8s
|
|
setTimeout(() => {
|
|
console.log('Closing socket after wait');
|
|
ws.close();
|
|
}, 8000);
|
|
});
|
|
|
|
ws.on('message', (data) => {
|
|
console.log('WS_MESSAGE', data.toString().slice(0,1000));
|
|
});
|
|
|
|
ws.on('close', (code, reason) => {
|
|
console.log('WS_CLOSE', code, (reason || '').toString().slice(0,300));
|
|
process.exit(0);
|
|
});
|
|
|
|
ws.on('error', (err) => {
|
|
console.error('WS_ERROR', err && err.message ? err.message : err);
|
|
process.exit(4);
|
|
});
|