// @bun
// src/components/docs/libraries/LibrariesTestingPage.tsx
import { CodeBlock, InstallCommand } from "@contractspec/lib.design-system";
import Link from "@contractspec/lib.ui-link";
import { ChevronRight } from "lucide-react";
import { jsx, jsxs } from "react/jsx-runtime";
function LibrariesTestingPage() {
  return /* @__PURE__ */ jsxs("div", {
    className: "space-y-8",
    children: [
      /* @__PURE__ */ jsxs("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx("h1", {
            className: "text-4xl font-bold",
            children: "@contractspec/lib.testing"
          }),
          /* @__PURE__ */ jsx("p", {
            className: "text-muted-foreground text-lg",
            children: "Golden tests ensure new rollouts behave exactly like the traffic that inspired them. Record requests in production, replay them locally, and ship with confidence."
          })
        ]
      }),
      /* @__PURE__ */ jsxs("div", {
        className: "space-y-4",
        children: [
          /* @__PURE__ */ jsx("h2", {
            className: "text-2xl font-bold",
            children: "Installation"
          }),
          /* @__PURE__ */ jsx(InstallCommand, {
            package: "@contractspec/lib.testing"
          })
        ]
      }),
      /* @__PURE__ */ jsxs("div", {
        className: "space-y-3",
        children: [
          /* @__PURE__ */ jsx("h2", {
            className: "text-2xl font-bold",
            children: "Record traffic"
          }),
          /* @__PURE__ */ jsx(CodeBlock, {
            language: "typescript",
            code: `import {
  TrafficRecorder,
  InMemoryTrafficStore,
} from '@contractspec/lib.testing/recorder';

const recorder = new TrafficRecorder({
  store: new InMemoryTrafficStore(),
  sampleRate: 0.02,
  sanitize: (snapshot) => ({
    ...snapshot,
    input: { ...snapshot.input, secret: undefined },
  }),
});

await recorder.record({
  operation: { name: 'orders.create', version: 6 },
  input: payload,
  output,
  success: true,
  tenantId: ctx.organizationId ?? undefined,
});`
          })
        ]
      }),
      /* @__PURE__ */ jsxs("div", {
        className: "space-y-3",
        children: [
          /* @__PURE__ */ jsx("h2", {
            className: "text-2xl font-bold",
            children: "Generate suites"
          }),
          /* @__PURE__ */ jsx(CodeBlock, {
            language: "typescript",
            code: `import { GoldenTestGenerator } from '@contractspec/lib.testing';

const generator = new GoldenTestGenerator();
const code = generator.generate(snapshots, {
  suiteName: 'orders.create golden path',
  runnerImport: './tests/run-operation',
  runnerFunction: 'runOrdersCommand',
  framework: 'vitest',
});`
          })
        ]
      }),
      /* @__PURE__ */ jsxs("div", {
        className: "space-y-3",
        children: [
          /* @__PURE__ */ jsx("h2", {
            className: "text-2xl font-bold",
            children: "CLI workflow"
          }),
          /* @__PURE__ */ jsx(CodeBlock, {
            language: "bash",
            code: `contractspec test generate \\
  --operation orders.create \\
  --output tests/orders.create.golden.test.ts \\
  --runner-import ./tests/run-operation \\
  --runner-fn runOrdersCommand \\
  --from-production \\
  --days 7 \\
  --sample-rate 0.05`
          })
        ]
      }),
      /* @__PURE__ */ jsx("div", {
        className: "grid gap-4 md:grid-cols-2",
        children: [
          {
            title: "Framework agnostic",
            description: "Vitest by default, Jest via `generateJestSuite`, or call `runGoldenTests` manually inside CI."
          },
          {
            title: "Sanitize & sample",
            description: "Scrub payloads before persistence and control sample rates per operation to stay within compliance limits."
          }
        ].map((card) => /* @__PURE__ */ jsxs("div", {
          className: "card-subtle space-y-2 p-4",
          children: [
            /* @__PURE__ */ jsx("h3", {
              className: "text-lg font-semibold",
              children: card.title
            }),
            /* @__PURE__ */ jsx("p", {
              className: "text-muted-foreground text-sm",
              children: card.description
            })
          ]
        }, card.title))
      }),
      /* @__PURE__ */ jsxs("div", {
        className: "flex items-center gap-4 pt-4",
        children: [
          /* @__PURE__ */ jsx(Link, {
            href: "/docs/libraries",
            className: "btn-ghost",
            children: "Back to Libraries"
          }),
          /* @__PURE__ */ jsxs(Link, {
            href: "/docs/libraries/resilience",
            className: "btn-primary",
            children: [
              "Next: Resilience ",
              /* @__PURE__ */ jsx(ChevronRight, {
                size: 16
              })
            ]
          })
        ]
      })
    ]
  });
}
export {
  LibrariesTestingPage
};
