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,17 +7,18 @@
import { browser, expect } from '@wdio/globals';
import * as S from '../helpers/selectors.ts';
import { exec } from '../helpers/execute.ts';
describe('Splash screen', () => {
it('should have splash element in DOM', async () => {
const exists = await browser.execute((sel: string) => {
const exists = await exec((sel: string) => {
return document.querySelector(sel) !== null;
}, S.SPLASH);
expect(exists).toBe(true);
});
it('should show the AGOR logo text', async () => {
const text = await browser.execute((sel: string) => {
const text = await exec((sel: string) => {
const el = document.querySelector(sel);
return el?.textContent ?? '';
}, S.LOGO_TEXT);
@ -27,7 +28,7 @@ describe('Splash screen', () => {
});
it('should show version string', async () => {
const text = await browser.execute((sel: string) => {
const text = await exec((sel: string) => {
const el = document.querySelector(sel);
return el?.textContent ?? '';
}, S.SPLASH_VERSION);
@ -37,7 +38,7 @@ describe('Splash screen', () => {
});
it('should have loading indicator dots', async () => {
const count = await browser.execute((sel: string) => {
const count = await exec((sel: string) => {
return document.querySelectorAll(sel).length;
}, S.SPLASH_DOT);
if (count > 0) {
@ -47,7 +48,7 @@ describe('Splash screen', () => {
it('should use display toggle (not removed from DOM)', async () => {
// Splash stays in DOM but gets display:none after load
const display = await browser.execute((sel: string) => {
const display = await exec((sel: string) => {
const el = document.querySelector(sel);
if (!el) return 'not-found';
return getComputedStyle(el).display;
@ -57,7 +58,7 @@ describe('Splash screen', () => {
});
it('should have proper z-index for overlay', async () => {
const zIndex = await browser.execute((sel: string) => {
const zIndex = await exec((sel: string) => {
const el = document.querySelector(sel);
if (!el) return '0';
return getComputedStyle(el).zIndex;