Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

bin.test.ts

601 lines22.6 KB

1// @effect-diagnostics nodeBuiltinImport:off - CLI integration exercises Node HTTP and filesystem boundaries.
2import * as NodeHttp from "node:http";
3import * as NodeFS from "node:fs";
4import * as NodeOS from "node:os";
5import * as NodePath from "node:path";
6​
7import * as NodeHttpServer from "@effect/platform-node/NodeHttpServer";
8import * as NodeServices from "@effect/platform-node/NodeServices";
9import {
10 CommandId,
11 EnvironmentOrchestrationHttpApi,
12 ProviderInstanceId,
13 ThreadId,
14} from "@t3tools/contracts";
15import * as NetService from "@t3tools/shared/Net";
16import { assert, it } from "@effect/vitest";
17import * as Effect from "effect/Effect";
18import * as DateTime from "effect/DateTime";
19import * as Layer from "effect/Layer";
20import * as HttpRouter from "effect/unstable/http/HttpRouter";
21import * as HttpServer from "effect/unstable/http/HttpServer";
22import * as HttpApi from "effect/unstable/httpapi/HttpApi";
23import * as HttpApiBuilder from "effect/unstable/httpapi/HttpApiBuilder";
24import * as CliError from "effect/unstable/cli/CliError";
25import * as TestConsole from "effect/testing/TestConsole";
26import { Command } from "effect/unstable/cli";
27​
28import { cli, makeCli } from "./bin.ts";
29import * as ServerConfig from "./config.ts";
30import * as ProjectionSnapshotQuery from "./orchestration/Services/ProjectionSnapshotQuery.ts";
31import * as OrchestrationEngine from "./orchestration/Services/OrchestrationEngine.ts";
32import { OrchestrationLayerLive } from "./orchestration/runtimeLayer.ts";
33import { orchestrationHttpApiLayer } from "./orchestration/http.ts";
34import { layerConfig as SqlitePersistenceLayerLive } from "./persistence/Layers/Sqlite.ts";
35import * as RepositoryIdentityResolver from "./project/RepositoryIdentityResolver.ts";
36import {
37 makePersistedServerRuntimeState,
38 persistServerRuntimeState,
39} from "./serverRuntimeState.ts";
40import * as WorkspacePaths from "./workspace/WorkspacePaths.ts";
41import * as ServerSecretStore from "./auth/ServerSecretStore.ts";
42import * as EnvironmentAuth from "./auth/EnvironmentAuth.ts";
43import { environmentAuthenticatedAuthLayer } from "./auth/http.ts";
44​
45const CliRuntimeLayer = Layer.mergeAll(NodeServices.layer, NetService.layer);
46class ProjectCliHttpApi extends HttpApi.make("environment").add(EnvironmentOrchestrationHttpApi) {}
47​
48const connectCli = makeCli({ cloudEnabled: true });
49const noConnectCli = makeCli({ cloudEnabled: false });
50const runCli = (args: ReadonlyArray<string>, command = cli) =>
51 Command.runWith(command, { version: "0.0.0" })(args);
52const runConnectCli = (args: ReadonlyArray<string>) => runCli(args, connectCli);
53const runCliWithRuntime = (args: ReadonlyArray<string>) =>
54 runCli(args).pipe(Effect.provide(CliRuntimeLayer));
55​
56const captureStdout = <A, E, R>(effect: Effect.Effect<A, E, R>) =>
57 Effect.gen(function* () {
58 const result = yield* effect;
59 const output =
60 (yield* TestConsole.logLines).findLast((line): line is string => typeof line === "string") ??
61 "";
62 return { result, output };
63 }).pipe(Effect.provide(Layer.mergeAll(CliRuntimeLayer, TestConsole.layer)));
64​
65const makeCliTestServerConfig = (baseDir: string) =>
66 Effect.gen(function* () {
67 const derivedPaths = yield* ServerConfig.deriveServerPaths(baseDir, undefined);
68 return {
69 logLevel: "Info",
70 traceMinLevel: "Info",
71 traceTimingEnabled: true,
72 traceBatchWindowMs: 200,
73 traceMaxBytes: 10 * 1024 * 1024,
74 traceMaxFiles: 10,
75 otlpTracesUrl: undefined,
76 otlpMetricsUrl: undefined,
77 otlpExportIntervalMs: 10_000,
78 otlpServiceName: "t3-server",
79 mode: "web",
80 port: 0,
81 host: "127.0.0.1",
82 cwd: process.cwd(),
83 baseDir,
84 ...derivedPaths,
85 staticDir: undefined,
86 devUrl: undefined,
87 noBrowser: true,
88 startupPresentation: "browser",
89 desktopBootstrapToken: undefined,
90 autoBootstrapProjectFromCwd: false,
91 logWebSocketEvents: false,
92 tailscaleServeEnabled: false,
93 tailscaleServePort: 443,
94 } satisfies ServerConfig.ServerConfig["Service"];
95 });
96​
97const makeProjectPersistenceLayer = (config: ServerConfig.ServerConfig["Service"]) =>
98 Layer.mergeAll(
99 OrchestrationLayerLive.pipe(
100 Layer.provideMerge(RepositoryIdentityResolver.layer),
101 Layer.provideMerge(SqlitePersistenceLayerLive),
102 ),
103 WorkspacePaths.layer,
104 ).pipe(Layer.provideMerge(NodeServices.layer), Layer.provide(ServerConfig.layer(config)));
105​
106const readPersistedSnapshot = (baseDir: string) =>
107 Effect.gen(function* () {
108 const config = yield* makeCliTestServerConfig(baseDir);
109 return yield* Effect.gen(function* () {
110 const projectionSnapshotQuery = yield* ProjectionSnapshotQuery.ProjectionSnapshotQuery;
111 return yield* projectionSnapshotQuery.getSnapshot();
112 }).pipe(Effect.provide(makeProjectPersistenceLayer(config)));
113 });
114​
115const withLiveProjectCliServer = <A, E, R>(baseDir: string, run: () => Effect.Effect<A, E, R>) =>
116 Effect.gen(function* () {
117 const config = yield* makeCliTestServerConfig(baseDir);
118 const routesLayer = HttpApiBuilder.layer(ProjectCliHttpApi).pipe(
119 Layer.provide(orchestrationHttpApiLayer),
120 Layer.provide(environmentAuthenticatedAuthLayer),
121 );
122 const appLayer = HttpRouter.serve(routesLayer, {
123 disableListenLog: true,
124 disableLogger: true,
125 }).pipe(
126 Layer.provideMerge(
127 EnvironmentAuth.layer.pipe(
128 Layer.provideMerge(SqlitePersistenceLayerLive),
129 Layer.provide(ServerSecretStore.layer),
130 ),
131 ),
132 Layer.provideMerge(makeProjectPersistenceLayer(config)),
133 Layer.provideMerge(
134 NodeHttpServer.layer(NodeHttp.createServer, {
135 host: "127.0.0.1",
136 port: 0,
137 }),
138 ),
139 Layer.provideMerge(NodeServices.layer),
140 Layer.provide(ServerConfig.layer(config)),
141 );
142​
143 return yield* Effect.scoped(
144 Effect.gen(function* () {
145 const server = yield* HttpServer.HttpServer;
146 const address = server.address;
147 if (typeof address === "string" || !("port" in address)) {
148 assert.fail(`Expected TCP address, got ${address}`);
149 }
150 yield* persistServerRuntimeState({
151 path: config.serverRuntimeStatePath,
152 state: yield* makePersistedServerRuntimeState({
153 config,
154 port: address.port,
155 }),
156 });
157 return yield* run();
158 }).pipe(Effect.provide(Layer.mergeAll(appLayer, NodeServices.layer))),
159 );
160 });
161​
162it.layer(NodeServices.layer)("bin cli parsing", (it) => {
163 it.effect("accepts the built-in lowercase log-level flag values", () =>
164 runCliWithRuntime(["--log-level", "debug", "--version"]),
165 );
166​
167 it.effect("accepts canonical --no-<flag> boolean negation", () =>
168 runCliWithRuntime(["--no-log-websocket-events", "--version"]),
169 );
170​
171 it.effect("rejects invalid log-level casing before launching the server", () =>
172 Effect.gen(function* () {
173 const error = yield* runCliWithRuntime(["--log-level", "Debug"]).pipe(Effect.flip);
174​
175 if (!CliError.isCliError(error)) {
176 assert.fail(`Expected CliError, got ${String(error)}`);
177 }
178 if (error._tag !== "InvalidValue") {
179 assert.fail(`Expected InvalidValue, got ${error._tag}`);
180 }
181 assert.equal(error.option, "log-level");
182 assert.equal(error.value, "Debug");
183 }),
184 );
185​
186 it.effect("rejects connect commands when public configuration is missing", () =>
187 Effect.gen(function* () {
188 const error = yield* runCli(["connect", "status"], noConnectCli).pipe(Effect.flip);
189​
190 if (!CliError.isCliError(error)) {
191 assert.fail(`Expected CliError, got ${String(error)}`);
192 }
193 if (error._tag !== "ShowHelp") {
194 assert.fail(`Expected ShowHelp, got ${error._tag}`);
195 }
196 assert.deepEqual(error.commandPath, ["t3", "connect"]);
197 assert.include(error.errors[0]?.message ?? "", "missing T3 Connect public configuration");
198​
199 const output = (yield* TestConsole.errorLines).join("\n");
200 assert.include(output, "ERROR");
201 assert.include(output, "missing T3 Connect public configuration");
202 }).pipe(Effect.provide(Layer.mergeAll(CliRuntimeLayer, TestConsole.layer))),
203 );
204​
205 it.effect("exposes service lifecycle commands without T3 Connect configuration", () =>
206 Effect.gen(function* () {
207 const { output } = yield* captureStdout(runCli(["service", "--help"], noConnectCli));
208​
209 assert.include(output, "Manage the T3 Code background service.");
210 assert.include(output, "install");
211 assert.include(output, "uninstall");
212 assert.include(output, "update");
213 assert.include(output, "status");
214 }),
215 );
216​
217 it.effect("reports fresh headless connect state without requiring local configuration", () =>
218 Effect.gen(function* () {
219 const baseDir = NodeFS.mkdtempSync(
220 NodePath.join(NodeOS.tmpdir(), "t3-cli-cloud-status-test-"),
221 );
222 const { output } = yield* captureStdout(
223 runConnectCli(["connect", "status", "--base-dir", baseDir, "--json"]),
224 );
225 // @effect-diagnostics-next-line preferSchemaOverJson:off - CLI JSON output is decoded as a presentation DTO.
226 const status = JSON.parse(output) as {
227 readonly desired: boolean;
228 readonly authenticated: boolean;
229 readonly linked: boolean;
230 readonly cloudUserId: string | null;
231 readonly relayUrl: string | null;
232 };
233​
234 assert.equal(status.desired, false);
235 assert.equal(status.authenticated, false);
236 assert.equal(status.linked, false);
237 assert.equal(status.cloudUserId, null);
238 assert.equal(status.relayUrl, null);
239 }),
240 );
241​
242 it.effect("reports actionable human-readable headless connect state", () =>
243 Effect.gen(function* () {
244 const baseDir = NodeFS.mkdtempSync(
245 NodePath.join(NodeOS.tmpdir(), "t3-cli-cloud-status-human-test-"),
246 );
247 const { output } = yield* captureStdout(
248 runConnectCli(["connect", "status", "--base-dir", baseDir]),
249 );
250​
251 assert.include(output, "T3 Connect\n Exposure: disabled");
252 assert.include(output, " Authorization: missing");
253 assert.include(output, " Environment link: not provisioned");
254 assert.include(output, "Next: Run `t3 connect link` to authorize and enable T3 Connect.");
255 }),
256 );
257​
258 it.effect("accepts the --headless login override without enabling access", () =>
259 Effect.gen(function* () {
260 const baseDir = NodeFS.mkdtempSync(
261 NodePath.join(NodeOS.tmpdir(), "t3-cli-cloud-login-test-"),
262 );
263 const { secretsDir } = yield* ServerConfig.deriveServerPaths(baseDir, undefined);
264 NodeFS.mkdirSync(secretsDir, { recursive: true });
265 NodeFS.writeFileSync(
266 NodePath.join(secretsDir, "cloud-cli-oauth-token.bin"),
267 // @effect-diagnostics-next-line preferSchemaOverJson:off - Test fixture matches the persisted CLI token representation.
268 JSON.stringify({
269 accessToken: "access-token",
270 refreshToken: "refresh-token",
271 expiresAtEpochMs: Number.MAX_SAFE_INTEGER,
272 }),
273 );
274​
275 const login = yield* captureStdout(
276 runConnectCli(["connect", "login", "--base-dir", baseDir, "--headless"]),
277 );
278 const status = yield* captureStdout(
279 runConnectCli(["connect", "status", "--base-dir", baseDir, "--json"]),
280 );
281 // @effect-diagnostics-next-line preferSchemaOverJson:off - CLI JSON output is decoded as a presentation DTO.
282 const decoded = JSON.parse(status.output) as {
283 readonly desired: boolean;
284 readonly authenticated: boolean;
285 };
286​
287 assert.equal(login.output, "✓ Signed in");
288 assert.isFalse(decoded.desired);
289 assert.isTrue(decoded.authenticated);
290 }),
291 );
292​
293 it.effect("disables headless connect without a running server", () =>
294 Effect.gen(function* () {
295 const baseDir = NodeFS.mkdtempSync(
296 NodePath.join(NodeOS.tmpdir(), "t3-cli-cloud-unlink-test-"),
297 );
298 const { output } = yield* captureStdout(
299 runConnectCli(["connect", "unlink", "--base-dir", baseDir]),
300 );
301​
302 assert.equal(output, "T3 Connect is disabled locally.");
303 }),
304 );
305​
306 it.effect("logs out of headless connect and removes the stored CLI authorization", () =>
307 Effect.gen(function* () {
308 const baseDir = NodeFS.mkdtempSync(
309 NodePath.join(NodeOS.tmpdir(), "t3-cli-cloud-logout-test-"),
310 );
311 const { secretsDir } = yield* ServerConfig.deriveServerPaths(baseDir, undefined);
312 const tokenPath = NodePath.join(secretsDir, "cloud-cli-oauth-token.bin");
313 NodeFS.mkdirSync(secretsDir, { recursive: true });
314 NodeFS.writeFileSync(tokenPath, "invalid persisted token");
315​
316 const { output } = yield* captureStdout(
317 runConnectCli(["connect", "logout", "--base-dir", baseDir]),
318 );
319​
320 assert.equal(
321 output,
322 "Signed out of T3 Connect locally.\nThe background service is managed separately with `t3 service`.",
323 );
324 assert.isFalse(NodeFS.existsSync(tokenPath));
325 }),
326 );
327​
328 it.effect("executes auth pairing subcommands and redacts secrets from list output", () =>
329 Effect.gen(function* () {
330 const baseDir = NodeFS.mkdtempSync(
331 NodePath.join(NodeOS.tmpdir(), "t3-cli-auth-pairing-test-"),
332 );
333​
334 const createdOutput = yield* captureStdout(
335 runCli(["auth", "pairing", "create", "--base-dir", baseDir, "--json"]),
336 );
337 // @effect-diagnostics-next-line preferSchemaOverJson:off
338 const created = JSON.parse(createdOutput.output) as {
339 readonly id: string;
340 readonly credential: string;
341 };
342 const listedOutput = yield* captureStdout(
343 runCli(["auth", "pairing", "list", "--base-dir", baseDir, "--json"]),
344 );
345 // @effect-diagnostics-next-line preferSchemaOverJson:off
346 const listed = JSON.parse(listedOutput.output) as ReadonlyArray<{
347 readonly id: string;
348 readonly credential?: string;
349 }>;
350​
351 assert.equal(typeof created.id, "string");
352 assert.equal(typeof created.credential, "string");
353 assert.equal(created.credential.length > 0, true);
354 assert.equal(listed.length, 1);
355 assert.equal(listed[0]?.id, created.id);
356 assert.equal("credential" in (listed[0] ?? {}), false);
357 }),
358 );
359​
360 it.effect("executes auth session subcommands and redacts secrets from list output", () =>
361 Effect.gen(function* () {
362 const baseDir = NodeFS.mkdtempSync(
363 NodePath.join(NodeOS.tmpdir(), "t3-cli-auth-session-test-"),
364 );
365​
366 const issuedOutput = yield* captureStdout(
367 runCli(["auth", "session", "issue", "--base-dir", baseDir, "--json"]),
368 );
369 // @effect-diagnostics-next-line preferSchemaOverJson:off
370 const issued = JSON.parse(issuedOutput.output) as {
371 readonly sessionId: string;
372 readonly token: string;
373 readonly scopes: ReadonlyArray<string>;
374 };
375 const listedOutput = yield* captureStdout(
376 runCli(["auth", "session", "list", "--base-dir", baseDir, "--json"]),
377 );
378 // @effect-diagnostics-next-line preferSchemaOverJson:off
379 const listed = JSON.parse(listedOutput.output) as ReadonlyArray<{
380 readonly sessionId: string;
381 readonly token?: string;
382 readonly scopes: ReadonlyArray<string>;
383 }>;
384​
385 assert.equal(typeof issued.sessionId, "string");
386 assert.equal(typeof issued.token, "string");
387 assert.deepEqual(issued.scopes, [
388 "orchestration:read",
389 "orchestration:operate",
390 "terminal:operate",
391 "review:write",
392 "relay:read",
393 "access:read",
394 "access:write",
395 "relay:write",
396 ]);
397 assert.equal(listed.length, 1);
398 assert.equal(listed[0]?.sessionId, issued.sessionId);
399 assert.deepEqual(listed[0]?.scopes, [
400 "orchestration:read",
401 "orchestration:operate",
402 "terminal:operate",
403 "review:write",
404 "relay:read",
405 "access:read",
406 "access:write",
407 "relay:write",
408 ]);
409 assert.equal("token" in (listed[0] ?? {}), false);
410 }),
411 );
412​
413 it.effect("rejects invalid ttl values before running auth commands", () =>
414 Effect.gen(function* () {
415 const error = yield* runCliWithRuntime(["auth", "pairing", "create", "--ttl", "soon"]).pipe(
416 Effect.flip,
417 );
418​
419 if (!CliError.isCliError(error)) {
420 assert.fail(`Expected CliError, got ${String(error)}`);
421 }
422 if (error._tag !== "ShowHelp") {
423 assert.fail(`Expected ShowHelp, got ${error._tag}`);
424 }
425 assert.deepEqual(error.commandPath, ["t3", "auth", "pairing", "create"]);
426 const ttlError = error.errors[0] as CliError.CliError | undefined;
427 if (!ttlError || ttlError._tag !== "InvalidValue") {
428 assert.fail(`Expected InvalidValue, got ${String(ttlError?._tag)}`);
429 }
430 assert.equal(ttlError.option, "ttl");
431 assert.equal(ttlError.value, "soon");
432 assert.isTrue(ttlError.message.includes("Invalid duration"));
433 assert.isTrue(ttlError.message.includes("5m, 1h, 30d, or 15 minutes"));
434 }),
435 );
436​
437 it.effect("adds, renames, and removes projects offline through the orchestration engine", () =>
438 Effect.gen(function* () {
439 const baseDir = NodeFS.mkdtempSync(
440 NodePath.join(NodeOS.tmpdir(), "t3-cli-projects-offline-test-"),
441 );
442 const workspaceRoot = NodeFS.mkdtempSync(
443 NodePath.join(NodeOS.tmpdir(), "t3-cli-projects-workspace-"),
444 );
445​
446 yield* runCliWithRuntime([
447 "project",
448 "add",
449 workspaceRoot,
450 "--title",
451 "Alpha",
452 "--base-dir",
453 baseDir,
454 ]);
455 const afterAdd = yield* readPersistedSnapshot(baseDir);
456 const addedProject = afterAdd.projects.find(
457 (project) => project.workspaceRoot === workspaceRoot && project.deletedAt === null,
458 );
459 assert.isTrue(addedProject !== undefined);
460 assert.equal(addedProject?.title, "Alpha");
461​
462 yield* runCliWithRuntime(["project", "rename", workspaceRoot, "Beta", "--base-dir", baseDir]);
463 const afterRename = yield* readPersistedSnapshot(baseDir);
464 const renamedProject = afterRename.projects.find(
465 (project) => project.id === addedProject?.id,
466 );
467 assert.equal(renamedProject?.title, "Beta");
468 assert.equal(renamedProject?.deletedAt, null);
469​
470 yield* runCliWithRuntime([
471 "project",
472 "remove",
473 addedProject?.id ?? "",
474 "--base-dir",
475 baseDir,
476 ]);
477 const afterRemove = yield* readPersistedSnapshot(baseDir);
478 const removedProject = afterRemove.projects.find(
479 (project) => project.id === addedProject?.id,
480 );
481 assert.isTrue((removedProject?.deletedAt ?? null) !== null);
482 }),
483 );
484​
485 it.effect("force removes projects that still contain threads", () =>
486 Effect.gen(function* () {
487 const baseDir = NodeFS.mkdtempSync(
488 NodePath.join(NodeOS.tmpdir(), "t3-cli-projects-force-remove-test-"),
489 );
490 const workspaceRoot = NodeFS.mkdtempSync(
491 NodePath.join(NodeOS.tmpdir(), "t3-cli-projects-force-remove-workspace-"),
492 );
493​
494 yield* runCliWithRuntime(["project", "add", workspaceRoot, "--base-dir", baseDir]);
495 const afterAdd = yield* readPersistedSnapshot(baseDir);
496 const project = afterAdd.projects.find(
497 (candidate) => candidate.workspaceRoot === workspaceRoot && candidate.deletedAt === null,
498 );
499 assert.isTrue(project !== undefined);
500​
501 const config = yield* makeCliTestServerConfig(baseDir);
502 yield* Effect.gen(function* () {
503 const engine = yield* OrchestrationEngine.OrchestrationEngineService;
504 yield* engine.dispatch({
505 type: "thread.create",
506 commandId: CommandId.make("cmd-cli-force-remove-thread"),
507 threadId: ThreadId.make("thread-cli-force-remove"),
508 projectId: project!.id,
509 title: "Thread",
510 modelSelection: {
511 instanceId: ProviderInstanceId.make("codex"),
512 model: "gpt-5-codex",
513 },
514 interactionMode: "default",
515 runtimeMode: "approval-required",
516 branch: null,
517 worktreePath: null,
518 createdAt: DateTime.formatIso(yield* DateTime.now),
519 });
520 }).pipe(Effect.provide(makeProjectPersistenceLayer(config)));
521​
522 yield* runCliWithRuntime([
523 "project",
524 "remove",
525 project!.id,
526 "--force",
527 "--base-dir",
528 baseDir,
529 ]);
530 const afterRemove = yield* readPersistedSnapshot(baseDir);
531 assert.isTrue(
532 (afterRemove.projects.find((candidate) => candidate.id === project!.id)?.deletedAt ??
533 null) !== null,
534 );
535 assert.isTrue(
536 (afterRemove.threads.find((thread) => thread.id === "thread-cli-force-remove")?.deletedAt ??
537 null) !== null,
538 );
539 }),
540 );
541​
542 it.effect("routes project commands through a running server when runtime state is present", () =>
543 Effect.gen(function* () {
544 const baseDir = NodeFS.mkdtempSync(
545 NodePath.join(NodeOS.tmpdir(), "t3-cli-projects-live-test-"),
546 );
547 const workspaceRoot = NodeFS.mkdtempSync(
548 NodePath.join(NodeOS.tmpdir(), "t3-cli-projects-live-workspace-"),
549 );
550​
551 yield* withLiveProjectCliServer(baseDir, () =>
552 Effect.gen(function* () {
553 yield* runCliWithRuntime([
554 "project",
555 "add",
556 workspaceRoot,
557 "--title",
558 "Live Project",
559 "--base-dir",
560 baseDir,
561 ]);
562 const projectionSnapshotQuery = yield* ProjectionSnapshotQuery.ProjectionSnapshotQuery;
563 const readModel = yield* projectionSnapshotQuery.getSnapshot();
564 const addedProject = readModel.projects.find(
565 (project) => project.workspaceRoot === workspaceRoot && project.deletedAt === null,
566 );
567 assert.isTrue(addedProject !== undefined);
568 assert.equal(addedProject?.title, "Live Project");
569 }),
570 );
571 }),
572 );
573​
574 it.effect("rejects dev-url on project commands", () =>
575 Effect.gen(function* () {
576 const workspaceRoot = NodeFS.mkdtempSync(
577 NodePath.join(NodeOS.tmpdir(), "t3-cli-projects-unknown-option-workspace-"),
578 );
579 const error = yield* runCliWithRuntime([
580 "project",
581 "add",
582 workspaceRoot,
583 "--dev-url",
584 "http://127.0.0.1:5173",
585 ]).pipe(Effect.flip);
586​
587 if (!CliError.isCliError(error)) {
588 assert.fail(`Expected CliError, got ${String(error)}`);
589 }
590 if (error._tag !== "ShowHelp") {
591 assert.fail(`Expected ShowHelp, got ${error._tag}`);
592 }
593 assert.deepEqual(error.commandPath, ["t3", "project", "add"]);
594 const optionError = error.errors[0] as CliError.CliError | undefined;
595 if (!optionError || optionError._tag !== "UnrecognizedOption") {
596 assert.fail(`Expected UnrecognizedOption, got ${String(optionError?._tag)}`);
597 }
598 assert.equal(optionError.option, "--dev-url");
599 }),
600 );
601});