import { describe, expect, it } from "vitest";
import {
  shouldConsumeRpaRetry,
} from "@/modules/quote/fallback-orchestrator";
import { RpaError } from "@/modules/rpa/errors";

describe("fallback entry errors (task-129)", () => {
  it("QUOTE_ENTRY_UNAVAILABLE 不消耗重试配额", () => {
    expect(
      shouldConsumeRpaRetry(
        new RpaError("QUOTE_ENTRY_UNAVAILABLE", "入口不可用", {
          retryable: false,
        }),
      ),
    ).toBe(false);
  });

  it("ADDRESS_SUGGESTION_NOT_FOUND 不消耗重试配额", () => {
    expect(
      shouldConsumeRpaRetry(
        new RpaError("ADDRESS_SUGGESTION_NOT_FOUND", "联想失败", {
          retryable: false,
        }),
      ),
    ).toBe(false);
  });

  it("PAGE_LOAD_TIMEOUT 仍可重试", () => {
    expect(
      shouldConsumeRpaRetry(
        new RpaError("PAGE_LOAD_TIMEOUT", "超时"),
      ),
    ).toBe(true);
  });
});
