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:
parent
407e49cc32
commit
6a8181f33a
42 changed files with 630 additions and 541 deletions
|
|
@ -4,10 +4,11 @@
|
|||
|
||||
import { browser, expect } from '@wdio/globals';
|
||||
import * as S from '../helpers/selectors.ts';
|
||||
import { exec } from '../helpers/execute.ts';
|
||||
|
||||
describe('Communications tab', () => {
|
||||
it('should render the comms tab container', async () => {
|
||||
const exists = await browser.execute((sel: string) => {
|
||||
const exists = await exec((sel: string) => {
|
||||
return document.querySelector(sel) !== null;
|
||||
}, S.COMMS_TAB);
|
||||
if (exists) {
|
||||
|
|
@ -20,7 +21,7 @@ describe('Communications tab', () => {
|
|||
const modeBar = await browser.$(S.COMMS_MODE_BAR);
|
||||
if (!(await modeBar.isExisting())) return;
|
||||
|
||||
const texts = await browser.execute((sel: string) => {
|
||||
const texts = await exec((sel: string) => {
|
||||
const buttons = document.querySelectorAll(sel);
|
||||
return Array.from(buttons).map(b => b.textContent?.trim() ?? '');
|
||||
}, S.MODE_BTN);
|
||||
|
|
@ -31,7 +32,7 @@ describe('Communications tab', () => {
|
|||
});
|
||||
|
||||
it('should highlight the active mode button', async () => {
|
||||
const exists = await browser.execute((sel: string) => {
|
||||
const exists = await exec((sel: string) => {
|
||||
return document.querySelector(sel) !== null;
|
||||
}, S.MODE_BTN_ACTIVE);
|
||||
if (exists) {
|
||||
|
|
@ -47,7 +48,7 @@ describe('Communications tab', () => {
|
|||
});
|
||||
|
||||
it('should show channel list with hash prefix', async () => {
|
||||
const text = await browser.execute((sel: string) => {
|
||||
const text = await exec((sel: string) => {
|
||||
const el = document.querySelector(sel);
|
||||
return el?.textContent ?? '';
|
||||
}, S.CH_HASH);
|
||||
|
|
@ -71,7 +72,7 @@ describe('Communications tab', () => {
|
|||
});
|
||||
|
||||
it('should have send button disabled when input empty', async () => {
|
||||
const disabled = await browser.execute((sel: string) => {
|
||||
const disabled = await exec((sel: string) => {
|
||||
const btn = document.querySelector(sel) as HTMLButtonElement;
|
||||
return btn?.disabled ?? null;
|
||||
}, S.MSG_SEND_BTN);
|
||||
|
|
@ -81,7 +82,7 @@ describe('Communications tab', () => {
|
|||
});
|
||||
|
||||
it('should switch to DMs mode on DMs button click', async () => {
|
||||
const switched = await browser.execute((sel: string) => {
|
||||
const switched = await exec((sel: string) => {
|
||||
const buttons = document.querySelectorAll(sel);
|
||||
if (buttons.length < 2) return false;
|
||||
(buttons[1] as HTMLElement).click();
|
||||
|
|
@ -91,7 +92,7 @@ describe('Communications tab', () => {
|
|||
if (switched) {
|
||||
expect(switched).toBe(true);
|
||||
// Switch back
|
||||
await browser.execute((sel: string) => {
|
||||
await exec((sel: string) => {
|
||||
const buttons = document.querySelectorAll(sel);
|
||||
if (buttons[0]) (buttons[0] as HTMLElement).click();
|
||||
}, S.MODE_BTN);
|
||||
|
|
@ -100,13 +101,13 @@ describe('Communications tab', () => {
|
|||
});
|
||||
|
||||
it('should show DM contact list in DMs mode', async () => {
|
||||
await browser.execute((sel: string) => {
|
||||
await exec((sel: string) => {
|
||||
const buttons = document.querySelectorAll(sel);
|
||||
if (buttons.length >= 2) (buttons[1] as HTMLElement).click();
|
||||
}, S.MODE_BTN);
|
||||
await browser.pause(300);
|
||||
|
||||
const hasList = await browser.execute(() => {
|
||||
const hasList = await exec(() => {
|
||||
return (document.querySelector('.dm-list')
|
||||
?? document.querySelector('.contact-list')
|
||||
?? document.querySelector('.comms-sidebar')) !== null;
|
||||
|
|
@ -114,7 +115,7 @@ describe('Communications tab', () => {
|
|||
expect(typeof hasList).toBe('boolean');
|
||||
|
||||
// Switch back
|
||||
await browser.execute((sel: string) => {
|
||||
await exec((sel: string) => {
|
||||
const buttons = document.querySelectorAll(sel);
|
||||
if (buttons[0]) (buttons[0] as HTMLElement).click();
|
||||
}, S.MODE_BTN);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue