From 3ff2780f4490d6918f683d12a1ab94de27cb58f1 Mon Sep 17 00:00:00 2001 From: Marco Beretta <81851188+berry-13@users.noreply.github.com> Date: Sat, 1 Aug 2026 17:44:58 +0200 Subject: [PATCH] test(e2e): align assertions with action groups --- e2e/specs/mock/activity-labels.spec.ts | 12 ++++++------ e2e/specs/mock/agent-handoffs.spec.ts | 11 +++++------ e2e/specs/mock/deferred-tools-hitl.spec.ts | 9 +++++++-- e2e/specs/mock/tool-approvals.spec.ts | 5 ++--- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/e2e/specs/mock/activity-labels.spec.ts b/e2e/specs/mock/activity-labels.spec.ts index d139762cb9..e6c641ce9b 100644 --- a/e2e/specs/mock/activity-labels.spec.ts +++ b/e2e/specs/mock/activity-labels.spec.ts @@ -82,7 +82,7 @@ test.describe('activity labels', () => { /** * The header is the feature: once a label lands it REPLACES the generic - * "Used N tools" verb above the same tool cards. + * "Ran N actions" verb above the same tool cards. */ test('renders the generated label as the tool-group header', async ({ page, request }) => { test.setTimeout(120000); @@ -94,7 +94,7 @@ test.describe('activity labels', () => { await expect( messagesView(page).getByRole('button', { name: 'Stored two facts in memory' }), ).toBeVisible({ timeout: 30000 }); - await expect(messagesView(page).getByRole('button', { name: 'Used 2 tools' })).toHaveCount(0); + await expect(messagesView(page).getByRole('button', { name: /^Ran 2 actions/ })).toHaveCount(0); }); /** @@ -141,7 +141,7 @@ test.describe('activity labels', () => { /** * A whitespace-only label must fill null. There is deliberately no templated - * stand-in ("ran 2 tools" only restates the cards), so the block renders + * stand-in ("Ran 2 actions" only restates the cards), so the block renders * exactly as it would without the feature. */ test('leaves the generic header when the model returns a blank label', async ({ @@ -154,7 +154,7 @@ test.describe('activity labels', () => { await runLabeledTurn(page, label); - await expect(messagesView(page).getByRole('button', { name: 'Used 2 tools' })).toBeVisible({ + await expect(messagesView(page).getByRole('button', { name: /^Ran 2 actions/ })).toBeVisible({ timeout: 30000, }); }); @@ -169,7 +169,7 @@ test.describe('activity labels', () => { /** The turn still finished (asserted in runLabeledTurn) and the block kept * its generic header rather than rendering an empty row. */ - await expect(messagesView(page).getByRole('button', { name: 'Used 2 tools' })).toBeVisible({ + await expect(messagesView(page).getByRole('button', { name: /^Ran 2 actions/ })).toBeVisible({ timeout: 30000, }); /** At least one attempt was made and failed; the client may retry a 5xx, @@ -191,7 +191,7 @@ test.describe('activity labels', () => { timeout: 60000, }); - await expect(messagesView(page).getByRole('button', { name: 'Used 2 tools' })).toBeVisible(); + await expect(messagesView(page).getByRole('button', { name: /^Ran 2 actions/ })).toBeVisible(); expect(await getLabelRequestsFor(request, label)).toHaveLength(0); }); diff --git a/e2e/specs/mock/agent-handoffs.spec.ts b/e2e/specs/mock/agent-handoffs.spec.ts index efa419e18c..3ba02fecdb 100644 --- a/e2e/specs/mock/agent-handoffs.spec.ts +++ b/e2e/specs/mock/agent-handoffs.spec.ts @@ -747,12 +747,11 @@ test.describe('agent handoffs', () => { }); await expect(transferCard).toBeEnabled(); await transferCard.click(); - await expect( - messagesView(page).getByText('Handoff instructions:', { exact: true }), - ).toBeVisible(); - await expect( - messagesView(page).getByText(JSON.stringify({ brief: payload }), { exact: true }), - ).toBeVisible(); + const handoffDetails = messagesView(page).getByRole('region', { + name: 'Handoff instructions', + }); + await expect(handoffDetails).toBeVisible(); + await expect(handoffDetails.getByText(payload, { exact: true })).toBeVisible(); await expect(page).toHaveURL(/\/c\/(?!new)/, { timeout: 15000 }); const conversationUrl = page.url(); diff --git a/e2e/specs/mock/deferred-tools-hitl.spec.ts b/e2e/specs/mock/deferred-tools-hitl.spec.ts index cdf58d4bda..070b05565a 100644 --- a/e2e/specs/mock/deferred-tools-hitl.spec.ts +++ b/e2e/specs/mock/deferred-tools-hitl.spec.ts @@ -127,7 +127,12 @@ test.describe('deferred tools across HITL resume', () => { const response = await sendMessage(page, `${PROMPT_MARKER}${label}`); expect(response.ok()).toBeTruthy(); await expect(page).toHaveURL(/\/c\/(?!new)/, { timeout: 15000 }); - await expect(page.getByText(question, { exact: true })).toBeVisible({ timeout: 30000 }); + const liveQuestion = () => + page + .getByRole('button', { name: 'Answer later in the chat' }) + .locator('..') + .getByText(question, { exact: true }); + await expect(liveQuestion()).toBeVisible({ timeout: 30000 }); /** Reload the public conversation route while the graph is paused. This * proves the browser reconstructs the real persisted pending action, @@ -135,7 +140,7 @@ test.describe('deferred tools across HITL resume', () => { const conversationPath = new URL(page.url()).pathname; await page.reload({ waitUntil: 'domcontentloaded' }); await expect(page).toHaveURL(conversationPath); - await expect(page.getByText(question, { exact: true })).toBeVisible({ timeout: 30000 }); + await expect(liveQuestion()).toBeVisible({ timeout: 30000 }); const option = page.getByRole('button', { name: new RegExp(`${escapeRegExp(optionLabel)}$`), diff --git a/e2e/specs/mock/tool-approvals.spec.ts b/e2e/specs/mock/tool-approvals.spec.ts index 7e38a4059b..49e3b7e2ae 100644 --- a/e2e/specs/mock/tool-approvals.spec.ts +++ b/e2e/specs/mock/tool-approvals.spec.ts @@ -162,7 +162,7 @@ async function submitAndCapture(page: Page, submit: Locator) { async function expectCompletedApprovalToolOutput(page: Page, toolCallId: string, output: string) { const view = messagesView(page); - const groupToggle = view.getByRole('button', { name: /^Used \d+ tools$/ }).last(); + const groupToggle = view.getByRole('button', { name: /^Ran \d+ actions/ }).last(); const toolCall = view.locator(`[data-testid="tool-call"][data-tool-call-id="${toolCallId}"]`); // On reload, the conversation arrives asynchronously and multi-tool groups @@ -502,8 +502,7 @@ test.describe('tool approvals', () => { await expect(submit).toBeEnabled(); const groupToggle = messagesView(page).getByRole('button', { - name: 'Used 2 tools', - exact: true, + name: /^Running 2 actions/, }); const groupPanel = messagesView(page).getByTestId('tool-call-group-panel').last(); await Promise.all([