mirror of
https://github.com/CopilotKit/CopilotKit.git
synced 2026-09-14 16:26:20 +08:00
2dcfc25b4c
OSS-451 shipped because nothing linked a demo page's CopilotKit runtimeUrl to the existence of the /api route it names. The only automatic pre-merge gate for showcase/** is a Docker build, which compiles a page that references a non-existent route just fine (runtimeUrl is an unchecked string) — so the page-404-on-load class was invisible. Add a static validator (validate-runtime-routes.ts) that, for every SHIPPED demo (a demo listed in its integration's manifest `features`), asserts its runtimeUrl resolves to a real route dir under src/app/api. Unshipped / experimental demos (not in `features`) and not_supported_features are skipped, so incomplete placeholders don't fail the gate — but promoting one into `features` immediately starts enforcing it. A baseline file can grandfather pre-existing violations; the fleet is currently clean (0). Wire it into a new pre-merge workflow (showcase_validate-wiring.yml) that runs on every showcase/integrations PR alongside the build check. Add it to branch-protection required checks to make it blocking. Regression test proves it flags the exact OSS-451 shape (shipped demo, missing route) while passing existing/base routes and skipping unshipped. Verified: npm run validate-routes -> clean fleet-wide; removing the 3 OSS-451 routes -> flags exactly those 3; full showcase/scripts vitest suite (2151 tests) green. Refs OSS-451
43 lines
1.9 KiB
TypeScript
43 lines
1.9 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import path from "path";
|
|
import { validateIntegration } from "../validate-runtime-routes.js";
|
|
|
|
// A fixture integration under fixtures/route-wiring models the OSS-451 shape:
|
|
// - shipped-ok (in features) → route exists → OK
|
|
// - base-route (in features) → runtimeUrl "/api/copilotkit" exists → OK
|
|
// - shipped-broken (in features) → route MISSING → VIOLATION (the OSS-451 bug)
|
|
// - unshipped-broken (NOT in features) → route MISSING → skipped (unshipped)
|
|
const FIXTURE = path.resolve(__dirname, "fixtures", "route-wiring");
|
|
|
|
describe("runtime-route wiring validator", () => {
|
|
const violations = validateIntegration(FIXTURE);
|
|
|
|
it("flags exactly the shipped demo whose route is missing (the OSS-451 class)", () => {
|
|
expect(violations).toHaveLength(1);
|
|
expect(violations[0].demo).toBe("shipped-broken");
|
|
expect(violations[0].runtimeUrl).toBe("/api/copilotkit-shipped-broken");
|
|
expect(violations[0].integration).toBe("route-wiring");
|
|
});
|
|
|
|
it("does NOT flag a shipped demo whose dedicated route exists", () => {
|
|
expect(violations.some((v) => v.demo === "shipped-ok")).toBe(false);
|
|
});
|
|
|
|
it("does NOT flag a shipped demo pointing at the shared /api/copilotkit route", () => {
|
|
expect(violations.some((v) => v.demo === "base-route")).toBe(false);
|
|
});
|
|
|
|
it("skips unshipped demos (not in manifest features) even when their route is missing", () => {
|
|
// unshipped-broken has a missing route but is intentionally not gated —
|
|
// it is not claimed to work. Promoting it into `features` would start
|
|
// enforcing it, catching the break at that PR.
|
|
expect(violations.some((v) => v.demo === "unshipped-broken")).toBe(false);
|
|
});
|
|
|
|
it("emits a stable baseline key for each violation", () => {
|
|
expect(violations[0].key).toBe(
|
|
"route-wiring:shipped-broken:/api/copilotkit-shipped-broken",
|
|
);
|
|
});
|
|
});
|