Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

1.6 KB
Raw Blame
import { ALLOW_TEST_SUITE_WEBSITE, TEST_SUITE_WEBSITE } from "../lib";
import { describeV1, scrape, scrapeTimeout, idmux, Identity } from "./lib";

let identity: Identity;

beforeAll(async () => {
  identity = await idmux({
    name: "menu-v1",
    concurrency: 100,
    credits: 1000000,
  });
}, 10000 + scrapeTimeout);

// The `menu` scrape format is registered for both v1 and v2. The v2 suite covers
// the positive extraction paths; here we only need to prove the additive-only
// contract on v1: a scrape that does NOT request the `menu` format is
// byte-identical in shape to a pre-feature v1 scrape (no `menu`, no spurious
// `warning`, markdown + metadata intact). The menu transformer is shared across
// v1/v2, so this guards the v1 format gate specifically.
describeV1(ALLOW_TEST_SUITE_WEBSITE)(
  "Menu scrape format (v1 back-compat)",
  () => {
    const base = TEST_SUITE_WEBSITE;
    const menuUrl = `${base}/product`;

    it.concurrent(
      "does not populate menu when the menu format is not requested (v1)",
      async () => {
        const response = await scrape(
          {
            url: menuUrl,
            formats: ["markdown"],
          },
          identity,
        );

        expect(response.menu).toBeUndefined();
        expect(response.warning).toBeUndefined();
        expect(response.markdown).toBeDefined();
        expect(typeof response.markdown).toBe("string");
        expect(response.markdown?.length).toBeGreaterThan(0);
        expect(response.metadata).toBeDefined();
        expect(response.metadata.statusCode).toBe(200);
      },
      scrapeTimeout,
    );
  },
);