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('Worktree support', () => {
it('should show clone/worktree button', async () => {
const exists = await browser.execute((sel: string) => {
const exists = await exec((sel: string) => {
return document.querySelector(sel) !== null;
}, S.CLONE_BTN);
expect(typeof exists).toBe('boolean');
@ -30,7 +31,7 @@ describe('Worktree support', () => {
});
it('should show WT badge on worktree sessions', async () => {
const exists = await browser.execute((sel: string) => {
const exists = await exec((sel: string) => {
return document.querySelector(sel) !== null;
}, S.WT_BADGE);
// Badge only appears when worktree is active
@ -38,14 +39,14 @@ describe('Worktree support', () => {
});
it('should show clone group display', async () => {
const exists = await browser.execute((sel: string) => {
const exists = await exec((sel: string) => {
return document.querySelector(sel) !== null;
}, S.CLONE_GROUP);
expect(typeof exists).toBe('boolean');
});
it('should have worktree toggle in settings', async () => {
const hasToggle = await browser.execute(() => {
const hasToggle = await exec(() => {
const text = document.body.textContent ?? '';
return text.includes('Worktree') || text.includes('worktree');
});
@ -53,7 +54,7 @@ describe('Worktree support', () => {
});
it('should handle worktree path display', async () => {
const paths = await browser.execute(() => {
const paths = await exec(() => {
const headers = document.querySelectorAll('.project-header');
return Array.from(headers).map(h => h.textContent ?? '');
});
@ -61,7 +62,7 @@ describe('Worktree support', () => {
});
it('should show worktree isolation toggle in settings', async () => {
const hasToggle = await browser.execute(() => {
const hasToggle = await exec(() => {
return (document.querySelector('.worktree-toggle')
?? document.querySelector('[data-setting="useWorktrees"]')) !== null;
});
@ -70,7 +71,7 @@ describe('Worktree support', () => {
it('should preserve worktree badge across tab switches', async () => {
// Worktree badge uses display toggle, not {#if}
const badge = await browser.execute((sel: string) => {
const badge = await exec((sel: string) => {
const el = document.querySelector(sel);
if (!el) return 'absent';
return getComputedStyle(el).display;