import { describe, it, expect } from "vitest";
import { createClient, role, label } from "@browseragentprotocol/client";
describe("Login flow", () => {
it("should login and reach dashboard", async () => {
const client = await createClient("ws://localhost:9222");
await client.launch({ browser: "chromium", headless: true });
await client.createPage({ url: "https://myapp.com/login" });
await client.act({
steps: [
{ action: "action/fill", params: { selector: label("Email"), value: "test@example.com" } },
{ action: "action/fill", params: { selector: label("Password"), value: "testpass123" } },
{ action: "action/click", params: { selector: role("button", "Sign In") } },
],
});
const obs = await client.observe({ includeMetadata: true });
expect(obs.metadata?.url).toContain("/dashboard");
await client.close();
});
});