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

@ -4,10 +4,11 @@
import { browser, expect } from '@wdio/globals';
import * as S from '../helpers/selectors.ts';
import { exec } from '../helpers/execute.ts';
describe('Task board', () => {
it('should render the task board container', async () => {
const exists = await browser.execute((sel: string) => {
const exists = await exec((sel: string) => {
return document.querySelector(sel) !== null;
}, S.TASK_BOARD);
if (exists) {
@ -17,7 +18,7 @@ describe('Task board', () => {
});
it('should show the toolbar with title', async () => {
const text = await browser.execute((sel: string) => {
const text = await exec((sel: string) => {
const el = document.querySelector(sel);
return el?.textContent ?? '';
}, S.TB_TITLE);
@ -27,7 +28,7 @@ describe('Task board', () => {
});
it('should have 5 kanban columns', async () => {
const count = await browser.execute((sel: string) => {
const count = await exec((sel: string) => {
return document.querySelectorAll(sel).length;
}, S.TB_COLUMN);
if (count > 0) {
@ -36,7 +37,7 @@ describe('Task board', () => {
});
it('should show column headers with labels', async () => {
const texts = await browser.execute((sel: string) => {
const texts = await exec((sel: string) => {
const labels = document.querySelectorAll(sel);
return Array.from(labels).map(l => l.textContent?.toUpperCase() ?? '');
}, S.TB_COL_LABEL);
@ -50,7 +51,7 @@ describe('Task board', () => {
});
it('should show column counts', async () => {
const count = await browser.execute((sel: string) => {
const count = await exec((sel: string) => {
return document.querySelectorAll(sel).length;
}, S.TB_COL_COUNT);
if (count > 0) {
@ -83,7 +84,7 @@ describe('Task board', () => {
});
it('should show task count in toolbar', async () => {
const text = await browser.execute((sel: string) => {
const text = await exec((sel: string) => {
const el = document.querySelector(sel);
return el?.textContent ?? '';
}, S.TB_COUNT);
@ -93,7 +94,7 @@ describe('Task board', () => {
});
it('should have task cards in columns', async () => {
const hasCards = await browser.execute(() => {
const hasCards = await exec(() => {
return document.querySelector('.task-card')
?? document.querySelector('.tb-card');
});
@ -101,7 +102,7 @@ describe('Task board', () => {
});
it('should support drag handle on task cards', async () => {
const hasDrag = await browser.execute(() => {
const hasDrag = await exec(() => {
return document.querySelector('.drag-handle')
?? document.querySelector('[draggable]');
});