const { chromium } = require('playwright'); function launchBrowser() { const channel = process.env.MEGURI_BROWSER_CHANNEL || 'chrome'; return chromium.launch({ headless: true, ...(channel === 'chromium' ? {} : { channel }), }); } exports.launchBrowser = launchBrowser; exports.openSetup = async (page, name) => { await page.waitForFunction(()=>window.Alpine && Alpine.$data(document.body).ready && Alpine.$data(document.body).workspace); const combined=['Schedules','Escalations & routing','Variables & rules'].includes(name); const target=page.getByRole('link',{name:combined?'Schedule setup':name,exact:true}); if(!await target.isVisible())await page.getByRole('button',{name:'Setup',exact:true}).click(); await target.click(); if(combined)await page.locator(name==='Schedules'?'#schedules':name==='Escalations & routing'?'#schedules':'#generation').scrollIntoViewIfNeeded(); };