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

@ -74,6 +74,7 @@ export const sharedConfig = {
if (db.shouldSkip(specFile, test.title)) {
const stats = db.getCacheStats();
console.log(`Skipping (3+ consecutive passes): ${test.title} [${stats.skippable}/${stats.total} skippable]`);
// this.skip() works in Mocha non-arrow context — safe for both protocols
this.skip();
}
},
@ -82,10 +83,13 @@ export const sharedConfig = {
async afterTest(test, _context, { passed }) {
let unexpected = [];
try {
const errors = await browser.execute(() => {
const toasts = [...document.querySelectorAll('.toast-error, .load-error')];
return toasts.map(t => t.textContent?.trim()).filter(Boolean);
});
// Use string script for cross-protocol compatibility (devtools + webdriver)
const errors = await browser.execute(
'return (function() {' +
' var toasts = Array.from(document.querySelectorAll(".toast-error, .load-error"));' +
' return toasts.map(function(t) { return (t.textContent || "").trim(); }).filter(Boolean);' +
'})()'
);
const expected = browser.__expectedErrors || [];
unexpected = errors.filter(e => !expected.some(exp => e.includes(exp)));