import { describe, expect, it } from "vitest";
import { pageLocator } from "@/lib/rpa/locator";

describe("pageLocator", () => {
  it("解析 role= 规格", () => {
    const calls: unknown[] = [];
    const page = {
      getByRole: (role: string, opts?: { name?: string }) => {
        calls.push([role, opts]);
        return { _type: "locator" };
      },
      locator: () => ({ _type: "css" }),
      getByText: () => ({ _type: "text" }),
      getByPlaceholder: () => ({ _type: "ph" }),
    } as unknown as Parameters<typeof pageLocator>[0];

    pageLocator(page, 'role=button[name="获取货运报价"]');
    expect(calls[0]).toEqual(["button", { name: "获取货运报价" }]);
  });
});
