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 { switchGroup } from '../helpers/actions.ts';
|
||||
import { exec } from '../helpers/execute.ts';
|
||||
|
||||
describe('Group sidebar', () => {
|
||||
it('should show group buttons in sidebar', async function () {
|
||||
const count = await browser.execute((sel: string) => {
|
||||
const count = await exec((sel: string) => {
|
||||
return document.querySelectorAll(sel).length;
|
||||
}, S.GROUP_BTN);
|
||||
if (count === 0) {
|
||||
|
|
@ -23,12 +24,12 @@ describe('Group sidebar', () => {
|
|||
});
|
||||
|
||||
it('should show numbered circle for each group', async function () {
|
||||
const hasGroups = await browser.execute(() => {
|
||||
const hasGroups = await exec(() => {
|
||||
return document.querySelector('.group-circle') !== null;
|
||||
});
|
||||
if (!hasGroups) { this.skip(); return; }
|
||||
|
||||
const text = await browser.execute((sel: string) => {
|
||||
const text = await exec((sel: string) => {
|
||||
const el = document.querySelector(sel);
|
||||
return el?.textContent ?? '';
|
||||
}, S.GROUP_CIRCLE);
|
||||
|
|
@ -36,19 +37,19 @@ describe('Group sidebar', () => {
|
|||
});
|
||||
|
||||
it('should highlight the active group', async function () {
|
||||
const hasGroups = await browser.execute(() => {
|
||||
const hasGroups = await exec(() => {
|
||||
return document.querySelectorAll('.group-btn').length > 0;
|
||||
});
|
||||
if (!hasGroups) { this.skip(); return; }
|
||||
|
||||
const count = await browser.execute((sel: string) => {
|
||||
const count = await exec((sel: string) => {
|
||||
return document.querySelectorAll(sel).length;
|
||||
}, S.GROUP_BTN_ACTIVE);
|
||||
expect(count).toBe(1);
|
||||
});
|
||||
|
||||
it('should show add group button', async function () {
|
||||
const hasGroups = await browser.execute(() => {
|
||||
const hasGroups = await exec(() => {
|
||||
return document.querySelectorAll('.group-btn').length > 0;
|
||||
});
|
||||
if (!hasGroups) { this.skip(); return; }
|
||||
|
|
@ -57,7 +58,7 @@ describe('Group sidebar', () => {
|
|||
if (await addBtn.isExisting()) {
|
||||
await expect(addBtn).toBeDisplayed();
|
||||
|
||||
const text = await browser.execute(() => {
|
||||
const text = await exec(() => {
|
||||
const circle = document.querySelector('.add-group-btn .group-circle');
|
||||
return circle?.textContent ?? '';
|
||||
});
|
||||
|
|
@ -66,14 +67,14 @@ describe('Group sidebar', () => {
|
|||
});
|
||||
|
||||
it('should switch active group on click', async function () {
|
||||
const groupCount = await browser.execute(() => {
|
||||
const groupCount = await exec(() => {
|
||||
return document.querySelectorAll('.group-btn:not(.add-group-btn)').length;
|
||||
});
|
||||
if (groupCount < 2) { this.skip(); return; }
|
||||
|
||||
await switchGroup(1);
|
||||
|
||||
const isActive = await browser.execute(() => {
|
||||
const isActive = await exec(() => {
|
||||
const groups = document.querySelectorAll('.group-btn:not(.add-group-btn)');
|
||||
return groups[1]?.classList.contains('active') ?? false;
|
||||
});
|
||||
|
|
@ -84,7 +85,7 @@ describe('Group sidebar', () => {
|
|||
});
|
||||
|
||||
it('should show notification badge structure', async function () {
|
||||
const hasGroups = await browser.execute(() => {
|
||||
const hasGroups = await exec(() => {
|
||||
return document.querySelectorAll('.group-btn').length > 0;
|
||||
});
|
||||
if (!hasGroups) { this.skip(); return; }
|
||||
|
|
@ -104,19 +105,19 @@ describe('Group sidebar', () => {
|
|||
});
|
||||
|
||||
it('should update project grid on group switch', async function () {
|
||||
const groupCount = await browser.execute(() => {
|
||||
const groupCount = await exec(() => {
|
||||
return document.querySelectorAll('.group-btn:not(.add-group-btn)').length;
|
||||
});
|
||||
if (groupCount < 2) { this.skip(); return; }
|
||||
|
||||
const cardsBefore = await browser.execute(() => {
|
||||
const cardsBefore = await exec(() => {
|
||||
return document.querySelectorAll('.project-box, .project-card').length;
|
||||
});
|
||||
|
||||
await switchGroup(1);
|
||||
await browser.pause(300);
|
||||
|
||||
const cardsAfter = await browser.execute(() => {
|
||||
const cardsAfter = await exec(() => {
|
||||
return document.querySelectorAll('.project-box, .project-card').length;
|
||||
});
|
||||
|
||||
|
|
@ -136,12 +137,12 @@ describe('Group sidebar', () => {
|
|||
});
|
||||
|
||||
it('should persist active group across sessions', async function () {
|
||||
const hasGroups = await browser.execute(() => {
|
||||
const hasGroups = await exec(() => {
|
||||
return document.querySelectorAll('.group-btn:not(.add-group-btn)').length > 0;
|
||||
});
|
||||
if (!hasGroups) { this.skip(); return; }
|
||||
|
||||
const activeIdx = await browser.execute(() => {
|
||||
const activeIdx = await exec(() => {
|
||||
const groups = document.querySelectorAll('.group-btn:not(.add-group-btn)');
|
||||
for (let i = 0; i < groups.length; i++) {
|
||||
if (groups[i].classList.contains('active')) return i;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue