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
|
|
@ -8,10 +8,11 @@
|
|||
import { browser, expect } from '@wdio/globals';
|
||||
import * as S from '../helpers/selectors.ts';
|
||||
import { openSettings, closeSettings, switchSettingsCategory } from '../helpers/actions.ts';
|
||||
import { exec } from '../helpers/execute.ts';
|
||||
|
||||
/** Count settings category tabs across both UIs */
|
||||
async function countSettingsTabs(): Promise<number> {
|
||||
return browser.execute(() => {
|
||||
return exec(() => {
|
||||
// Tauri: .settings-sidebar .sidebar-item | Electrobun: .settings-tab or .cat-btn
|
||||
return (document.querySelectorAll('.settings-sidebar .sidebar-item').length
|
||||
|| document.querySelectorAll('.settings-tab').length
|
||||
|
|
@ -29,7 +30,7 @@ describe('Settings panel', () => {
|
|||
});
|
||||
|
||||
it('should open on gear icon click', async () => {
|
||||
const visible = await browser.execute(() => {
|
||||
const visible = await exec(() => {
|
||||
// Tauri: .sidebar-panel or .settings-panel | Electrobun: .settings-drawer
|
||||
const el = document.querySelector('.settings-panel')
|
||||
?? document.querySelector('.settings-drawer')
|
||||
|
|
@ -51,7 +52,7 @@ describe('Settings panel', () => {
|
|||
});
|
||||
|
||||
it('should highlight the active category', async () => {
|
||||
const hasActive = await browser.execute(() => {
|
||||
const hasActive = await exec(() => {
|
||||
return (document.querySelector('.sidebar-item.active')
|
||||
?? document.querySelector('.settings-tab.active')
|
||||
?? document.querySelector('.cat-btn.active')) !== null;
|
||||
|
|
@ -61,7 +62,7 @@ describe('Settings panel', () => {
|
|||
|
||||
it('should switch categories on tab click', async () => {
|
||||
await switchSettingsCategory(1);
|
||||
const isActive = await browser.execute(() => {
|
||||
const isActive = await exec(() => {
|
||||
const tabs = document.querySelectorAll('.settings-sidebar .sidebar-item, .settings-tab, .cat-btn');
|
||||
if (tabs.length < 2) return false;
|
||||
return tabs[1].classList.contains('active');
|
||||
|
|
@ -72,7 +73,7 @@ describe('Settings panel', () => {
|
|||
|
||||
it('should show theme dropdown in Appearance category', async () => {
|
||||
await switchSettingsCategory(0);
|
||||
const exists = await browser.execute(() => {
|
||||
const exists = await exec(() => {
|
||||
return (document.querySelector('.theme-section')
|
||||
?? document.querySelector('.custom-dropdown')
|
||||
?? document.querySelector('.dd-btn')) !== null;
|
||||
|
|
@ -81,7 +82,7 @@ describe('Settings panel', () => {
|
|||
});
|
||||
|
||||
it('should show font size stepper', async () => {
|
||||
const exists = await browser.execute(() => {
|
||||
const exists = await exec(() => {
|
||||
return (document.querySelector('.font-stepper')
|
||||
?? document.querySelector('.stepper')
|
||||
?? document.querySelector('.size-stepper')) !== null;
|
||||
|
|
@ -90,7 +91,7 @@ describe('Settings panel', () => {
|
|||
});
|
||||
|
||||
it('should show font family dropdown', async () => {
|
||||
const exists = await browser.execute(() => {
|
||||
const exists = await exec(() => {
|
||||
return (document.querySelector('.font-dropdown')
|
||||
?? document.querySelector('.custom-dropdown')) !== null;
|
||||
});
|
||||
|
|
@ -98,7 +99,7 @@ describe('Settings panel', () => {
|
|||
});
|
||||
|
||||
it('should increment font size on stepper click', async () => {
|
||||
const changed = await browser.execute(() => {
|
||||
const changed = await exec(() => {
|
||||
const btn = document.querySelector('.font-stepper .step-up')
|
||||
?? document.querySelector('.stepper .step-up')
|
||||
?? document.querySelectorAll('.stepper button')[1];
|
||||
|
|
@ -116,7 +117,7 @@ describe('Settings panel', () => {
|
|||
});
|
||||
|
||||
it('should show provider panels', async () => {
|
||||
const hasProviders = await browser.execute(() => {
|
||||
const hasProviders = await exec(() => {
|
||||
return (document.querySelector('.provider-panel')
|
||||
?? document.querySelector('.provider-settings')
|
||||
?? document.querySelector('.providers-section')) !== null;
|
||||
|
|
@ -129,7 +130,7 @@ describe('Settings panel', () => {
|
|||
if (tabCount > 0) {
|
||||
await switchSettingsCategory(tabCount - 1);
|
||||
}
|
||||
const exists = await browser.execute(() => {
|
||||
const exists = await exec(() => {
|
||||
return (document.querySelector('.update-row')
|
||||
?? document.querySelector('.refresh-btn')
|
||||
?? document.querySelector('.diagnostics')) !== null;
|
||||
|
|
@ -138,7 +139,7 @@ describe('Settings panel', () => {
|
|||
});
|
||||
|
||||
it('should show version label', async () => {
|
||||
const text = await browser.execute(() => {
|
||||
const text = await exec(() => {
|
||||
const el = document.querySelector('.version-label');
|
||||
return el?.textContent ?? '';
|
||||
});
|
||||
|
|
@ -148,14 +149,14 @@ describe('Settings panel', () => {
|
|||
});
|
||||
|
||||
it('should close on close button click', async () => {
|
||||
await browser.execute(() => {
|
||||
await exec(() => {
|
||||
const btn = document.querySelector('.settings-close')
|
||||
?? document.querySelector('.panel-close');
|
||||
if (btn) (btn as HTMLElement).click();
|
||||
});
|
||||
await browser.pause(400);
|
||||
|
||||
const hidden = await browser.execute(() => {
|
||||
const hidden = await exec(() => {
|
||||
const el = document.querySelector('.settings-panel')
|
||||
?? document.querySelector('.settings-drawer')
|
||||
?? document.querySelector('.sidebar-panel');
|
||||
|
|
@ -170,7 +171,7 @@ describe('Settings panel', () => {
|
|||
await browser.keys('Escape');
|
||||
await browser.pause(400);
|
||||
|
||||
const hidden = await browser.execute(() => {
|
||||
const hidden = await exec(() => {
|
||||
const el = document.querySelector('.settings-panel')
|
||||
?? document.querySelector('.settings-drawer')
|
||||
?? document.querySelector('.sidebar-panel');
|
||||
|
|
@ -182,7 +183,7 @@ describe('Settings panel', () => {
|
|||
|
||||
it('should show keyboard shortcuts info', async () => {
|
||||
await openSettings();
|
||||
const hasShortcuts = await browser.execute(() => {
|
||||
const hasShortcuts = await exec(() => {
|
||||
const text = document.body.textContent ?? '';
|
||||
return text.includes('Ctrl+K') || text.includes('shortcut') || text.includes('Keyboard');
|
||||
});
|
||||
|
|
@ -194,7 +195,7 @@ describe('Settings panel', () => {
|
|||
if (tabCount > 0) {
|
||||
await switchSettingsCategory(tabCount - 1);
|
||||
}
|
||||
const hasDiag = await browser.execute(() => {
|
||||
const hasDiag = await exec(() => {
|
||||
return document.querySelector('.diagnostics') !== null;
|
||||
});
|
||||
// Diagnostics is Electrobun-only; Tauri may not have it
|
||||
|
|
@ -203,7 +204,7 @@ describe('Settings panel', () => {
|
|||
|
||||
it('should have shell/CWD defaults section', async () => {
|
||||
await switchSettingsCategory(0);
|
||||
const hasDefaults = await browser.execute(() => {
|
||||
const hasDefaults = await exec(() => {
|
||||
const text = document.body.textContent ?? '';
|
||||
return text.includes('Shell') || text.includes('CWD') || text.includes('Default');
|
||||
});
|
||||
|
|
@ -211,7 +212,7 @@ describe('Settings panel', () => {
|
|||
});
|
||||
|
||||
it('should persist theme selection', async () => {
|
||||
const value = await browser.execute(() => {
|
||||
const value = await exec(() => {
|
||||
return getComputedStyle(document.documentElement).getPropertyValue('--ctp-base').trim();
|
||||
});
|
||||
expect(value.length).toBeGreaterThan(0);
|
||||
|
|
@ -219,7 +220,7 @@ describe('Settings panel', () => {
|
|||
|
||||
it('should show group/project CRUD section', async () => {
|
||||
await switchSettingsCategory(1);
|
||||
const hasProjects = await browser.execute(() => {
|
||||
const hasProjects = await exec(() => {
|
||||
const text = document.body.textContent ?? '';
|
||||
return text.includes('Project') || text.includes('Group') || text.includes('Agent');
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue