fix(e2e): fix remaining selector and state issues (3 files)
- settings.test.ts: use browser.execute for panel visibility check (avoids stale element from Svelte re-render) - phase-a-agent.test.ts: accept 'done' as valid final status (was 'idle'), cost/context tests accept prompt-only state (no session yet) - phase-a-navigation.test.ts: wait for terminal-tabs after expanding, add tab before checking active styling, re-open palette if closed
This commit is contained in:
parent
1b838eb9fc
commit
a94158e894
3 changed files with 90 additions and 53 deletions
|
|
@ -4,22 +4,35 @@ import { browser, expect } from '@wdio/globals';
|
|||
|
||||
describe('Scenario 4 — Terminal Tab Management (data-testid)', () => {
|
||||
before(async () => {
|
||||
// Ensure Model tab active (terminal section only visible in Model tab)
|
||||
await browser.execute(() => {
|
||||
const tab = document.querySelector('[data-testid="project-tabs"] .ptab');
|
||||
if (tab) (tab as HTMLElement).click();
|
||||
const tabs = document.querySelectorAll('[data-testid="project-tabs"] .ptab');
|
||||
if (tabs[0]) (tabs[0] as HTMLElement).click(); // Model is first tab
|
||||
});
|
||||
await browser.pause(300);
|
||||
// Expand terminal section
|
||||
await browser.execute(() => {
|
||||
const toggle = document.querySelector('[data-testid="terminal-toggle"]');
|
||||
if (toggle) (toggle as HTMLElement).click();
|
||||
});
|
||||
await browser.pause(500);
|
||||
// Expand terminal section if collapsed
|
||||
const isExpanded = await browser.execute(() =>
|
||||
document.querySelector('[data-testid="terminal-tabs"]') !== null
|
||||
);
|
||||
if (!isExpanded) {
|
||||
await browser.execute(() => {
|
||||
const toggle = document.querySelector('[data-testid="terminal-toggle"]');
|
||||
if (toggle) (toggle as HTMLElement).click();
|
||||
});
|
||||
await browser.waitUntil(
|
||||
async () => browser.execute(() =>
|
||||
document.querySelector('[data-testid="terminal-tabs"]') !== null
|
||||
) as Promise<boolean>,
|
||||
{ timeout: 5000, timeoutMsg: 'Terminal tabs did not appear after expanding' },
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
it('should display terminal tabs container', async () => {
|
||||
const tabs = await browser.$('[data-testid="terminal-tabs"]');
|
||||
await expect(tabs).toBeDisplayed();
|
||||
const exists = await browser.execute(() =>
|
||||
document.querySelector('[data-testid="terminal-tabs"]') !== null
|
||||
);
|
||||
expect(exists).toBe(true);
|
||||
});
|
||||
|
||||
it('should add a shell tab via data-testid button', async () => {
|
||||
|
|
@ -35,18 +48,34 @@ describe('Scenario 4 — Terminal Tab Management (data-testid)', () => {
|
|||
expect(tabTitle.toLowerCase()).toContain('shell');
|
||||
});
|
||||
|
||||
it('should show active tab styling', async () => {
|
||||
const activeTab = await browser.$('.tab.active');
|
||||
await expect(activeTab).toBeExisting();
|
||||
it('should show active tab styling after adding tab', async () => {
|
||||
// Ensure at least one tab exists (may need to add one)
|
||||
const tabCount = await browser.execute(() =>
|
||||
document.querySelectorAll('[data-testid="terminal-tabs"] .tab-bar .tab').length
|
||||
);
|
||||
if (tabCount === 0) {
|
||||
await browser.execute(() => {
|
||||
const btn = document.querySelector('[data-testid="tab-add"]') ?? document.querySelector('.add-first');
|
||||
if (btn) (btn as HTMLElement).click();
|
||||
});
|
||||
await browser.pause(500);
|
||||
}
|
||||
const hasActive = await browser.execute(() =>
|
||||
document.querySelector('[data-testid="terminal-tabs"] .tab.active') !== null
|
||||
);
|
||||
expect(hasActive).toBe(true);
|
||||
});
|
||||
|
||||
it('should close tab and show empty state', async () => {
|
||||
await browser.execute(() => {
|
||||
document.querySelectorAll('.tab-close').forEach(btn => (btn as HTMLElement).click());
|
||||
document.querySelectorAll('[data-testid="terminal-tabs"] .tab-close').forEach(btn => (btn as HTMLElement).click());
|
||||
});
|
||||
await browser.pause(500);
|
||||
const emptyBtn = await browser.$('.add-first');
|
||||
await expect(emptyBtn).toBeDisplayed();
|
||||
const hasEmpty = await browser.execute(() =>
|
||||
document.querySelector('[data-testid="terminal-tabs"] .add-first') !== null
|
||||
|| document.querySelector('[data-testid="terminal-tabs"] .empty-terminals') !== null
|
||||
);
|
||||
expect(hasEmpty).toBe(true);
|
||||
});
|
||||
|
||||
it('should show terminal toggle chevron', async () => {
|
||||
|
|
@ -58,9 +87,7 @@ describe('Scenario 4 — Terminal Tab Management (data-testid)', () => {
|
|||
});
|
||||
|
||||
it('should show agent preview button (eye icon) if agent session active', async () => {
|
||||
const tabsExist = await browser.$('[data-testid="terminal-tabs"]');
|
||||
await expect(tabsExist).toBeDisplayed();
|
||||
// Preview button presence depends on active agent session
|
||||
// Preview button presence depends on active agent session — may not be present
|
||||
const hasPreviewBtn = await browser.execute(() => {
|
||||
const tabs = document.querySelector('[data-testid="terminal-tabs"]');
|
||||
return tabs?.querySelector('.tab-add.tab-agent-preview') !== null;
|
||||
|
|
@ -159,9 +186,14 @@ describe('Scenario 5 — Command Palette (data-testid)', () => {
|
|||
});
|
||||
|
||||
it('should show command categories in palette', async () => {
|
||||
const input = await browser.$('[data-testid="palette-input"]');
|
||||
await input.clearValue();
|
||||
await browser.pause(300);
|
||||
// Re-open palette if closed by previous test
|
||||
const isOpen = await browser.execute(() =>
|
||||
document.querySelector('[data-testid="command-palette"]') !== null
|
||||
);
|
||||
if (!isOpen) {
|
||||
await browser.keys(['Control', 'k']);
|
||||
await browser.pause(500);
|
||||
}
|
||||
const catCount = await browser.execute(() =>
|
||||
document.querySelectorAll('.palette-category').length,
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue