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

@ -5,10 +5,11 @@
import { browser, expect } from '@wdio/globals';
import * as S from '../helpers/selectors.ts';
import { sendPrompt } from '../helpers/actions.ts';
import { exec } from '../helpers/execute.ts';
describe('Agent pane', () => {
it('should show the prompt input area', async () => {
const exists = await browser.execute((sel: string) => {
const exists = await exec((sel: string) => {
return document.querySelector(sel) !== null;
}, S.CHAT_INPUT);
if (exists) {
@ -39,7 +40,7 @@ describe('Agent pane', () => {
});
it('should show idle status by default', async () => {
const text = await browser.execute((sel: string) => {
const text = await exec((sel: string) => {
const el = document.querySelector(sel);
return el?.textContent?.toLowerCase() ?? '';
}, S.AGENT_STATUS_TEXT);
@ -50,7 +51,7 @@ describe('Agent pane', () => {
it('should accept text in the prompt input', async () => {
await sendPrompt('test prompt');
const value = await browser.execute(() => {
const value = await exec(() => {
const ta = document.querySelector('.chat-input textarea') as HTMLTextAreaElement;
if (ta) return ta.value;
const inp = document.querySelector('.chat-input input') as HTMLInputElement;
@ -62,7 +63,7 @@ describe('Agent pane', () => {
});
it('should show provider indicator', async () => {
const text = await browser.execute((sel: string) => {
const text = await exec((sel: string) => {
const el = document.querySelector(sel);
return el?.textContent ?? '';
}, S.PROVIDER_BADGE);
@ -72,7 +73,7 @@ describe('Agent pane', () => {
});
it('should show cost display', async () => {
const exists = await browser.execute((sel: string) => {
const exists = await exec((sel: string) => {
return document.querySelector(sel) !== null;
}, S.AGENT_COST);
if (exists) {
@ -82,7 +83,7 @@ describe('Agent pane', () => {
});
it('should show model selector or label', async () => {
const exists = await browser.execute((sel: string) => {
const exists = await exec((sel: string) => {
return document.querySelector(sel) !== null;
}, S.MODEL_LABEL);
if (exists) {
@ -93,7 +94,7 @@ describe('Agent pane', () => {
it('should have tool call display structure', async () => {
// Tool calls render inside details elements
const hasStructure = await browser.execute(() => {
const hasStructure = await exec(() => {
return document.querySelector('.tool-call')
?? document.querySelector('.tool-group')
?? document.querySelector('details');
@ -103,7 +104,7 @@ describe('Agent pane', () => {
});
it('should have timeline dots container', async () => {
const exists = await browser.execute(() => {
const exists = await exec(() => {
return document.querySelector('.timeline')
?? document.querySelector('.turn-dots')
?? document.querySelector('.agent-timeline');
@ -115,7 +116,7 @@ describe('Agent pane', () => {
const stopBtn = await browser.$(S.STOP_BTN);
if (await stopBtn.isExisting()) {
// Stop button should not be displayed when agent is idle
const display = await browser.execute((sel: string) => {
const display = await exec((sel: string) => {
const el = document.querySelector(sel);
if (!el) return 'none';
return getComputedStyle(el).display;
@ -126,7 +127,7 @@ describe('Agent pane', () => {
});
it('should have context meter', async () => {
const exists = await browser.execute(() => {
const exists = await exec(() => {
return document.querySelector('.context-meter')
?? document.querySelector('.usage-meter')
?? document.querySelector('.token-meter');
@ -135,7 +136,7 @@ describe('Agent pane', () => {
});
it('should have prompt area with proper dimensions', async () => {
const dims = await browser.execute((sel: string) => {
const dims = await exec((sel: string) => {
const el = document.querySelector(sel);
if (!el) return null;
const rect = el.getBoundingClientRect();
@ -149,7 +150,7 @@ describe('Agent pane', () => {
it('should clear prompt after send attempt', async () => {
// Clear any existing text first
await browser.execute(() => {
await exec(() => {
const ta = document.querySelector('.chat-input textarea') as HTMLTextAreaElement;
if (ta) { ta.value = ''; ta.dispatchEvent(new Event('input')); }
});