Skip to content

Commit ff3adfd

Browse files
Guard against deprecation warning on perform calls
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent 3c0f78c commit ff3adfd

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

src/agent/__tests__/hyperagent-constructor.test.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2431,6 +2431,52 @@ describe("HyperAgent constructor and task controls", () => {
24312431
}
24322432
});
24332433

2434+
it("does not emit aiAction deprecation warning for hyperPage.perform", async () => {
2435+
const page = {
2436+
on: jest.fn(),
2437+
off: jest.fn(),
2438+
context: () => ({
2439+
on: jest.fn(),
2440+
off: jest.fn(),
2441+
pages: () => [page],
2442+
}),
2443+
isClosed: () => false,
2444+
} as unknown as Page;
2445+
const agent = new HyperAgent({
2446+
llm: createMockLLM(),
2447+
});
2448+
const internalAgent = agent as unknown as {
2449+
browser: object | null;
2450+
context: { pages: () => Page[] } | null;
2451+
executeSingleAction: jest.Mock;
2452+
};
2453+
internalAgent.browser = {};
2454+
internalAgent.context = {
2455+
pages: () => [page],
2456+
};
2457+
internalAgent.executeSingleAction = jest.fn().mockResolvedValue({
2458+
taskId: "task-id",
2459+
status: TaskStatus.COMPLETED,
2460+
steps: [],
2461+
output: "done",
2462+
});
2463+
const warnSpy = jest.spyOn(console, "warn").mockImplementation(() => {});
2464+
2465+
try {
2466+
const [hyperPage] = await agent.getPages();
2467+
await hyperPage.perform("click submit");
2468+
await hyperPage.perform("click continue");
2469+
2470+
const deprecationWarnings = warnSpy.mock.calls.filter((call) =>
2471+
String(call[0] ?? "").includes("page.aiAction() is deprecated")
2472+
);
2473+
expect(deprecationWarnings).toHaveLength(0);
2474+
expect(internalAgent.executeSingleAction).toHaveBeenCalledTimes(2);
2475+
} finally {
2476+
warnSpy.mockRestore();
2477+
}
2478+
});
2479+
24342480
it("hyperPage.extract rejects blank task descriptions when provided", async () => {
24352481
const mockedRunAgentTask = jest.mocked(runAgentTask);
24362482
mockedRunAgentTask.mockResolvedValue({

0 commit comments

Comments
 (0)