import { describe, expect, it } from "vitest";
import {
  getSelectorSpecs,
  parseSelectorSpecs,
} from "@/lib/rpa/selector-specs";

describe("selector-specs", () => {
  it("parseSelectorSpecs 支持逗号分隔双语", () => {
    expect(parseSelectorSpecs("text=Pick up from,text=从何处取货")).toEqual([
      "text=Pick up from",
      "text=从何处取货",
    ]);
  });

  it("getSelectorSpecs 合并 env 与内置回退", () => {
    process.env.RPA_SELECTOR_PICKUP_SECTION = "text=Custom pickup";
    const specs = getSelectorSpecs("RPA_SELECTOR_PICKUP_SECTION");
    expect(specs[0]).toBe("text=Custom pickup");
    expect(specs.some((s) => s.includes("Pick up from"))).toBe(true);
    delete process.env.RPA_SELECTOR_PICKUP_SECTION;
  });

  it("英文 street selector 在内置回退中", () => {
    const specs = getSelectorSpecs("RPA_SELECTOR_PICKUP_STREET");
    expect(specs.some((s) => s.includes("Search address"))).toBe(true);
  });
});
