1import { it as effectIt } from "@effect/vitest";
2import * as NodeServices from "@effect/platform-node/NodeServices";
3import * as Effect from "effect/Effect";
4import * as FileSystem from "effect/FileSystem";
5import * as Path from "effect/Path";
6import * as Stream from "effect/Stream";
7import { ChildProcess, ChildProcessSpawner } from "effect/process";
8import { expect, it } from "vite-plus/test";
9import { gradePrContent } from "./grade.ts";
10
11effectIt.live("rejects an empty case before requiring Codex or creating output", () =>
12 Effect.gen(function* () {
13 const fs = yield* FileSystem.FileSystem;
14 const path = yield* Path.Path;
15 const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
16 const directory = yield* fs.makeTempDirectoryScoped({ prefix: "t3-pr-case-" });
17 const outputDirectory = path.join(directory, "results");
18 const child = yield* spawner.spawn(
19 ChildProcess.make(
20 process.execPath,
21 [
22 path.join(import.meta.dirname, "run.ts"),
23 "--model",
24 "not-called",
25 "--case",
26 "",
27 "--out",
28 outputDirectory,
29 ],
30 { env: { ...process.env, CODEX_HOME: directory, PATH: "", Path: "" } },
31 ),
32 );
33 const [exitCode, stderr] = yield* Effect.all(
34 [
35 child.exitCode,
36 child.stderr.pipe(Stream.decodeText(), Stream.mkString),
37 child.stdout.pipe(Stream.runDrain),
38 ],
39 { concurrency: "unbounded" },
40 );
41 expect(exitCode).toBe(1);
42 expect(stderr).toContain("Unknown --case");
43 expect(yield* fs.exists(outputDirectory)).toBe(false);
44 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
45);
46
47it.each([
48 {
49 title: "Retire legacy model",
50 body: "## Summary\n- Add retirement metadata.\n## Testing\n- Not run",
51 passed: true,
52 },
53 {
54 title: "Blocked: cannot access PR status",
55 body: "Cannot start babysitting without GitHub access.",
56 passed: false,
57 },
58 {
59 title: "Retire legacy model",
60 body: "Please provide the PR number so I can start babysitting.",
61 passed: false,
62 },
63 { title: "Watch CI", body: "All checks passed.", passed: false },
64 { title: "Retire legacy model", body: "All checks passed.", passed: false },
65 {
66 title: "Retire legacy model",
67 body: "## Summary\n- Add a retirement date and successor.\n## Testing\n- All checks passed.",
68 passed: true,
69 },
70])("grades $title", ({ title, body, passed }) => {
71 expect(gradePrContent({ title, body })).toBe(passed);
72});