Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(playwright): scope tool and todo locators to their activity groups

Steven Enamakeld78a10ea33dc
diff --git a/app/test/playwright/specs/aui-tool-result-elements.spec.ts b/app/test/playwright/specs/aui-tool-result-elements.spec.ts
index 5cf2ffc730..7542436d27 100644
--- a/app/test/playwright/specs/aui-tool-result-elements.spec.ts
+++ b/app/test/playwright/specs/aui-tool-result-elements.spec.ts
@@ -101,8 +101,20 @@ async function scriptToolCall(
* "the first button in the card" — an earlier revision clicked by button order
* and silently opened nothing.
*/
+async function openActivityGroup(page: Page): Promise<Locator> {
+ const group = page.locator('[data-slot="tool-group-root"]').last();
+ await expect(group, 'the assistant response has no activity disclosure').toBeVisible({
+ timeout: 30_000,
+ });
+ const trigger = group.locator('[data-slot="tool-group-trigger"]');
+ if ((await trigger.getAttribute('aria-expanded')) === 'false') await trigger.click();
+ await expect(trigger).toHaveAttribute('aria-expanded', 'true', { timeout: 10_000 });
+ return group;
+}
+
async function openToolCall(page: Page, expectedLabel: string | RegExp): Promise<Locator> {
- const card = page.getByTestId('assistant-ui-tool-call').filter({ hasText: expectedLabel });
+ const group = await openActivityGroup(page);
+ const card = group.getByTestId('assistant-ui-tool-call').filter({ hasText: expectedLabel });
await expect(
card.first(),
`the round settled but produced no tool card matching ${String(expectedLabel)} — ` +
@@ -276,9 +288,8 @@ test.describe('assistant-ui tool-result elements', () => {
]);
await sendTurn(page, threadId, 'AUI-DOC-CASE write up the infrastructure review');
- const toolCard = await openToolCall(page, /Document|document/);
-
- const card = toolCard.locator('[data-slot="artifact-card"]').first();
+ const group = await openActivityGroup(page);
+ const card = group.locator('[data-slot="artifact-card"]').last();
await expect(card).toBeVisible({ timeout: 20_000 });
// The point of this assertion. `DocumentArtifactCall` resolves the title as
diff --git a/app/test/playwright/specs/chat-todo-list-render.spec.ts b/app/test/playwright/specs/chat-todo-list-render.spec.ts
index 4ca682b82b..aabf5e1711 100644
--- a/app/test/playwright/specs/chat-todo-list-render.spec.ts
+++ b/app/test/playwright/specs/chat-todo-list-render.spec.ts
@@ -5,10 +5,10 @@
* There are two renders of the same vendored element and they are not the same
* claim:
*
- * PINNED `Conversations.tsx:1658` — `data-testid="todo-checklist"`, fed by
+ * PINNED `TurnTaskCards.tsx` — `data-testid="todo-checklist"`, fed by
* `useThreadTodos` off the live `thread_todos_changed` event. One
* per thread, always current.
- * SNAPSHOT `aui/TodoListPart.tsx:76` — one per `todo` tool call in the
+ * SNAPSHOT `aui/TodoListPart.tsx:89` — one per `todo` tool call in the
* transcript, fed by that call's own `args`/`result`
* (`TodoListPart.tsx:62-66` is explicit that these are different
* sources).
@@ -96,18 +96,15 @@ const RULES = [
];
/**
- * Every rendered todo list, pinned and snapshot alike. `data-slot` is the
- * element's own attribute (`todo-list.tsx:46`), so this finds the real
- * component rather than a wrapper that happens to carry a test id.
+ * Every rendered todo UI surface: a pinned task card or per-call receipt.
*/
const allTodoSurfaces = (page: Page): Locator =>
page.locator('[data-testid="todo-checklist"], [data-testid="todo-receipt"]');
/** The pinned, always-current list above the composer. */
/**
- * The per-tool-call snapshots in the transcript. The pinned render is the only
- * one given a test id (`Conversations.tsx:1659`), so excluding it leaves
- * exactly the `TodoListPart` renders.
+ * The per-tool-call transcript snapshots. Each `TodoListPart` has its own
+ * receipt wrapper; the pinned task cards use the separate `todo-checklist` id.
*/
const snapshotReceipts = (page: Page): Locator => page.getByTestId('todo-receipt');
@@ -125,7 +122,7 @@ async function expandSnapshotReceipts(page: Page): Promise<void> {
/**
* One list's item states, in list order, as the element publishes them to
- * assistive technology (`todo-list.tsx:82`).
+ * assistive technology (`todo-list.tsx:126`).
*
* Reads the DOM directly rather than through a tolerant helper: a helper that
* shrugged off a missing span would turn "the element stopped reporting its