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

@ -6,6 +6,7 @@ import { browser, expect } from '@wdio/globals';
import * as S from '../helpers/selectors.ts';
import { openSettings, closeSettings, switchSettingsCategory } from '../helpers/actions.ts';
import { assertThemeApplied } from '../helpers/assertions.ts';
import { exec } from '../helpers/execute.ts';
describe('Theme system', () => {
before(async () => {
@ -19,7 +20,7 @@ describe('Theme system', () => {
});
it('should show theme dropdown button', async () => {
const exists = await browser.execute(() => {
const exists = await exec(() => {
return (document.querySelector('.dd-btn')
?? document.querySelector('.dropdown-btn')
?? document.querySelector('.custom-dropdown')) !== null;
@ -28,14 +29,14 @@ describe('Theme system', () => {
});
it('should open theme dropdown on click', async () => {
await browser.execute(() => {
await exec(() => {
const btn = document.querySelector('.dd-btn')
?? document.querySelector('.dropdown-btn');
if (btn) (btn as HTMLElement).click();
});
await browser.pause(300);
const listOpen = await browser.execute(() => {
const listOpen = await exec(() => {
const list = document.querySelector('.dd-list')
?? document.querySelector('.dropdown-menu');
if (!list) return false;
@ -47,7 +48,7 @@ describe('Theme system', () => {
});
it('should show theme groups (Catppuccin, Editor, Deep Dark)', async () => {
const texts = await browser.execute(() => {
const texts = await exec(() => {
const labels = document.querySelectorAll('.dd-group-label, .dropdown-group-label');
return Array.from(labels).map(l => l.textContent ?? '');
});
@ -60,7 +61,7 @@ describe('Theme system', () => {
});
it('should list at least 17 theme options', async () => {
const count = await browser.execute(() => {
const count = await exec(() => {
return (document.querySelectorAll('.dd-item').length
|| document.querySelectorAll('.dropdown-item').length);
});
@ -70,7 +71,7 @@ describe('Theme system', () => {
});
it('should highlight the currently selected theme', async () => {
const hasSelected = await browser.execute(() => {
const hasSelected = await exec(() => {
return (document.querySelector('.dd-item.selected')
?? document.querySelector('.dropdown-item.active')) !== null;
});
@ -84,7 +85,7 @@ describe('Theme system', () => {
});
it('should have 4 Catppuccin themes', async () => {
const count = await browser.execute(() => {
const count = await exec(() => {
const items = document.querySelectorAll('.dd-item, .dropdown-item');
let catCount = 0;
const catNames = ['mocha', 'macchiato', 'frapp', 'latte'];
@ -100,7 +101,7 @@ describe('Theme system', () => {
});
it('should have 7 Editor themes', async () => {
const count = await browser.execute(() => {
const count = await exec(() => {
const items = document.querySelectorAll('.dd-item, .dropdown-item');
const editorNames = ['vscode', 'atom', 'monokai', 'dracula', 'nord', 'solarized', 'github'];
let edCount = 0;
@ -116,7 +117,7 @@ describe('Theme system', () => {
});
it('should have 6 Deep Dark themes', async () => {
const count = await browser.execute(() => {
const count = await exec(() => {
const items = document.querySelectorAll('.dd-item, .dropdown-item');
const deepNames = ['tokyo', 'gruvbox', 'ayu', 'poimandres', 'vesper', 'midnight'];
let deepCount = 0;
@ -136,7 +137,7 @@ describe('Theme system', () => {
await browser.keys('Escape');
await browser.pause(200);
const count = await browser.execute(() => {
const count = await exec(() => {
return (document.querySelectorAll('.size-stepper').length
|| document.querySelectorAll('.font-stepper').length
|| document.querySelectorAll('.stepper').length);
@ -147,7 +148,7 @@ describe('Theme system', () => {
});
it('should show theme action buttons', async () => {
const count = await browser.execute(() => {
const count = await exec(() => {
return document.querySelectorAll('.theme-action-btn').length;
});
if (count > 0) {
@ -156,7 +157,7 @@ describe('Theme system', () => {
});
it('should apply font changes to terminal', async () => {
const fontFamily = await browser.execute(() => {
const fontFamily = await exec(() => {
return getComputedStyle(document.documentElement).getPropertyValue('--term-font-family').trim();
});
expect(typeof fontFamily).toBe('string');