// Isolated broadcaster UI: the only capturable display source is a generated QA window. // No real server, microphone, private screen, private camera, or persistent profile is used. // Run ONLY inside an isolated virtual display; never on the owner's Windows desktop. import { closeSettings, launchApp } from './lib/electron-app.mjs'; import assert from 'node:assert/strict'; import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'; import { tmpdir } from 'node:os'; import path from 'node:path'; const args = process.argv.slice(2); const opt = (key, fallback) => args.includes(`--${key}`) ? args[args.indexOf(`--${key}`) + 1] : fallback; const injectedCapture = args.includes('--offscreen-fixture'); if (!injectedCapture && process.platform === 'win32') throw new Error('Native capture smoke is disabled on Windows. Use the separate injected-capture offscreen smoke.'); if (!injectedCapture && (process.env.TEAMSPEACH_ISOLATED_DISPLAY !== '1' || !process.env.DISPLAY)) throw new Error('Native capture needs an explicitly isolated virtual DISPLAY (TEAMSPEACH_ISOLATED_DISPLAY=1).'); const out = path.resolve(opt('out', 'smoke-out/broadcast-ui')); const profile = mkdtempSync(path.join(tmpdir(), 'teamspeach-broadcast-ui-')); mkdirSync(out, { recursive: true }); const result = { scope: injectedCapture ? 'Offscreen real renderer; injected generated canvas capture and synthetic signaling. Not native capture, permissions, TS6 interoperability or platform proof.' : 'Hidden generated QA source, synthetic signaling IPC. Native capture unavailable offscreen is not a pass.', checks: [], screenshots: [], errors: [] }; let app; let page; const check = (name, data = {}) => result.checks.push({ name, ...data }); const snapshot = { event: 'snapshot', rev: 1, own_client_id: 1, own_channel_id: 10, server: { name: 'Broadcast QA', version: 'fixture', welcome_message: '' }, channels: [{ id: 10, parent_id: 0, order: 0, depth: 0, name: 'Generated media only', topic: '', codec: 'opus_voice', needed_talk_power: 0, has_password: false }], clients: [ { id: 1, uid: 'qa-broadcaster', nickname: 'Broadcaster', channel_id: 10, is_self: true, input_muted: true, output_muted: true, server_groups: [] }, { id: 2, uid: 'qa-selected', nickname: 'Selected viewer', channel_id: 10, input_muted: true, output_muted: true, server_groups: [] }, { id: 3, uid: 'qa-other', nickname: 'Other viewer', channel_id: 10, input_muted: true, output_muted: true, server_groups: [] }, ], server_groups: [], channel_groups: [], }; const commands = () => app.evaluate(() => globalThis.__broadcastUI.commands); const send = (event) => app.evaluate(({ BrowserWindow }, value) => { const main = BrowserWindow.getAllWindows().find(win => win.webContents.getURL().startsWith('app://')); main.webContents.send('core:event', { ...value, connectionId: 'c1' }); }, event); const source = () => page.locator('.broadcast-source').filter({ hasText: 'TeamsPeach Generated Broadcast QA' }); const open = async () => { await page.locator('#broadcast-controls button').first().click(); await source().waitFor({ state: 'visible' }); }; const preview = async () => { await source().click(); await page.getByRole('button', { name: /^(Next|Далее)$/ }).click(); await page.waitForFunction(() => { const video = document.querySelector('.broadcast-preview video'); return video?.srcObject && video.videoWidth > 0 && !document.querySelector('.broadcast-settings').hidden; }); }; // Wide dialogs show segmented pills; narrow ones (data-collapsed) show the same choices as a