(agent)
| 51 | } |
| 52 | |
| 53 | async function openBrowser(agent) { |
| 54 | browser = await chromium.launch({ headless: true, args: ['--disable-background-networking'] }); |
| 55 | const context = await browser.newContext({ viewport: { width: 1600, height: 1060 }, serviceWorkers: 'block' }); |
| 56 | let interrupt = false; |
| 57 | await context.route('**/*', async route => { |
| 58 | const url = route.request().url(); |
| 59 | if (!url.startsWith(ORIGIN + '/') && !url.startsWith('data:') && !url.startsWith('blob:')) { |
| 60 | report.externalAttempts.push(url); |
| 61 | return route.abort(); |
| 62 | } |
| 63 | if (interrupt && new URL(url).pathname === '/api/agent-events') return route.abort('connectionfailed'); |
| 64 | return route.continue(); |
| 65 | }); |
| 66 | await context.addInitScript(() => { |
| 67 | localStorage.setItem('cbm.workspace.setup', 'done'); |
| 68 | localStorage.setItem('cbm.workspace', 'agents'); |
| 69 | }); |
| 70 | const page = await context.newPage(); |
| 71 | page.on('request', request => report.browserRequests.push(request.url())); |
| 72 | // A legacy port override must have no effect on the new source. |
| 73 | await page.goto(`${ORIGIN}/?project=${PROJECT}&agents=4142`); |
| 74 | await page.locator('.cbm-activity').waitFor({ timeout: 30000 }); |
| 75 | const agentCalls = () => report.browserRequests.filter(url => new URL(url).pathname === '/api/agent-events').length; |
| 76 | const beforeOff = agentCalls(); |
| 77 | await delay(1200); |
| 78 | assert.equal(agentCalls(), beforeOff, 'Off mode must not send any activity requests'); |
| 79 | await page.getByRole('button', { name: 'Load live activity', exact: true }).click(); |
| 80 | await page.locator('.cbm-activity-connection [data-state="connected"]').waitFor({ timeout: 20000 }); |
| 81 | await page.getByLabel('Agent', { exact: true }).selectOption({ label: agent }); |
| 82 | return { page, agentCalls, interrupt: value => { interrupt = value; } }; |
| 83 | } |
| 84 | |
| 85 | async function waitRows(page, expected) { |
| 86 | await page.waitForFunction(count => document.querySelectorAll('.cbm-activity-row').length === count, |
no test coverage detected