import { describe, expect, it } from "vitest";
import {
  isPostSubmitDestination,
  POST_SUBMIT_URL_PATTERN,
} from "@/workers/rpa/quote-capture/post-submit-navigation";

describe("post-submit navigation", () => {
  it("sign-up-quote 为合法落点", () => {
    expect(
      isPostSubmitDestination(
        "https://www.mothership.com/sign-up-quote?quote-details=abc",
      ),
    ).toBe(true);
  });

  it("/quote 路径为合法落点", () => {
    expect(
      isPostSubmitDestination("https://www.mothership.com/quote/results"),
    ).toBe(true);
  });

  it("首页不是合法落点", () => {
    expect(isPostSubmitDestination("https://www.mothership.com/")).toBe(false);
  });

  it("POST_SUBMIT_URL_PATTERN 覆盖 sign-up-quote", () => {
    expect(POST_SUBMIT_URL_PATTERN.test("sign-up-quote?x=1")).toBe(true);
  });
});
