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,6 +5,7 @@
import { browser, expect } from '@wdio/globals';
import * as S from '../helpers/selectors.ts';
import { clickProjectTab } from '../helpers/actions.ts';
import { exec } from '../helpers/execute.ts';
describe('Context tab', () => {
before(async () => {
@ -12,7 +13,7 @@ describe('Context tab', () => {
});
it('should render the context tab container', async () => {
const exists = await browser.execute((sel: string) => {
const exists = await exec((sel: string) => {
return document.querySelector(sel) !== null;
}, S.CONTEXT_TAB);
if (exists) {
@ -22,28 +23,28 @@ describe('Context tab', () => {
});
it('should show token meter', async () => {
const exists = await browser.execute((sel: string) => {
const exists = await exec((sel: string) => {
return document.querySelector(sel) !== null;
}, S.TOKEN_METER);
expect(typeof exists).toBe('boolean');
});
it('should show file references section', async () => {
const exists = await browser.execute((sel: string) => {
const exists = await exec((sel: string) => {
return document.querySelector(sel) !== null;
}, S.FILE_REFS);
expect(typeof exists).toBe('boolean');
});
it('should show turn count', async () => {
const exists = await browser.execute((sel: string) => {
const exists = await exec((sel: string) => {
return document.querySelector(sel) !== null;
}, S.TURN_COUNT);
expect(typeof exists).toBe('boolean');
});
it('should show stats bar', async () => {
const exists = await browser.execute(() => {
const exists = await exec(() => {
return (document.querySelector('.context-stats')
?? document.querySelector('.stats-bar')
?? document.querySelector('.context-header')) !== null;
@ -52,7 +53,7 @@ describe('Context tab', () => {
});
it('should show anchor section if available', async () => {
const exists = await browser.execute(() => {
const exists = await exec(() => {
return (document.querySelector('.anchor-section')
?? document.querySelector('.anchors')
?? document.querySelector('.anchor-budget')) !== null;
@ -61,7 +62,7 @@ describe('Context tab', () => {
});
it('should show segmented meter bar', async () => {
const exists = await browser.execute(() => {
const exists = await exec(() => {
return (document.querySelector('.segment-bar')
?? document.querySelector('.meter-bar')
?? document.querySelector('.progress-bar')) !== null;
@ -70,7 +71,7 @@ describe('Context tab', () => {
});
it('should show turn breakdown list', async () => {
const exists = await browser.execute(() => {
const exists = await exec(() => {
return (document.querySelector('.turn-list')
?? document.querySelector('.turn-breakdown')
?? document.querySelector('.context-turns')) !== null;
@ -79,7 +80,7 @@ describe('Context tab', () => {
});
it('should have proper layout dimensions', async () => {
const dims = await browser.execute(() => {
const dims = await exec(() => {
const el = document.querySelector('.context-tab');
if (!el) return null;
const rect = el.getBoundingClientRect();