32 lines
1.3 KiB
JavaScript
32 lines
1.3 KiB
JavaScript
import { chromium } from 'playwright';
|
|
|
|
const WS = process.env.PLAYWRIGHT_WS_ENDPOINT || 'ws://192.168.1.20:3003';
|
|
const REDIR = process.env.REDIR_URL;
|
|
|
|
(async ()=>{
|
|
if (!REDIR) {
|
|
console.error('REDIR_URL not provided');
|
|
process.exit(2);
|
|
}
|
|
const browser = await chromium.connect({ wsEndpoint: WS });
|
|
const context = await browser.newContext();
|
|
const page = await context.newPage();
|
|
page.on('console', m => console.log('PAGE:', m.text()));
|
|
try {
|
|
await page.goto(REDIR, { waitUntil: 'networkidle', timeout: 30000 });
|
|
await page.waitForSelector('.studio-portal .layout-btn', { timeout: 5000 }).catch(()=>{});
|
|
// click second layout
|
|
await page.evaluate(()=>{ const btns = document.querySelectorAll('.layout-btn'); if (btns && btns[1]) (btns[1] as HTMLElement).click(); });
|
|
await page.waitForFunction(()=> !!document.querySelector('.studio-room')?.getAttribute('data-layout'), { timeout: 3000 }).catch(()=>{});
|
|
await page.evaluate(()=>{ const rec = document.querySelector('.btn-record') as HTMLElement; if(rec) rec.click(); });
|
|
await page.waitForTimeout(1500);
|
|
await page.screenshot({ path: '/tmp/e2e_portal_interaction.png', fullPage:true});
|
|
console.log('PAGE URL', page.url());
|
|
} catch (err) {
|
|
console.error('E2E error', err);
|
|
} finally {
|
|
await browser.close();
|
|
}
|
|
})();
|
|
|