Repository navigation
test: refresh activation-aware Agent panel coverage #19413
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
de1d35c
137ba82
2044e54
394d176
270bda1
abbcca8
a71fadc
90c7634
22bf1c4
b93cd4d
ce39e5a
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 |
|---|---|---|
|
|
@@ -105,6 +105,105 @@ test.describe( | |
| await expect(openButton).toBeVisible() | ||
| }) | ||
|
|
||
| test.describe('opening from a user-closed panel', () => { | ||
| test.beforeEach(async ({ page }) => { | ||
| await bootAgentApp(page, true) | ||
| const agentPanel = new AgentPanel(page) | ||
| await expect(agentPanel.root).toBeVisible({ timeout: 8_000 }) | ||
| await agentPanel.root | ||
| .getByRole('button', { name: enMessages.g.close }) | ||
| .click() | ||
| await expect(agentPanel.root).toHaveCount(0) | ||
| }) | ||
|
|
||
| test('waits for a delayed open without clicking again', async ({ | ||
| page | ||
| }) => { | ||
| const agentPanel = new AgentPanel(page) | ||
| await agentPanel.openButton.evaluate<void, HTMLElement>((button) => { | ||
| button.dataset.testClickCount = '0' | ||
| button.addEventListener( | ||
| 'click', | ||
| () => { | ||
| button.dataset.testClickCount = String( | ||
| Number(button.dataset.testClickCount) + 1 | ||
| ) | ||
| }, | ||
| true | ||
| ) | ||
|
|
||
| let delayed = false | ||
| const delayOpen = (event: Event) => { | ||
| event.stopImmediatePropagation() | ||
| if (delayed) return | ||
| delayed = true | ||
| window.setTimeout(() => { | ||
| button.removeEventListener('click', delayOpen, true) | ||
| button.click() | ||
| }, 1_500) | ||
| } | ||
| button.addEventListener('click', delayOpen, true) | ||
| }) | ||
|
|
||
| await agentPanel.open(3_000) | ||
|
|
||
| await expect(agentPanel.openButton).toHaveAttribute( | ||
| 'data-test-click-count', | ||
| '2' | ||
| ) | ||
| }) | ||
|
|
||
| test('rejects with the caller timeout while an open stays pending', async ({ | ||
| page | ||
| }) => { | ||
| const agentPanel = new AgentPanel(page) | ||
| await agentPanel.openButton.evaluate((button) => { | ||
| button.addEventListener( | ||
| 'click', | ||
| (event) => event.stopImmediatePropagation(), | ||
| true | ||
| ) | ||
| }) | ||
|
|
||
| await expect(agentPanel.open(250)).rejects.toThrow('250ms') | ||
| }) | ||
|
|
||
| test('drops its click when activation opens the panel just before it lands', async ({ | ||
| page | ||
| }) => { | ||
| const agentPanel = new AgentPanel(page) | ||
| await agentPanel.openButton.evaluate<void, HTMLElement>((button) => { | ||
| button.dataset.testClickCount = '0' | ||
| button.dataset.testActivationClickCount = '0' | ||
| button.addEventListener('click', (event) => { | ||
| button.dataset.testClickCount = String( | ||
| Number(button.dataset.testClickCount) + 1 | ||
| ) | ||
| if (!event.isTrusted) { | ||
| button.dataset.testActivationClickCount = String( | ||
| Number(button.dataset.testActivationClickCount) + 1 | ||
| ) | ||
| } | ||
|
Comment on lines
+182
to
+186
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. P3: button.addEventListener(
'pointerdown',
() => {
button.dataset.testActivationRan = 'true'
button.click()
},
{ capture: true, once: true }
)Then assert |
||
| }) | ||
| button.addEventListener('pointerdown', () => button.click(), { | ||
| capture: true, | ||
| once: true | ||
| }) | ||
| }) | ||
|
|
||
| await agentPanel.open() | ||
|
|
||
| await expect(agentPanel.openButton).toHaveAttribute( | ||
| 'data-test-click-count', | ||
| '1' | ||
| ) | ||
| await expect(agentPanel.openButton).toHaveAttribute( | ||
| 'data-test-activation-click-count', | ||
| '1' | ||
| ) | ||
| }) | ||
| }) | ||
|
|
||
| test('keeps the dock within the viewport and its documented width cap', async ({ | ||
| page | ||
| }) => { | ||
|
|
||
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.
Should we just bump the timeout globally?