| 1 | import type { EnvironmentProject } from "@t3tools/client-runtime/state/shell"; |
| 2 | import { EnvironmentId, ProjectId, ProviderInstanceId } from "@t3tools/contracts"; |
| 3 | import { assert, it } from "@effect/vitest"; |
| 4 | |
| 5 | import { |
| 6 | buildShowcasePendingTasks, |
| 7 | SHOWCASE_PENDING_TASK_DEFINITIONS, |
| 8 | } from "./showcasePendingTasks"; |
| 9 | |
| 10 | const projects: ReadonlyArray<EnvironmentProject> = [ |
| 11 | { |
| 12 | environmentId: EnvironmentId.make("moonbase-terminal"), |
| 13 | id: ProjectId.make("t3code"), |
| 14 | title: "T3 Code", |
| 15 | workspaceRoot: "/workspace/t3code", |
| 16 | repositoryIdentity: null, |
| 17 | defaultModelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.4" }, |
| 18 | scripts: [], |
| 19 | createdAt: "2026-07-16T08:00:00.000Z", |
| 20 | updatedAt: "2026-07-16T08:00:00.000Z", |
| 21 | }, |
| 22 | { |
| 23 | environmentId: EnvironmentId.make("suspense-station"), |
| 24 | id: ProjectId.make("react"), |
| 25 | title: "React", |
| 26 | workspaceRoot: "/workspace/react", |
| 27 | repositoryIdentity: null, |
| 28 | defaultModelSelection: null, |
| 29 | scripts: [], |
| 30 | createdAt: "2026-07-16T08:00:00.000Z", |
| 31 | updatedAt: "2026-07-16T08:00:00.000Z", |
| 32 | }, |
| 33 | ]; |
| 34 | |
| 35 | it("builds sendable-looking pending tasks against real showcase projects", () => { |
| 36 | const tasks = buildShowcasePendingTasks(projects, Date.parse("2026-07-16T09:00:00.000Z")); |
| 37 | |
| 38 | assert.equal(tasks.length, SHOWCASE_PENDING_TASK_DEFINITIONS.length); |
| 39 | assert.deepStrictEqual( |
| 40 | tasks.map((task) => ({ |
| 41 | environmentId: String(task.environmentId), |
| 42 | projectId: task.creation ? String(task.creation.projectId) : undefined, |
| 43 | title: task.creation?.projectTitle, |
| 44 | branch: task.creation?.branch, |
| 45 | createdAt: task.createdAt, |
| 46 | })), |
| 47 | [ |
| 48 | { |
| 49 | environmentId: "moonbase-terminal", |
| 50 | projectId: "t3code", |
| 51 | title: "T3 Code", |
| 52 | branch: "feat/offline-launchpad", |
| 53 | createdAt: "2026-07-16T08:52:00.000Z", |
| 54 | }, |
| 55 | { |
| 56 | environmentId: "suspense-station", |
| 57 | projectId: "react", |
| 58 | title: "React", |
| 59 | branch: "perf/tunnel-handoff", |
| 60 | createdAt: "2026-07-16T08:33:00.000Z", |
| 61 | }, |
| 62 | ], |
| 63 | ); |
| 64 | assert.equal( |
| 65 | tasks.every((task) => task.modelSelection !== undefined), |
| 66 | true, |
| 67 | ); |
| 68 | }); |
| 69 | |
| 70 | it("waits until every referenced project has hydrated", () => { |
| 71 | assert.equal(buildShowcasePendingTasks(projects.slice(0, 1), Date.now()).length, 1); |
| 72 | }); |