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
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
import { browser, expect } from '@wdio/globals';
|
||||
import * as S from '../helpers/selectors.ts';
|
||||
import { exec } from '../helpers/execute.ts';
|
||||
|
||||
describe('Smoke tests', () => {
|
||||
it('should launch and have the correct title', async () => {
|
||||
|
|
@ -22,7 +23,7 @@ describe('Smoke tests', () => {
|
|||
});
|
||||
|
||||
it('should render the app shell', async () => {
|
||||
const exists = await browser.execute((sel: string) => {
|
||||
const exists = await exec((sel: string) => {
|
||||
return document.querySelector(sel) !== null;
|
||||
}, S.APP_SHELL);
|
||||
if (exists) {
|
||||
|
|
@ -35,7 +36,7 @@ describe('Smoke tests', () => {
|
|||
// Wait for sidebar to appear (may take time after splash screen)
|
||||
await browser.waitUntil(
|
||||
async () =>
|
||||
browser.execute(() => {
|
||||
exec(() => {
|
||||
const el = document.querySelector('.sidebar-rail')
|
||||
?? document.querySelector('.sidebar')
|
||||
?? document.querySelector('[data-testid="sidebar-rail"]');
|
||||
|
|
@ -52,7 +53,7 @@ describe('Smoke tests', () => {
|
|||
});
|
||||
|
||||
it('should display the status bar', async () => {
|
||||
const visible = await browser.execute(() => {
|
||||
const visible = await exec(() => {
|
||||
const el = document.querySelector('[data-testid="status-bar"]')
|
||||
?? document.querySelector('.status-bar');
|
||||
if (!el) return false;
|
||||
|
|
@ -62,7 +63,7 @@ describe('Smoke tests', () => {
|
|||
});
|
||||
|
||||
it('should show version text in status bar', async () => {
|
||||
const text = await browser.execute(() => {
|
||||
const text = await exec(() => {
|
||||
const el = document.querySelector('.status-bar .version');
|
||||
return el?.textContent?.trim() ?? '';
|
||||
});
|
||||
|
|
@ -72,10 +73,10 @@ describe('Smoke tests', () => {
|
|||
});
|
||||
|
||||
it('should show group buttons in sidebar (Electrobun) or tab bar (Tauri)', async function () {
|
||||
const hasGroups = await browser.execute(() => {
|
||||
const hasGroups = await exec(() => {
|
||||
return document.querySelectorAll('.group-btn').length > 0;
|
||||
});
|
||||
const hasTabBar = await browser.execute(() => {
|
||||
const hasTabBar = await exec(() => {
|
||||
return document.querySelector('.sidebar-rail') !== null
|
||||
|| document.querySelector('[data-testid="sidebar-rail"]') !== null;
|
||||
});
|
||||
|
|
@ -84,7 +85,7 @@ describe('Smoke tests', () => {
|
|||
});
|
||||
|
||||
it('should show the settings gear icon', async () => {
|
||||
const exists = await browser.execute(() => {
|
||||
const exists = await exec(() => {
|
||||
return (document.querySelector('[data-testid="settings-btn"]')
|
||||
?? document.querySelector('.sidebar-icon')
|
||||
?? document.querySelector('.rail-btn')) !== null;
|
||||
|
|
@ -93,7 +94,7 @@ describe('Smoke tests', () => {
|
|||
});
|
||||
|
||||
it('should show the notification bell', async () => {
|
||||
const exists = await browser.execute(() => {
|
||||
const exists = await exec(() => {
|
||||
// Tauri: .bell-btn | Electrobun: .notif-btn
|
||||
return (document.querySelector('.notif-btn')
|
||||
?? document.querySelector('.bell-btn')
|
||||
|
|
@ -111,7 +112,7 @@ describe('Smoke tests', () => {
|
|||
});
|
||||
|
||||
it('should toggle sidebar with settings button', async () => {
|
||||
await browser.execute(() => {
|
||||
await exec(() => {
|
||||
const btn = document.querySelector('[data-testid="settings-btn"]')
|
||||
?? document.querySelector('.sidebar-icon')
|
||||
?? document.querySelector('.rail-btn');
|
||||
|
|
@ -121,13 +122,13 @@ describe('Smoke tests', () => {
|
|||
// Wait for either panel (Tauri: .sidebar-panel, Electrobun: .settings-drawer)
|
||||
await browser.waitUntil(
|
||||
async () =>
|
||||
browser.execute(() =>
|
||||
exec(() =>
|
||||
document.querySelector('.sidebar-panel, .settings-drawer, .settings-panel') !== null,
|
||||
) as Promise<boolean>,
|
||||
{ timeout: 5_000 },
|
||||
).catch(() => {}); // may not appear in all configs
|
||||
|
||||
const visible = await browser.execute(() => {
|
||||
const visible = await exec(() => {
|
||||
const el = document.querySelector('.sidebar-panel')
|
||||
?? document.querySelector('.settings-drawer')
|
||||
?? document.querySelector('.settings-panel');
|
||||
|
|
@ -139,7 +140,7 @@ describe('Smoke tests', () => {
|
|||
expect(visible).toBe(true);
|
||||
|
||||
// Close it
|
||||
await browser.execute(() => {
|
||||
await exec(() => {
|
||||
const btn = document.querySelector('.panel-close')
|
||||
?? document.querySelector('.settings-close');
|
||||
if (btn) (btn as HTMLElement).click();
|
||||
|
|
@ -149,7 +150,7 @@ describe('Smoke tests', () => {
|
|||
});
|
||||
|
||||
it('should show project cards in grid', async () => {
|
||||
const count = await browser.execute(() => {
|
||||
const count = await exec(() => {
|
||||
// Tauri: .project-box | Electrobun: .project-card
|
||||
return document.querySelectorAll('.project-box, .project-card').length;
|
||||
});
|
||||
|
|
@ -158,7 +159,7 @@ describe('Smoke tests', () => {
|
|||
});
|
||||
|
||||
it('should show the AGOR title', async () => {
|
||||
const text = await browser.execute((sel: string) => {
|
||||
const text = await exec((sel: string) => {
|
||||
const el = document.querySelector(sel);
|
||||
return el?.textContent?.trim() ?? '';
|
||||
}, S.AGOR_TITLE);
|
||||
|
|
@ -168,7 +169,7 @@ describe('Smoke tests', () => {
|
|||
});
|
||||
|
||||
it('should have terminal section in project card', async () => {
|
||||
const exists = await browser.execute((sel: string) => {
|
||||
const exists = await exec((sel: string) => {
|
||||
return document.querySelector(sel) !== null;
|
||||
}, S.TERMINAL_SECTION);
|
||||
// Terminal section may or may not be visible depending on card state
|
||||
|
|
@ -177,7 +178,7 @@ describe('Smoke tests', () => {
|
|||
|
||||
it('should have window close button (Electrobun) or native decorations', async () => {
|
||||
// Electrobun has a custom close button; Tauri uses native decorations
|
||||
const hasClose = await browser.execute(() => {
|
||||
const hasClose = await exec(() => {
|
||||
return document.querySelector('.close-btn') !== null;
|
||||
});
|
||||
// Just verify the check completed — both stacks are valid
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue