Skip to content

refactor: extract waitForAgentToFinish helper to pages/sessions#859

Open
empiricalrun[bot] wants to merge 6 commits intomainfrom
chat-session_mMo3RWattTZr
Open

refactor: extract waitForAgentToFinish helper to pages/sessions#859
empiricalrun[bot] wants to merge 6 commits intomainfrom
chat-session_mMo3RWattTZr

Conversation

@empiricalrun
Copy link
Copy Markdown
Contributor

@empiricalrun empiricalrun Bot commented Apr 19, 2026

Summary

Adds a waitForAgentToFinish(page) helper to tests/pages/sessions.ts and replaces 4 scattered inline usages in tests/sessions.spec.ts.

What changed

tests/pages/sessions.ts

Added a new exported helper:

export async function waitForAgentToFinish(page: Page, timeout = 60000): Promise<void> {
  await expect(page.getByRole('button', { name: /^Stop/ })).toBeHidden({ timeout });
}

tests/sessions.spec.ts

Replaced 4 occurrences of the "wait for agent" pattern that had slight inconsistencies:

Before Location
await expect(page.getByRole('button', { name: /^Stop/ })).toBeHidden({ timeout: 60000 }) Close session test
const stopButton = …('Stop'); if (await stopButton.isVisible()) { await expect(stopButton).toBeHidden(…) } Edit message test (conditional + different selector)
await expect(stopButton).toBeHidden({ timeout: 60000 }) Session creation test (×2)

All replaced with:

await waitForAgentToFinish(page);

Why this change

  • Standardizes the stop-button check — previously used /^Stop/ regex in some places and the exact string 'Stop' in others (the regex handles keyboard-shortcut variants like "Stop ⌃C")
  • Removes a redundant conditional in the edit-message test — expect().toBeHidden() already passes immediately when the element is already hidden, so the if (isVisible()) guard was unnecessary
  • Makes intent clearwaitForAgentToFinish(page) reads naturally in the test flow
  • Reusable — future tests can import this from pages/sessions instead of reimplementing it

PR created from session #121603

Updated at 2026-04-19 05:02:27.183 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants