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

@ -8,10 +8,11 @@
import { browser, expect } from '@wdio/globals';
import * as S from '../helpers/selectors.ts';
import { openNotifications, closeNotifications } from '../helpers/actions.ts';
import { exec } from '../helpers/execute.ts';
describe('Notification system', () => {
it('should show the notification bell button', async () => {
const exists = await browser.execute(() => {
const exists = await exec(() => {
return (document.querySelector('.notif-btn')
?? document.querySelector('.bell-btn')
?? document.querySelector('[data-testid="notification-bell"]')) !== null;
@ -23,7 +24,7 @@ describe('Notification system', () => {
it('should open notification drawer on bell click', async () => {
await openNotifications();
const visible = await browser.execute(() => {
const visible = await exec(() => {
// Tauri: .notification-center .panel | Electrobun: .notif-drawer
const el = document.querySelector('.notif-drawer')
?? document.querySelector('[data-testid="notification-panel"]')
@ -37,7 +38,7 @@ describe('Notification system', () => {
});
it('should show drawer header with title', async () => {
const text = await browser.execute(() => {
const text = await exec(() => {
// Tauri: .panel-title | Electrobun: .drawer-title
const el = document.querySelector('.drawer-title')
?? document.querySelector('.panel-title');
@ -49,7 +50,7 @@ describe('Notification system', () => {
});
it('should show clear all button', async () => {
const exists = await browser.execute(() => {
const exists = await exec(() => {
// Tauri: .action-btn with "Clear" | Electrobun: .clear-btn
return (document.querySelector('.clear-btn')
?? document.querySelector('.action-btn')) !== null;
@ -60,7 +61,7 @@ describe('Notification system', () => {
it('should show empty state or notification items', async () => {
await openNotifications();
const hasContent = await browser.execute(() => {
const hasContent = await exec(() => {
// Tauri: .empty or .notification-item | Electrobun: .notif-empty or .notif-item
const empty = document.querySelector('.notif-empty') ?? document.querySelector('.empty');
const items = document.querySelectorAll('.notif-item, .notification-item');
@ -73,7 +74,7 @@ describe('Notification system', () => {
it('should close drawer on backdrop click', async () => {
await closeNotifications();
const hidden = await browser.execute(() => {
const hidden = await exec(() => {
const el = document.querySelector('.notif-drawer')
?? document.querySelector('[data-testid="notification-panel"]')
?? document.querySelector('.notification-center .panel');
@ -84,7 +85,7 @@ describe('Notification system', () => {
});
it('should show unread badge when notifications exist', async () => {
const hasBadge = await browser.execute(() => {
const hasBadge = await exec(() => {
return (document.querySelector('.notif-badge')
?? document.querySelector('.unread-count')
?? document.querySelector('.badge')) !== null;
@ -96,7 +97,7 @@ describe('Notification system', () => {
it('should reopen drawer after close', async () => {
await openNotifications();
const visible = await browser.execute(() => {
const visible = await exec(() => {
const el = document.querySelector('.notif-drawer')
?? document.querySelector('[data-testid="notification-panel"]')
?? document.querySelector('.notification-center .panel');
@ -112,7 +113,7 @@ describe('Notification system', () => {
it('should show notification timestamp', async () => {
await openNotifications();
const hasTimestamp = await browser.execute(() => {
const hasTimestamp = await exec(() => {
return (document.querySelector('.notif-time')
?? document.querySelector('.notif-timestamp')) !== null;
});
@ -122,7 +123,7 @@ describe('Notification system', () => {
it('should show mark-read action', async () => {
await openNotifications();
const hasAction = await browser.execute(() => {
const hasAction = await exec(() => {
return (document.querySelector('.mark-read')
?? document.querySelector('.notif-action')
?? document.querySelector('.action-btn')) !== null;