Repository navigation
test: confirm running-command prompts when closing tabs #18965
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3f606c5
97dcdf6
b11d6b8
decb380
50ab6c9
7c2976b
c71729e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -39,6 +39,22 @@ function tabLocator(page: Page, tabId: string) { | |||||||||||||
| return page.locator(`${SORTABLE_TAB}[data-tab-id="${tabId}"]`).first() | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| async function closeTabFromTabBar(page: Page, tabId: string): Promise<void> { | ||||||||||||||
| const tab = tabLocator(page, tabId) | ||||||||||||||
| await tab.hover() | ||||||||||||||
| await tab.getByRole('button', { name: /^Close tab /i }).click() | ||||||||||||||
| const confirmation = page.getByRole('dialog', { name: 'Stop running command?' }) | ||||||||||||||
| // A shell still starting under load may require the running-command confirmation. | ||||||||||||||
| await expect | ||||||||||||||
| .poll(async () => (await confirmation.isVisible()) || (await tab.count()) === 0, { | ||||||||||||||
| timeout: 5_000 | ||||||||||||||
| }) | ||||||||||||||
| .toBe(true) | ||||||||||||||
| if (await confirmation.isVisible()) { | ||||||||||||||
| await confirmation.getByRole('button', { name: 'Stop and Close', exact: true }).click() | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win Wait for tab removal after the confirmation click. When the confirmation is visible, the poll stops before the tab is removed. After Proposed fix if (await confirmation.isVisible()) {
await confirmation.getByRole('button', { name: 'Stop and Close', exact: true }).click()
}
+ await expect.poll(async () => (await tab.count()) === 0, {
+ timeout: 5_000,
+ }).toBe(true)📝 Committable suggestion
Suggested change
|
||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| /** Count rendered tabs in the tab bar (user-visible, not store-level). */ | ||||||||||||||
| async function countRenderedTabs(page: Page): Promise<number> { | ||||||||||||||
| return page.locator(SORTABLE_TAB).count() | ||||||||||||||
|
|
@@ -73,6 +89,8 @@ test.describe('Tabs', () => { | |||||||||||||
| await waitForStartupWorktreeRefresh(orcaPage) | ||||||||||||||
| await waitForActiveWorktree(orcaPage) | ||||||||||||||
| await ensureTerminalVisible(orcaPage) | ||||||||||||||
| const initialTabId = (await getActiveTabId(orcaPage))! | ||||||||||||||
| await expect(tabLocator(orcaPage, initialTabId)).toBeVisible() | ||||||||||||||
| }) | ||||||||||||||
|
|
||||||||||||||
| /** | ||||||||||||||
|
|
@@ -94,7 +112,7 @@ test.describe('Tabs', () => { | |||||||||||||
| // Why: the "+" dropdown uses Radix <DropdownMenuItem>, which exposes the | ||||||||||||||
| // label text as the accessible name once the menu is open. | ||||||||||||||
| const newTerminalMenuItem = orcaPage.getByRole('menuitem', { name: /New Terminal/i }).first() | ||||||||||||||
| await newTerminalMenuItem.click({ force: true }) | ||||||||||||||
| await newTerminalMenuItem.click() | ||||||||||||||
| await expect(newTerminalMenuItem).toBeHidden({ timeout: 3_000 }) | ||||||||||||||
|
|
||||||||||||||
| // Final assertion is on the rendered tab count — the tab bar itself must | ||||||||||||||
|
|
@@ -138,8 +156,7 @@ test.describe('Tabs', () => { | |||||||||||||
|
|
||||||||||||||
| await orcaPage.getByRole('button', { name: 'New tab' }).click({ force: true }) | ||||||||||||||
| const newMarkdownMenuItem = orcaPage.getByRole('menuitem', { name: /New Markdown/i }).first() | ||||||||||||||
| await newMarkdownMenuItem.click({ force: true }) | ||||||||||||||
| await expect(newMarkdownMenuItem).toBeHidden({ timeout: 3_000 }) | ||||||||||||||
| await newMarkdownMenuItem.click() | ||||||||||||||
|
|
||||||||||||||
| // Why: require an id that did not exist before the click, so an already-open | ||||||||||||||
| // Markdown file can't satisfy the assertions (or be deleted by cleanup), and | ||||||||||||||
|
|
@@ -161,6 +178,7 @@ test.describe('Tabs', () => { | |||||||||||||
|
|
||||||||||||||
| const editor = orcaPage.locator('.rich-markdown-editor') | ||||||||||||||
| await expect(editor).toBeVisible({ timeout: 25_000 }) | ||||||||||||||
| await expect(newMarkdownMenuItem).toBeHidden({ timeout: 3_000 }) | ||||||||||||||
|
|
||||||||||||||
| await expect | ||||||||||||||
| .poll(() => editor.evaluate((element) => document.activeElement === element), { | ||||||||||||||
|
|
@@ -519,12 +537,7 @@ test.describe('Tabs', () => { | |||||||||||||
| const tabsBefore = await countRenderedTabs(orcaPage) | ||||||||||||||
| const activeId = await getActiveTabId(orcaPage) | ||||||||||||||
| expect(activeId).not.toBeNull() | ||||||||||||||
| const activeTab = tabLocator(orcaPage, activeId!) | ||||||||||||||
| // Why: hover the tab first so the close button reveals its hover style. | ||||||||||||||
| // The button is interactive regardless but hovering matches real user | ||||||||||||||
| // behaviour and keeps click coordinates stable. | ||||||||||||||
| await activeTab.hover() | ||||||||||||||
| await activeTab.getByRole('button', { name: /^Close tab /i }).click() | ||||||||||||||
| await closeTabFromTabBar(orcaPage, activeId!) | ||||||||||||||
|
|
||||||||||||||
| await expect | ||||||||||||||
| .poll(() => countRenderedTabs(orcaPage), { | ||||||||||||||
|
|
@@ -562,9 +575,7 @@ test.describe('Tabs', () => { | |||||||||||||
| const activeTabBefore = await getActiveTabId(orcaPage) | ||||||||||||||
| expect(activeTabBefore).not.toBeNull() | ||||||||||||||
|
|
||||||||||||||
| const activeTab = tabLocator(orcaPage, activeTabBefore!) | ||||||||||||||
| await activeTab.hover() | ||||||||||||||
| await activeTab.getByRole('button', { name: /^Close tab /i }).click() | ||||||||||||||
| await closeTabFromTabBar(orcaPage, activeTabBefore!) | ||||||||||||||
|
|
||||||||||||||
| // Final DOM assertion: some *other* tab element now carries data-active. | ||||||||||||||
| await expect | ||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This hardcodes the
commandcopy variant, whereas the sibling specs (terminal-tab-close-running-confirm.spec.ts,terminal-tab-close-running-confirm-mouse.spec.ts) match bothStop running command?|Stop this agent?via acloseDialogTitleregex. Correct for the two call sites here (both create plain terminal tabs), but a future agent-tab close routed through this helper would time out rather than match. Consider matching the canonical regex.