import { describe, expect, it } from "vitest";
import {
  describeFlockPagePhase,
  isFlockQuoteLimitText,
} from "@/workers/rpa/flock/page-state";
import { readFlockStallMs } from "@/workers/rpa/flock/stall-watch";

describe("isFlockQuoteLimitText", () => {
  it("识别 Thank you for your interest", () => {
    expect(isFlockQuoteLimitText("Thank you for your interest in Flock")).toBe(true);
    expect(describeFlockPagePhase("Thank you for your interest")).toBe("quote_limit");
  });

  it("识别中文上限", () => {
    expect(isFlockQuoteLimitText("获取报价达到上限")).toBe(true);
  });
});

describe("readFlockStallMs", () => {
  it("默认 20s", () => {
    const prev = process.env.FLOCK_STALL_MS;
    delete process.env.FLOCK_STALL_MS;
    expect(readFlockStallMs()).toBe(20_000);
    process.env.FLOCK_STALL_MS = prev;
  });
});
