Skip to content

Commit 847f39e

Browse files
only21milclaude
andcommitted
test(cli): cover each non-terminal stream in the onboarding prompt guard
The test set stdin and stdout non-TTY together, so a guard that checked only stdin would still pass. Run the case for stdin alone, stdout alone, and both. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 4014528 commit 847f39e

1 file changed

Lines changed: 28 additions & 18 deletions

File tree

‎apps/server/src/cli/service.test.ts‎

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -112,26 +112,36 @@ it.effect("leaves a newer service unchanged during onboarding without prompting"
112112
}),
113113
);
114114

115-
const withoutTerminal = Effect.acquireRelease(
116-
Effect.sync(() =>
117-
[process.stdin, process.stdout].map((stream) => {
118-
const descriptor = Object.getOwnPropertyDescriptor(stream, "isTTY");
119-
Object.defineProperty(stream, "isTTY", { configurable: true, value: false });
120-
return { stream, descriptor };
121-
}),
122-
),
123-
(saved) =>
124-
Effect.sync(() => {
125-
for (const { stream, descriptor } of saved) {
126-
if (descriptor === undefined) Reflect.deleteProperty(stream, "isTTY");
127-
else Object.defineProperty(stream, "isTTY", descriptor);
128-
}
129-
}),
130-
);
115+
const withTerminal = (isTTY: { readonly stdin: boolean; readonly stdout: boolean }) =>
116+
Effect.acquireRelease(
117+
Effect.sync(() =>
118+
(
119+
[
120+
[process.stdin, isTTY.stdin],
121+
[process.stdout, isTTY.stdout],
122+
] as const
123+
).map(([stream, value]) => {
124+
const descriptor = Object.getOwnPropertyDescriptor(stream, "isTTY");
125+
Object.defineProperty(stream, "isTTY", { configurable: true, value });
126+
return { stream, descriptor };
127+
}),
128+
),
129+
(saved) =>
130+
Effect.sync(() => {
131+
for (const { stream, descriptor } of saved) {
132+
if (descriptor === undefined) Reflect.deleteProperty(stream, "isTTY");
133+
else Object.defineProperty(stream, "isTTY", descriptor);
134+
}
135+
}),
136+
);
131137

132-
it.effect("skips the onboarding service prompt when there is no terminal", () =>
138+
it.effect.each([
139+
{ label: "stdin and stdout are", stdin: false, stdout: false },
140+
{ label: "stdin is", stdin: false, stdout: true },
141+
{ label: "stdout is", stdin: true, stdout: false },
142+
])("skips the onboarding service prompt when $label not a terminal", (isTTY) =>
133143
Effect.gen(function* () {
134-
yield* withoutTerminal;
144+
yield* withTerminal(isTTY);
135145
const { service, installOptions } = makeTestService({
136146
...status,
137147
installed: false,

0 commit comments

Comments
 (0)