Open History to see the last commit
1import * as NodeServices from "@effect/platform-node/NodeServices";
2import { it as effectIt } from "@effect/vitest";
3import { HostProcessEnvironment, HostProcessPlatform } from "@t3tools/shared/hostProcess";
4import * as Effect from "effect/Effect";
5import { describe, expect, it, vi } from "vite-plus/test";
6
7import {
8 extractPathFromShellOutput,
9 CommandAvailability,
10 type CommandAvailabilityChecker,
11 isCommandAvailable,
12 listLoginShellCandidates,
13 mergePathEntries,
14 mergePathValues,
15 readEnvironmentFromLoginShell,
16 readEnvironmentFromWindowsShell,
17 readPathFromLaunchctl,
18 readPathFromLoginShell,
19 resolveCommandPath,
20 resolveKnownWindowsCliDirs,
21 resolveSpawnCommand,
22 resolveWindowsEnvironment,
23 SpawnExecutableResolution,
24 WindowsShellEnvironment,
25 type WindowsShellEnvironmentReader,
26} from "./shell.ts";
27
28const withWindowsEnvironmentMocks = <A, E, R>(
29 effect: Effect.Effect<A, E, R>,
30 readEnvironment: WindowsShellEnvironmentReader,
31 commandAvailable: CommandAvailabilityChecker,
32) =>
33 effect.pipe(
34 Effect.provideService(WindowsShellEnvironment, readEnvironment),
35 Effect.provideService(CommandAvailability, commandAvailable),
36 );
37
38describe("extractPathFromShellOutput", () => {
39 it("extracts the path between capture markers", () => {
40 expect(
41 extractPathFromShellOutput(
42 "__T3CODE_PATH_START__\n/opt/homebrew/bin:/usr/bin\n__T3CODE_PATH_END__\n",
43 ),
44 ).toBe("/opt/homebrew/bin:/usr/bin");
45 });
46
47 it("ignores shell startup noise around the capture markers", () => {
48 expect(
49 extractPathFromShellOutput(
50 "Welcome to fish\n__T3CODE_PATH_START__\n/opt/homebrew/bin:/usr/bin\n__T3CODE_PATH_END__\nBye\n",
51 ),
52 ).toBe("/opt/homebrew/bin:/usr/bin");
53 });
54
55 it("returns null when the markers are missing", () => {
56 expect(extractPathFromShellOutput("/opt/homebrew/bin /usr/bin")).toBeNull();
57 });
58});
59
60describe("readPathFromLoginShell", () => {
61 it("uses a shell-agnostic printenv PATH probe", () => {
62 const execFile = vi.fn<
63 (
64 file: string,
65 args: ReadonlyArray<string>,
66 options: { encoding: "utf8"; timeout: number },
67 ) => string
68 >(() => "__T3CODE_ENV_PATH_START__\n/a:/b\n__T3CODE_ENV_PATH_END__\n");
69
70 expect(readPathFromLoginShell("/opt/homebrew/bin/fish", execFile)).toBe("/a:/b");
71 expect(execFile).toHaveBeenCalledTimes(1);
72
73 const firstCall = execFile.mock.calls[0] as
74 | [string, ReadonlyArray<string>, { encoding: "utf8"; timeout: number }]
75 | undefined;
76 expect(firstCall).toBeDefined();
77 if (!firstCall) {
78 throw new Error("Expected execFile to be called");
79 }
80
81 const [shell, args, options] = firstCall;
82 expect(shell).toBe("/opt/homebrew/bin/fish");
83 expect(args).toHaveLength(2);
84 expect(args?.[0]).toBe("-ilc");
85 expect(args?.[1]).toContain("printenv PATH || true");
86 expect(args?.[1]).toContain("__T3CODE_ENV_PATH_START__");
87 expect(args?.[1]).toContain("__T3CODE_ENV_PATH_END__");
88 expect(options).toEqual({ encoding: "utf8", timeout: 5000 });
89 });
90});
91
92describe("readPathFromLaunchctl", () => {
93 it("returns a trimmed PATH value from launchctl", () => {
94 const execFile = vi.fn<
95 (
96 file: string,
97 args: ReadonlyArray<string>,
98 options: { encoding: "utf8"; timeout: number },
99 ) => string
100 >(() => " /opt/homebrew/bin:/usr/bin \n");
101
102 expect(readPathFromLaunchctl(execFile)).toBe("/opt/homebrew/bin:/usr/bin");
103 expect(execFile).toHaveBeenCalledWith("/bin/launchctl", ["getenv", "PATH"], {
104 encoding: "utf8",
105 timeout: 2000,
106 });
107 });
108
109 it("returns undefined when launchctl is unavailable", () => {
110 const execFile = vi.fn<
111 (
112 file: string,
113 args: ReadonlyArray<string>,
114 options: { encoding: "utf8"; timeout: number },
115 ) => string
116 >(() => {
117 throw new Error("spawn /bin/launchctl ENOENT");
118 });
119
120 expect(readPathFromLaunchctl(execFile)).toBeUndefined();
121 });
122});
123
124describe("readEnvironmentFromLoginShell", () => {
125 it("extracts multiple environment variables from a login shell command", () => {
126 const execFile = vi.fn<
127 (
128 file: string,
129 args: ReadonlyArray<string>,
130 options: { encoding: "utf8"; timeout: number },
131 ) => string
132 >(() =>
133 [
134 "__T3CODE_ENV_PATH_START__",
135 "/a:/b",
136 "__T3CODE_ENV_PATH_END__",
137 "__T3CODE_ENV_SSH_AUTH_SOCK_START__",
138 "/tmp/secretive.sock",
139 "__T3CODE_ENV_SSH_AUTH_SOCK_END__",
140 ].join("\n"),
141 );
142
143 expect(readEnvironmentFromLoginShell("/bin/zsh", ["PATH", "SSH_AUTH_SOCK"], execFile)).toEqual({
144 PATH: "/a:/b",
145 SSH_AUTH_SOCK: "/tmp/secretive.sock",
146 });
147 expect(execFile).toHaveBeenCalledTimes(1);
148 });
149
150 it("omits environment variables that are missing or empty", () => {
151 const execFile = vi.fn<
152 (
153 file: string,
154 args: ReadonlyArray<string>,
155 options: { encoding: "utf8"; timeout: number },
156 ) => string
157 >(() =>
158 [
159 "__T3CODE_ENV_PATH_START__",
160 "/a:/b",
161 "__T3CODE_ENV_PATH_END__",
162 "__T3CODE_ENV_SSH_AUTH_SOCK_START__",
163 "__T3CODE_ENV_SSH_AUTH_SOCK_END__",
164 ].join("\n"),
165 );
166
167 expect(readEnvironmentFromLoginShell("/bin/zsh", ["PATH", "SSH_AUTH_SOCK"], execFile)).toEqual({
168 PATH: "/a:/b",
169 });
170 });
171
172 it("preserves surrounding whitespace in captured values", () => {
173 const execFile = vi.fn<
174 (
175 file: string,
176 args: ReadonlyArray<string>,
177 options: { encoding: "utf8"; timeout: number },
178 ) => string
179 >(() =>
180 ["__T3CODE_ENV_CUSTOM_VAR_START__", " padded value ", "__T3CODE_ENV_CUSTOM_VAR_END__"].join(
181 "\n",
182 ),
183 );
184
185 expect(readEnvironmentFromLoginShell("/bin/zsh", ["CUSTOM_VAR"], execFile)).toEqual({
186 CUSTOM_VAR: " padded value ",
187 });
188 });
189});
190
191describe("listLoginShellCandidates", () => {
192 it("returns env shell, user shell, then the platform fallback without duplicates", () => {
193 expect(listLoginShellCandidates("darwin", " /opt/homebrew/bin/nu ", "/bin/zsh")).toEqual([
194 "/opt/homebrew/bin/nu",
195 "/bin/zsh",
196 ]);
197 });
198
199 it("falls back to the platform default when no shells are available", () => {
200 expect(listLoginShellCandidates("linux", undefined, "")).toEqual(["/bin/bash"]);
201 });
202});
203
204describe("mergePathEntries", () => {
205 it("prefers login-shell PATH entries and keeps inherited extras", () => {
206 expect(
207 mergePathEntries("/opt/homebrew/bin:/usr/bin", "/Users/test/.local/bin:/usr/bin", "darwin"),
208 ).toBe("/opt/homebrew/bin:/usr/bin:/Users/test/.local/bin");
209 });
210
211 it("uses the platform-specific delimiter", () => {
212 expect(mergePathEntries("C:\\Tools;C:\\Windows", "C:\\Windows;C:\\Git", "win32")).toBe(
213 "C:\\Tools;C:\\Windows;C:\\Git",
214 );
215 });
216});
217
218describe("readEnvironmentFromWindowsShell", () => {
219 it("extracts environment variables from a PowerShell command", () => {
220 const execFile = vi.fn<
221 (
222 file: string,
223 args: ReadonlyArray<string>,
224 options: { encoding: "utf8"; timeout: number },
225 ) => string
226 >(
227 () =>
228 "__T3CODE_ENV_PATH_START__\nC:\\Users\\testuser\\AppData\\Roaming\\npm\n__T3CODE_ENV_PATH_END__\n",
229 );
230
231 expect(readEnvironmentFromWindowsShell(["PATH"], execFile)).toEqual({
232 PATH: "C:\\Users\\testuser\\AppData\\Roaming\\npm",
233 });
234 expect(execFile).toHaveBeenCalledWith(
235 "pwsh.exe",
236 expect.arrayContaining(["-NoLogo", "-NoProfile", "-NonInteractive", "-Command"]),
237 { encoding: "utf8", timeout: 5000 },
238 );
239 const command = execFile.mock.calls[0]?.[1]?.at(-1);
240 expect(command).toContain("[Environment]::GetEnvironmentVariable('PATH', 'Machine')");
241 expect(command).toContain("[Environment]::GetEnvironmentVariable('PATH', 'User')");
242 });
243
244 it("strips CRLF delimiters from captured PowerShell values", () => {
245 const execFile = vi.fn<
246 (
247 file: string,
248 args: ReadonlyArray<string>,
249 options: { encoding: "utf8"; timeout: number },
250 ) => string
251 >(
252 () =>
253 "__T3CODE_ENV_FNM_DIR_START__\r\nC:\\Users\\testuser\\AppData\\Roaming\\fnm\r\n__T3CODE_ENV_FNM_DIR_END__\r\n",
254 );
255
256 expect(readEnvironmentFromWindowsShell(["FNM_DIR"], execFile)).toEqual({
257 FNM_DIR: "C:\\Users\\testuser\\AppData\\Roaming\\fnm",
258 });
259 });
260
261 it("omits -NoProfile when loadProfile is enabled", () => {
262 const execFile = vi.fn<
263 (
264 file: string,
265 args: ReadonlyArray<string>,
266 options: { encoding: "utf8"; timeout: number },
267 ) => string
268 >(() => "__T3CODE_ENV_PATH_START__\nC:\\Tools\n__T3CODE_ENV_PATH_END__\n");
269
270 expect(readEnvironmentFromWindowsShell(["PATH"], { loadProfile: true }, execFile)).toEqual({
271 PATH: "C:\\Tools",
272 });
273 expect(execFile).toHaveBeenCalledWith(
274 "pwsh.exe",
275 expect.arrayContaining(["-NoLogo", "-NonInteractive", "-Command"]),
276 { encoding: "utf8", timeout: 5000 },
277 );
278 expect(execFile.mock.calls[0]?.[1]).not.toContain("-NoProfile");
279 });
280
281 it("falls back to Windows PowerShell when pwsh.exe is unavailable", () => {
282 const execFile = vi.fn<
283 (
284 file: string,
285 args: ReadonlyArray<string>,
286 options: { encoding: "utf8"; timeout: number },
287 ) => string
288 >((file) => {
289 if (file === "pwsh.exe") {
290 throw new Error("spawn pwsh.exe ENOENT");
291 }
292 return "__T3CODE_ENV_PATH_START__\nC:\\Tools\n__T3CODE_ENV_PATH_END__\n";
293 });
294
295 expect(readEnvironmentFromWindowsShell(["PATH"], execFile)).toEqual({
296 PATH: "C:\\Tools",
297 });
298 expect(execFile).toHaveBeenNthCalledWith(1, "pwsh.exe", expect.any(Array), {
299 encoding: "utf8",
300 timeout: 5000,
301 });
302 expect(execFile).toHaveBeenNthCalledWith(2, "powershell.exe", expect.any(Array), {
303 encoding: "utf8",
304 timeout: 5000,
305 });
306 });
307});
308
309describe("mergePathValues", () => {
310 it("dedupes case-insensitively on Windows while preserving preferred order", () => {
311 expect(
312 mergePathValues(
313 'C:\\Users\\testuser\\AppData\\Roaming\\npm;"C:\\Program Files\\nodejs"',
314 "c:\\users\\testuser\\appdata\\roaming\\npm;C:\\Windows\\System32",
315 "win32",
316 ),
317 ).toBe(
318 'C:\\Users\\testuser\\AppData\\Roaming\\npm;"C:\\Program Files\\nodejs";C:\\Windows\\System32',
319 );
320 });
321
322 it("dedupes case-sensitively on POSIX", () => {
323 expect(mergePathValues("/usr/local/bin:/usr/bin", "/usr/bin:/USR/BIN", "linux")).toBe(
324 "/usr/local/bin:/usr/bin:/USR/BIN",
325 );
326 });
327});
328
329describe("resolveKnownWindowsCliDirs", () => {
330 it("returns known Windows CLI install directories in priority order", () => {
331 expect(
332 resolveKnownWindowsCliDirs({
333 APPDATA: "C:\\Users\\testuser\\AppData\\Roaming",
334 LOCALAPPDATA: "C:\\Users\\testuser\\AppData\\Local",
335 USERPROFILE: "C:\\Users\\testuser",
336 }),
337 ).toEqual([
338 "C:\\Users\\testuser\\AppData\\Roaming\\npm",
339 "C:\\Users\\testuser\\AppData\\Local\\Programs\\nodejs",
340 "C:\\Users\\testuser\\AppData\\Local\\Programs\\OpenAI\\Codex\\bin",
341 "C:\\Users\\testuser\\AppData\\Local\\Volta\\bin",
342 "C:\\Users\\testuser\\AppData\\Local\\pnpm",
343 "C:\\Users\\testuser\\.local\\bin",
344 "C:\\Users\\testuser\\.bun\\bin",
345 "C:\\Users\\testuser\\scoop\\shims",
346 ]);
347 });
348});
349
350effectIt.layer(NodeServices.layer)("isCommandAvailable", (it) => {
351 it.effect("returns false when PATH is empty", () =>
352 Effect.gen(function* () {
353 expect(
354 yield* isCommandAvailable("definitely-not-installed", {
355 env: { PATH: "", PATHEXT: ".COM;.EXE;.BAT;.CMD" },
356 }).pipe(Effect.provideService(HostProcessPlatform, "win32")),
357 ).toBe(false);
358 }),
359 );
360});
361
362effectIt.layer(NodeServices.layer)("resolveCommandPath", (it) => {
363 it.effect("fails when PATH is empty", () =>
364 Effect.gen(function* () {
365 const result = yield* resolveCommandPath("definitely-not-installed", {
366 env: { PATH: "", PATHEXT: ".COM;.EXE;.BAT;.CMD" },
367 }).pipe(Effect.provideService(HostProcessPlatform, "win32"), Effect.result);
368
369 expect(result._tag).toBe("Failure");
370 }),
371 );
372});
373
374effectIt.layer(NodeServices.layer)("resolveSpawnCommand", (it) => {
375 it.effect("runs Windows executables directly without a shell", () =>
376 Effect.gen(function* () {
377 const command = yield* resolveSpawnCommand("node.exe", ["script.js", "hello & goodbye"], {
378 env: { PATH: "", PATHEXT: ".COM;.EXE;.BAT;.CMD" },
379 }).pipe(Effect.provideService(HostProcessPlatform, "win32"));
380
381 expect(command).toEqual({
382 command: "node.exe",
383 args: ["script.js", "hello & goodbye"],
384 shell: false,
385 });
386 }),
387 );
388
389 it.effect("escapes the executable and arguments for Windows command shims", () =>
390 Effect.gen(function* () {
391 const command = yield* resolveSpawnCommand(
392 "vp",
393 ["run", "value & calc", "%PATH%", 'quote"value'],
394 { env: { PATH: "", PATHEXT: ".COM;.EXE;.BAT;.CMD" } },
395 ).pipe(
396 Effect.provideService(HostProcessPlatform, "win32"),
397 Effect.provideService(
398 SpawnExecutableResolution,
399 () => "C:\\Program Files\\npm & tools\\vp.cmd",
400 ),
401 );
402
403 expect(command.shell).toBe(true);
404 expect(command.command).not.toContain(" & ");
405 expect(command.command).toContain("^&");
406 expect(command.args).toEqual([
407 '^"run^"',
408 '^"value^ ^&^ calc^"',
409 '^"^%PATH^%^"',
410 '^"quote\\^"value^"',
411 ]);
412 }),
413 );
414
415 it.effect("resolves against the effective environment when extending host env", () =>
416 Effect.gen(function* () {
417 let resolvedEnvironment: NodeJS.ProcessEnv | undefined;
418 yield* resolveSpawnCommand("codex", ["app-server"], {
419 env: { CODEX_HOME: "C:\\Users\\tester\\.codex" },
420 extendEnv: true,
421 }).pipe(
422 Effect.provideService(HostProcessPlatform, "win32"),
423 Effect.provideService(HostProcessEnvironment, {
424 PATH: "C:\\Users\\tester\\AppData\\Roaming\\npm",
425 PATHEXT: ".COM;.EXE;.BAT;.CMD",
426 }),
427 Effect.provideService(SpawnExecutableResolution, (_command, _platform, env) => {
428 resolvedEnvironment = env;
429 return "C:\\Users\\tester\\AppData\\Roaming\\npm\\codex.cmd";
430 }),
431 );
432
433 expect(resolvedEnvironment).toEqual({
434 PATH: "C:\\Users\\tester\\AppData\\Roaming\\npm",
435 PATHEXT: ".COM;.EXE;.BAT;.CMD",
436 CODEX_HOME: "C:\\Users\\tester\\.codex",
437 });
438 }),
439 );
440
441 it.effect("does not fall back to a shell for unresolved Windows commands", () =>
442 Effect.gen(function* () {
443 const command = yield* resolveSpawnCommand("missing & calc", ["unsafe & value"], {
444 env: { PATH: "", PATHEXT: ".COM;.EXE;.BAT;.CMD" },
445 }).pipe(Effect.provideService(HostProcessPlatform, "win32"));
446
447 expect(command).toEqual({
448 command: "missing & calc",
449 args: ["unsafe & value"],
450 shell: false,
451 });
452 }),
453 );
454});
455
456effectIt.layer(NodeServices.layer)("resolveWindowsEnvironment", (it) => {
457 it.effect("returns the baseline no-profile PATH patch when node is already available", () =>
458 Effect.gen(function* () {
459 const readEnvironment = vi.fn(
460 (_names: ReadonlyArray<string>, options?: { loadProfile?: boolean }) =>
461 options?.loadProfile
462 ? { PATH: "C:\\Profile\\Bin" }
463 : { PATH: "C:\\Shell\\Bin;C:\\Windows\\System32" },
464 );
465 const commandAvailable = vi.fn(() => Effect.succeed(true));
466
467 expect(
468 yield* withWindowsEnvironmentMocks(
469 resolveWindowsEnvironment({
470 PATH: "C:\\Windows\\System32",
471 APPDATA: "C:\\Users\\testuser\\AppData\\Roaming",
472 LOCALAPPDATA: "C:\\Users\\testuser\\AppData\\Local",
473 USERPROFILE: "C:\\Users\\testuser",
474 }),
475 readEnvironment,
476 commandAvailable,
477 ),
478 ).toEqual({
479 PATH: [
480 "C:\\Users\\testuser\\AppData\\Roaming\\npm",
481 "C:\\Users\\testuser\\AppData\\Local\\Programs\\nodejs",
482 "C:\\Users\\testuser\\AppData\\Local\\Programs\\OpenAI\\Codex\\bin",
483 "C:\\Users\\testuser\\AppData\\Local\\Volta\\bin",
484 "C:\\Users\\testuser\\AppData\\Local\\pnpm",
485 "C:\\Users\\testuser\\.local\\bin",
486 "C:\\Users\\testuser\\.bun\\bin",
487 "C:\\Users\\testuser\\scoop\\shims",
488 "C:\\Shell\\Bin",
489 "C:\\Windows\\System32",
490 ].join(";"),
491 });
492 expect(readEnvironment).toHaveBeenCalledTimes(1);
493 expect(readEnvironment).toHaveBeenCalledWith(["PATH"], { loadProfile: false });
494 expect(commandAvailable).toHaveBeenCalledWith(
495 "node",
496 expect.objectContaining({ env: expect.any(Object) }),
497 );
498 }),
499 );
500
501 it.effect("loads the PowerShell profile when baseline env cannot resolve node", () =>
502 Effect.gen(function* () {
503 const readEnvironment = vi.fn(
504 (_names: ReadonlyArray<string>, options?: { loadProfile?: boolean }) =>
505 options?.loadProfile
506 ? {
507 PATH: "C:\\Profile\\Node;C:\\Windows\\System32",
508 FNM_DIR: "C:\\Users\\testuser\\AppData\\Roaming\\fnm",
509 FNM_MULTISHELL_PATH: "C:\\Users\\testuser\\AppData\\Local\\fnm_multishells\\123",
510 }
511 : { PATH: "C:\\Shell\\Bin;C:\\Windows\\System32" },
512 );
513 const commandAvailable = vi.fn(() => Effect.succeed(false));
514
515 expect(
516 yield* withWindowsEnvironmentMocks(
517 resolveWindowsEnvironment({
518 PATH: "C:\\Windows\\System32",
519 APPDATA: "C:\\Users\\testuser\\AppData\\Roaming",
520 LOCALAPPDATA: "C:\\Users\\testuser\\AppData\\Local",
521 USERPROFILE: "C:\\Users\\testuser",
522 }),
523 readEnvironment,
524 commandAvailable,
525 ),
526 ).toEqual({
527 PATH: [
528 "C:\\Profile\\Node",
529 "C:\\Windows\\System32",
530 "C:\\Users\\testuser\\AppData\\Roaming\\npm",
531 "C:\\Users\\testuser\\AppData\\Local\\Programs\\nodejs",
532 "C:\\Users\\testuser\\AppData\\Local\\Programs\\OpenAI\\Codex\\bin",
533 "C:\\Users\\testuser\\AppData\\Local\\Volta\\bin",
534 "C:\\Users\\testuser\\AppData\\Local\\pnpm",
535 "C:\\Users\\testuser\\.local\\bin",
536 "C:\\Users\\testuser\\.bun\\bin",
537 "C:\\Users\\testuser\\scoop\\shims",
538 "C:\\Shell\\Bin",
539 ].join(";"),
540 FNM_DIR: "C:\\Users\\testuser\\AppData\\Roaming\\fnm",
541 FNM_MULTISHELL_PATH: "C:\\Users\\testuser\\AppData\\Local\\fnm_multishells\\123",
542 });
543 expect(readEnvironment).toHaveBeenNthCalledWith(1, ["PATH"], { loadProfile: false });
544 expect(readEnvironment).toHaveBeenNthCalledWith(
545 2,
546 ["PATH", "FNM_DIR", "FNM_MULTISHELL_PATH"],
547 {
548 loadProfile: true,
549 },
550 );
551 expect(commandAvailable).toHaveBeenCalledTimes(1);
552 }),
553 );
554
555 it.effect("keeps the baseline env when profiled probe still does not resolve node", () =>
556 Effect.gen(function* () {
557 const readEnvironment = vi.fn(
558 (_names: ReadonlyArray<string>, options?: { loadProfile?: boolean }) =>
559 options?.loadProfile ? { FNM_DIR: "C:\\Users\\testuser\\AppData\\Roaming\\fnm" } : {},
560 );
561 const commandAvailable = vi.fn(() => Effect.succeed(false));
562
563 expect(
564 yield* withWindowsEnvironmentMocks(
565 resolveWindowsEnvironment({
566 PATH: "C:\\Windows\\System32",
567 APPDATA: "C:\\Users\\testuser\\AppData\\Roaming",
568 USERPROFILE: "C:\\Users\\testuser",
569 }),
570 readEnvironment,
571 commandAvailable,
572 ),
573 ).toEqual({
574 PATH: [
575 "C:\\Users\\testuser\\AppData\\Roaming\\npm",
576 "C:\\Users\\testuser\\.local\\bin",
577 "C:\\Users\\testuser\\.bun\\bin",
578 "C:\\Users\\testuser\\scoop\\shims",
579 "C:\\Windows\\System32",
580 ].join(";"),
581 FNM_DIR: "C:\\Users\\testuser\\AppData\\Roaming\\fnm",
582 });
583 expect(commandAvailable).toHaveBeenCalledTimes(1);
584 }),
585 );
586});