fix(e2e): cross-protocol browser.execute() — works with both WebDriver + CDP

Root cause: WebDriverIO devtools protocol wraps functions in a polyfill
that puts `return` inside eval() (not a function body) → "Illegal return".

Fix: exec() wrapper in helpers/execute.ts converts function args to IIFE
strings before passing to browser.execute(). Works identically on both
WebDriver (Tauri) and CDP/devtools (Electrobun CEF).

- 35 spec files updated (browser.execute → exec)
- 4 config files updated (string-form expressions)
- helpers/actions.ts + assertions.ts updated
- 560 vitest + 116 cargo passing
This commit is contained in:
Hibryda 2026-03-22 06:33:55 +01:00
parent 407e49cc32
commit 6a8181f33a
42 changed files with 630 additions and 541 deletions

View file

@ -7,6 +7,7 @@
import { browser, expect } from '@wdio/globals';
import * as S from '../helpers/selectors.ts';
import { assertStatusBarComplete } from '../helpers/assertions.ts';
import { exec } from '../helpers/execute.ts';
describe('Status bar', () => {
it('should be visible at the bottom', async () => {
@ -14,7 +15,7 @@ describe('Status bar', () => {
});
it('should show version text', async () => {
const text = await browser.execute(() => {
const text = await exec(() => {
const el = document.querySelector('.status-bar .version');
return el?.textContent?.trim() ?? '';
});
@ -24,7 +25,7 @@ describe('Status bar', () => {
});
it('should show agent state counts', async () => {
const exists = await browser.execute(() => {
const exists = await exec(() => {
// Tauri uses inline spans (.state-running, .state-idle, .state-stalled)
// Electrobun uses .agent-counts
return (document.querySelector('.agent-counts')
@ -35,14 +36,14 @@ describe('Status bar', () => {
});
it('should show burn rate', async () => {
const exists = await browser.execute(() => {
const exists = await exec(() => {
return document.querySelector('.burn-rate') !== null;
});
expect(typeof exists).toBe('boolean');
});
it('should show attention queue dropdown', async () => {
const exists = await browser.execute(() => {
const exists = await exec(() => {
// Tauri: .attention-btn | Electrobun: .attention-queue
return (document.querySelector('.attention-queue')
?? document.querySelector('.attention-btn')) !== null;
@ -51,7 +52,7 @@ describe('Status bar', () => {
});
it('should show total tokens', async () => {
const exists = await browser.execute(() => {
const exists = await exec(() => {
return (document.querySelector('.fleet-tokens')
?? document.querySelector('.tokens')) !== null;
});
@ -59,7 +60,7 @@ describe('Status bar', () => {
});
it('should show total cost', async () => {
const exists = await browser.execute(() => {
const exists = await exec(() => {
return (document.querySelector('.fleet-cost')
?? document.querySelector('.cost')) !== null;
});
@ -67,7 +68,7 @@ describe('Status bar', () => {
});
it('should show project count', async () => {
const exists = await browser.execute(() => {
const exists = await exec(() => {
// Tauri embeds count in text, Electrobun uses .project-count
const hasClass = document.querySelector('.project-count') !== null;
const hasText = (document.querySelector('.status-bar')?.textContent ?? '').includes('project');
@ -77,7 +78,7 @@ describe('Status bar', () => {
});
it('should have proper height and layout', async () => {
const dims = await browser.execute(() => {
const dims = await exec(() => {
const el = document.querySelector('[data-testid="status-bar"]')
?? document.querySelector('.status-bar');
if (!el) return null;
@ -92,7 +93,7 @@ describe('Status bar', () => {
});
it('should use theme colors', async () => {
const bg = await browser.execute(() => {
const bg = await exec(() => {
const el = document.querySelector('[data-testid="status-bar"]')
?? document.querySelector('.status-bar');
if (!el) return '';
@ -104,7 +105,7 @@ describe('Status bar', () => {
});
it('should show agent running/idle/stalled counts', async () => {
const text = await browser.execute(() => {
const text = await exec(() => {
const el = document.querySelector('[data-testid="status-bar"]')
?? document.querySelector('.status-bar');
return el?.textContent ?? '';
@ -113,7 +114,7 @@ describe('Status bar', () => {
});
it('should show attention queue cards on click', async () => {
const dropdown = await browser.execute(() => {
const dropdown = await exec(() => {
const btn = document.querySelector('.attention-queue')
?? document.querySelector('.attention-btn');
if (btn) (btn as HTMLElement).click();
@ -122,7 +123,7 @@ describe('Status bar', () => {
});
expect(dropdown !== undefined).toBe(true);
// Close by clicking elsewhere
await browser.execute(() => document.body.click());
await exec(() => document.body.click());
await browser.pause(200);
});
});