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

@ -1,4 +1,5 @@
import { browser, expect } from '@wdio/globals';
import { exec } from '../helpers/execute.ts';
// Phase A — Structure: App structural integrity + settings panel + NEW structural tests.
// Shares a single Tauri app session with other phase-a-* spec files.
@ -22,7 +23,7 @@ describe('Scenario 1 — App Structural Integrity', () => {
});
it('should have data-project-id on project boxes', async () => {
const projectId = await browser.execute(() => {
const projectId = await exec(() => {
const box = document.querySelector('[data-testid="project-box"]');
return box?.getAttribute('data-project-id') ?? null;
});
@ -50,7 +51,7 @@ describe('Scenario 1 — App Structural Integrity', () => {
it('should have data-testid on status bar sections (agent-counts, cost, attention)', async () => {
// Status bar left section contains agent state items and attention
const leftItems = await browser.execute(() => {
const leftItems = await exec(() => {
const bar = document.querySelector('[data-testid="status-bar"]');
if (!bar) return { left: false, right: false };
const left = bar.querySelector('.left');
@ -62,7 +63,7 @@ describe('Scenario 1 — App Structural Integrity', () => {
});
it('should render project accent colors (different per slot)', async () => {
const accents = await browser.execute(() => {
const accents = await exec(() => {
const boxes = document.querySelectorAll('[data-testid="project-box"]');
const styles: string[] = [];
boxes.forEach(box => {
@ -83,7 +84,7 @@ describe('Scenario 1 — App Structural Integrity', () => {
});
it('should show project name in header', async () => {
const name = await browser.execute(() => {
const name = await exec(() => {
const el = document.querySelector('.project-header .project-name');
return el?.textContent?.trim() ?? '';
});
@ -91,7 +92,7 @@ describe('Scenario 1 — App Structural Integrity', () => {
});
it('should show project icon in header', async () => {
const icon = await browser.execute(() => {
const icon = await exec(() => {
const el = document.querySelector('.project-header .project-icon');
return el?.textContent?.trim() ?? '';
});
@ -100,7 +101,7 @@ describe('Scenario 1 — App Structural Integrity', () => {
});
it('should have correct grid layout (project boxes fill available space)', async () => {
const layout = await browser.execute(() => {
const layout = await exec(() => {
const box = document.querySelector('[data-testid="project-box"]') as HTMLElement | null;
if (!box) return { width: 0, height: 0 };
const rect = box.getBoundingClientRect();
@ -117,7 +118,7 @@ describe('Scenario 1 — App Structural Integrity', () => {
describe('Scenario 2 — Settings Panel (data-testid)', () => {
before(async () => {
// Ensure settings panel is closed before starting
await browser.execute(() => {
await exec(() => {
const panel = document.querySelector('.sidebar-panel');
if (panel && (panel as HTMLElement).offsetParent !== null) {
const btn = document.querySelector('.panel-close');
@ -129,7 +130,7 @@ describe('Scenario 2 — Settings Panel (data-testid)', () => {
it('should open settings via data-testid button', async () => {
// Use JS click for reliability with WebKit2GTK/tauri-driver
await browser.execute(() => {
await exec(() => {
const btn = document.querySelector('[data-testid="settings-btn"]');
if (btn) (btn as HTMLElement).click();
});
@ -139,7 +140,7 @@ describe('Scenario 2 — Settings Panel (data-testid)', () => {
// Wait for settings panel content to mount
await browser.waitUntil(
async () => {
const has = await browser.execute(() =>
const has = await exec(() =>
document.querySelector('.settings-panel .settings-content') !== null,
);
return has as boolean;