Skip to content

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

test: use typed cross-platform tool helpers

Steven Enamakelff327e2c43ba
diff --git a/app/src/components/assistant-ui/elements/tool-call.tsx b/app/src/components/assistant-ui/elements/tool-call.tsx
index 7954394185..344e293209 100644
--- a/app/src/components/assistant-ui/elements/tool-call.tsx
+++ b/app/src/components/assistant-ui/elements/tool-call.tsx
@@ -50,6 +50,7 @@ export interface ToolCallProps {
onOpenChange?: (open: boolean) => void;
className?: string;
'data-testid'?: string;
+ 'data-tool-name'?: string;
}
export function ToolCall({
diff --git a/app/test/e2e/helpers/element-helpers.ts b/app/test/e2e/helpers/element-helpers.ts
index 9d4a5961bf..5c468386ad 100644
--- a/app/test/e2e/helpers/element-helpers.ts
+++ b/app/test/e2e/helpers/element-helpers.ts
@@ -514,6 +514,32 @@ export async function clickTestId(
return el;
}
+/** Click a test id in DOM-backed runs or its visible text on Mac2. */
+export async function clickTestIdOrText(
+ testId: string,
+ text: string,
+ timeout: number = 15_000
+): Promise<ChainablePromiseElement> {
+ return isTauriDriver() ? clickTestId(testId, timeout) : clickText(text, timeout);
+}
+
+/** Click a tool activity group trigger by its visible count label and position. */
+export async function clickToolGroupTrigger(
+ index: number,
+ label: string,
+ timeout: number = 15_000
+): Promise<void> {
+ const literal = xpathStringLiteral(label);
+ const selector = isTauriDriver()
+ ? '[data-slot="tool-group-root"] [data-slot="tool-group-trigger"]'
+ : `//XCUIElementTypeButton[contains(@label, ${literal}) or contains(@value, ${literal}) or contains(@title, ${literal})]`;
+ const triggers = await browser.$$(selector);
+ const trigger = triggers[index];
+ if (!trigger) throw new Error(`Tool group trigger ${index + 1} (${label}) was not found`);
+ await trigger.waitForExist({ timeout, timeoutMsg: `Tool group trigger "${label}" not found` });
+ await clickAtElement(trigger);
+}
+
/** Click a test id with a physical pointer sequence. Use for controls, such as
* Radix menu triggers, that listen for pointerdown instead of a synthetic click.
*/
diff --git a/app/test/e2e/specs/chat-live-history-parity.spec.ts b/app/test/e2e/specs/chat-live-history-parity.spec.ts
index e661bd66d8..8455f13a1f 100644
--- a/app/test/e2e/specs/chat-live-history-parity.spec.ts
+++ b/app/test/e2e/specs/chat-live-history-parity.spec.ts
@@ -30,7 +30,7 @@ import {
waitForSocketConnected,
} from '../helpers/chat-harness';
import { callOpenhumanRpc } from '../helpers/core-rpc';
-import { clickElement, clickTestId } from '../helpers/element-helpers';
+import { clickTestIdOrText, clickToolGroupTrigger } from '../helpers/element-helpers';
import { resetApp } from '../helpers/reset-app';
import { navigateViaHash } from '../helpers/shared-flows';
import { clearRequestLog, setMockBehavior, startMockServer, stopMockServer } from '../mock-server';
@@ -128,22 +128,8 @@ async function replyBlocks(): Promise<Block[]> {
}
async function expandToolGroups(): Promise<void> {
- const messages = await browser.$$('[data-testid="agent-message"]');
- const last = messages[messages.length - 1];
- if (!last) throw new Error('assistant reply message was not rendered');
- const groups = await last.$$('[data-slot="tool-group-root"]');
- for (const group of groups) {
- if ((await group.getAttribute('data-state')) === 'closed') {
- await clickElement(await group.$('[data-slot="tool-group-trigger"]'));
- }
- }
- await browser.waitUntil(
- async () =>
- Promise.all(groups.map(group => group.getAttribute('data-state'))).then(states =>
- states.every(state => state === 'open')
- ),
- { timeout: 5_000, timeoutMsg: 'tool activity groups did not expand' }
- );
+ await clickToolGroupTrigger(0, '1 tool call');
+ await clickToolGroupTrigger(1, '1 tool call');
}
function hasFinalReply(blocks: Block[]): boolean {
@@ -310,7 +296,7 @@ describe('Chat live/history parity', () => {
).__OPENHUMAN_STORE__;
store?.dispatch({ type: 'chatRuntime/clearAllChatRuntime' });
});
- await clickTestId(`thread-row-${threadId}`, 10_000);
+ await clickTestIdOrText(`thread-row-${threadId}`, PROMPT, 10_000);
previous = undefined;
stableSamples = 0;