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

@ -5,6 +5,7 @@
import { browser, expect } from '@wdio/globals';
import * as S from '../helpers/selectors.ts';
import { clickProjectTab } from '../helpers/actions.ts';
import { exec } from '../helpers/execute.ts';
describe('File browser', () => {
before(async () => {
@ -34,7 +35,7 @@ describe('File browser', () => {
});
it('should show directory rows in tree', async () => {
const count = await browser.execute((sel: string) => {
const count = await exec((sel: string) => {
return document.querySelectorAll(sel).length;
}, S.FB_DIR);
if (count > 0) {
@ -43,7 +44,7 @@ describe('File browser', () => {
});
it('should show file rows in tree', async () => {
const count = await browser.execute((sel: string) => {
const count = await exec((sel: string) => {
return document.querySelectorAll(sel).length;
}, S.FB_FILE);
if (count > 0) {
@ -52,7 +53,7 @@ describe('File browser', () => {
});
it('should show placeholder when no file selected', async () => {
const text = await browser.execute((sel: string) => {
const text = await exec((sel: string) => {
const el = document.querySelector(sel);
return el?.textContent?.toLowerCase() ?? '';
}, S.FB_EMPTY);
@ -68,7 +69,7 @@ describe('File browser', () => {
await dirs[0].click();
await browser.pause(500);
const isOpen = await browser.execute((sel: string) => {
const isOpen = await exec((sel: string) => {
const chevron = document.querySelector(`${sel} .fb-chevron`);
return chevron?.classList.contains('open') ?? false;
}, S.FB_DIR);
@ -84,7 +85,7 @@ describe('File browser', () => {
await files[0].click();
await browser.pause(500);
const hasContent = await browser.execute(() => {
const hasContent = await exec(() => {
return (document.querySelector('.fb-editor-header')
?? document.querySelector('.fb-image-wrap')
?? document.querySelector('.fb-error')
@ -94,7 +95,7 @@ describe('File browser', () => {
});
it('should show file type icon in tree', async () => {
const count = await browser.execute((sel: string) => {
const count = await exec((sel: string) => {
return document.querySelectorAll(sel).length;
}, S.FILE_TYPE);
if (count > 0) {
@ -114,14 +115,14 @@ describe('File browser', () => {
});
it('should have CodeMirror editor for text files', async () => {
const hasCM = await browser.execute(() => {
const hasCM = await exec(() => {
return document.querySelector('.cm-editor') !== null;
});
expect(typeof hasCM).toBe('boolean');
});
it('should have save button when editing', async () => {
const hasBtn = await browser.execute(() => {
const hasBtn = await exec(() => {
return (document.querySelector('.save-btn')
?? document.querySelector('.fb-save')) !== null;
});
@ -129,7 +130,7 @@ describe('File browser', () => {
});
it('should show dirty indicator for modified files', async () => {
const hasDirty = await browser.execute(() => {
const hasDirty = await exec(() => {
return (document.querySelector('.dirty-dot')
?? document.querySelector('.unsaved')) !== null;
});
@ -137,7 +138,7 @@ describe('File browser', () => {
});
it('should handle image display', async () => {
const hasImage = await browser.execute(() => {
const hasImage = await exec(() => {
return document.querySelector('.fb-image-wrap')
?? document.querySelector('.fb-image');
});
@ -145,7 +146,7 @@ describe('File browser', () => {
});
it('should have PDF viewer component', async () => {
const hasPdf = await browser.execute(() => {
const hasPdf = await exec(() => {
return document.querySelector('.pdf-viewer')
?? document.querySelector('.pdf-container');
});