- AGENTS.md bind-production code block: shows the slim default state (no @repo/core-events / @repo/core-realtime imports, BindProductionContext with no generic args) with a comment pointing to the scaffold workflow. The previous block showed a fully-wired post-scaffold state without signaling that none of those packages exist in main. - bind-protocols.test.ts: top-of-file comment clarifies what these tests actually verify (protocol shapes have required methods) vs what the spec text might suggest (full assignability of optional packages' interfaces — that's verified by the e2e reconstruction tests, not here). - core-package-generator.md: drops two stale "Until Phases 3-6 land" parentheticals — the phases shipped. - config.test.ts: extends the choices assertion to cover all 4 names (realtime, events, trpc, ui). - marketing-pages bind-* comments: reverse the inverted optional/required language. queue (IJobQueue) is from core-shared and always present; bus is the optional one (from @repo/core-events when scaffolded). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
59 lines
2.6 KiB
TypeScript
59 lines
2.6 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import type { PlopTypes } from "@turbo/gen";
|
|
import generator from "./config";
|
|
|
|
describe("core-package generator", () => {
|
|
it("is registered with realtime and events in choices list", () => {
|
|
const captured: Array<{ name: string; def: PlopTypes.PlopGeneratorConfig }> = [];
|
|
const plopMock = {
|
|
setHelper: () => {},
|
|
setGenerator: (name: string, def: PlopTypes.PlopGeneratorConfig) =>
|
|
captured.push({ name, def }),
|
|
} as unknown as PlopTypes.NodePlopAPI;
|
|
generator(plopMock);
|
|
const corePkg = captured.find((c) => c.name === "core-package");
|
|
expect(corePkg).toBeDefined();
|
|
const prompts = corePkg!.def.prompts as Array<{ name: string; choices: unknown[] }>;
|
|
expect(prompts[0]!.name).toBe("name");
|
|
expect(prompts[0]!.choices).toContain("realtime");
|
|
expect(prompts[0]!.choices).toContain("events");
|
|
expect(prompts[0]!.choices).toContain("trpc");
|
|
expect(prompts[0]!.choices).toContain("ui");
|
|
});
|
|
});
|
|
|
|
describe("core-package realtime", () => {
|
|
it("emits actions covering package files, transpilePackages, and ESLint rules", () => {
|
|
// Capture the actions returned by the realtime entry.
|
|
const captured: Array<{ name: string; def: PlopTypes.PlopGeneratorConfig }> = [];
|
|
const plop = {
|
|
setHelper: () => {},
|
|
setGenerator: (n: string, d: unknown) => captured.push({ name: n, def: d as PlopTypes.PlopGeneratorConfig }),
|
|
} as unknown as PlopTypes.NodePlopAPI;
|
|
generator(plop);
|
|
const corePkg = captured.find((c) => c.name === "core-package")!.def;
|
|
const actions = (corePkg.actions as (a: { name: string }) => PlopTypes.ActionType[])(
|
|
{ name: "realtime" },
|
|
);
|
|
// Expectations: at least one assertNotPresent guard, multiple `add` actions, and a transpilePackages action.
|
|
expect(actions.length).toBeGreaterThan(20); // 28 files + extras
|
|
});
|
|
});
|
|
|
|
describe("core-package events", () => {
|
|
it("emits actions covering package files, transpilePackages, and ESLint rule splice", () => {
|
|
const captured: Array<{ name: string; def: PlopTypes.PlopGeneratorConfig }> = [];
|
|
const plop = {
|
|
setHelper: () => {},
|
|
setGenerator: (n: string, d: unknown) => captured.push({ name: n, def: d as PlopTypes.PlopGeneratorConfig }),
|
|
} as unknown as PlopTypes.NodePlopAPI;
|
|
generator(plop);
|
|
const corePkg = captured.find((c) => c.name === "core-package")!.def;
|
|
const actions = (corePkg.actions as (a: { name: string }) => PlopTypes.ActionType[])(
|
|
{ name: "events" },
|
|
);
|
|
// 1 guard + 15 template files + transpilePackages + ESLint splice + printNextSteps = 19
|
|
expect(actions.length).toBeGreaterThanOrEqual(18);
|
|
});
|
|
});
|