- 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
77 lines
3.0 KiB
JavaScript
77 lines
3.0 KiB
JavaScript
// e2e/playwright/token-flow.js
|
|
// Simple E2E script using Playwright to validate token -> broadcast-panel -> studio flow.
|
|
// Usage: WS_ENDPOINT=ws://192.168.1.20:3003 BACKEND=http://127.0.0.1:4000 BROADCAST_URL=https://avanzacast-broadcastpanel.bfzqqk.easypanel.host node e2e/playwright/token-flow.js
|
|
|
|
const { chromium } = require('playwright');
|
|
const fetch = require('node-fetch');
|
|
|
|
(async () => {
|
|
try {
|
|
const WS = process.env.WS_ENDPOINT || process.env.BROWSER_WS || 'ws://192.168.1.20:3003';
|
|
const BACKEND = process.env.BACKEND || 'http://127.0.0.1:4000';
|
|
const BROADCAST = process.env.BROADCAST_URL || 'https://avanzacast-broadcastpanel.bfzqqk.easypanel.host';
|
|
|
|
console.log('Using ws endpoint:', WS);
|
|
console.log('Backend (token server):', BACKEND);
|
|
console.log('Broadcast panel url:', BROADCAST);
|
|
|
|
// 1) Request session/token from backend
|
|
const sessionResp = await fetch(`${BACKEND}/api/session`, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ room: 'e2e-room', username: 'e2e-cli' })
|
|
});
|
|
|
|
if (!sessionResp.ok) {
|
|
const text = await sessionResp.text();
|
|
throw new Error(`Backend /api/session failed: ${sessionResp.status} ${text}`);
|
|
}
|
|
|
|
const sessionJson = await sessionResp.json();
|
|
console.log('Session response:', sessionJson);
|
|
|
|
const redirectUrl = sessionJson.redirectUrl || sessionJson.studioUrl || `${BROADCAST}/?session=${sessionJson.id}`;
|
|
console.log('Will navigate to:', redirectUrl);
|
|
|
|
// 2) Connect to remote browser
|
|
const browser = await chromium.connect({ wsEndpoint: WS, timeout: 60000 });
|
|
const context = await browser.newContext({ viewport: { width: 1280, height: 800 } });
|
|
const page = await context.newPage();
|
|
|
|
// capture console messages
|
|
page.on('console', msg => console.log('PAGE LOG:', msg.type(), msg.text()));
|
|
|
|
// Navigate to redirect url
|
|
await page.goto(redirectUrl, { waitUntil: 'networkidle' });
|
|
console.log('Navigated. Waiting for StudioPortal or livekit logs...');
|
|
|
|
// Wait for StudioPortal element or a known selector
|
|
const SELECTOR = '[data-testid="studio-portal"]';
|
|
try {
|
|
await page.waitForSelector(SELECTOR, { timeout: 10000 });
|
|
console.log('StudioPortal element found:', SELECTOR);
|
|
} catch (e) {
|
|
console.log('StudioPortal selector not found; will look for LiveKit logs in console.');
|
|
}
|
|
|
|
// Look for text in page that indicates livekit attempted connection
|
|
const livekitText = await page.evaluate(() => {
|
|
return document.body.innerText.slice(0, 2000);
|
|
});
|
|
console.log('Page snippet:', livekitText.substring(0, 800));
|
|
|
|
// Wait some seconds for any WS attempts (validate calls) to appear in network logs
|
|
await page.waitForTimeout(5000);
|
|
|
|
console.log('E2E script finished — closing browser.');
|
|
await context.close();
|
|
await browser.close();
|
|
|
|
process.exit(0);
|
|
} catch (err) {
|
|
console.error('E2E script error:', err);
|
|
process.exit(2);
|
|
}
|
|
})();
|
|
|