Skip to content

Commit 4ba4c27

Browse files
committed
fix: add resetStatusBar() and fix test config pollution
src/client/http.ts: - Export resetStatusBar() to reset the module-level statusBarPrinted flag between test runs. Without this, a test that prints the status bar pollutes the state for subsequent tests in the same process. test/: - test/client/http.test.ts: import resetStatusBar(), call it in afterEach, set quiet:true/noColor:true on all configs (was quiet:false/noColor:false). - test/commands/text/chat.test.ts: same resetStatusBar() + afterEach + fix dry-run test config from quiet:false → quiet:true. - test/commands/video/task-get.test.ts: same resetStatusBar() + afterEach. config kept at quiet:false — the command itself has a stdout/json bug when quiet:true that belongs to a separate fix.
1 parent 59b5fa9 commit 4ba4c27

4 files changed

Lines changed: 18 additions & 5 deletions

File tree

src/client/http.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ export interface RequestOpts {
1919
// Printed once per process invocation to avoid repeating on every request.
2020
let statusBarPrinted = false;
2121

22+
/**
23+
* Reset the status bar flag — for use in test afterEach hooks to prevent
24+
* state pollution between test files.
25+
*/
26+
export function resetStatusBar(): void {
27+
statusBarPrinted = false;
28+
}
29+
2230
export async function request(
2331
config: Config,
2432
opts: RequestOpts,

test/client/http.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, it, expect, afterEach } from 'bun:test';
2-
import { requestJson } from '../../src/client/http';
2+
import { requestJson, resetStatusBar } from '../../src/client/http';
33
import { createMockServer, jsonResponse, type MockServer } from '../helpers/mock-server';
44
import type { Config } from '../../src/config/schema';
55

@@ -11,8 +11,8 @@ function makeConfig(baseUrl: string): Config {
1111
output: 'text',
1212
timeout: 10,
1313
verbose: false,
14-
quiet: false,
15-
noColor: false,
14+
quiet: true,
15+
noColor: true,
1616
yes: false,
1717
dryRun: false,
1818
nonInteractive: false,
@@ -25,6 +25,7 @@ describe('HTTP client', () => {
2525

2626
afterEach(() => {
2727
server?.close();
28+
resetStatusBar();
2829
});
2930

3031
it('makes authenticated GET request', async () => {

test/commands/text/chat.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { describe, it, expect, afterEach } from 'bun:test';
2+
import { resetStatusBar } from '../../../src/client/http';
23
import { createMockServer, jsonResponse, sseResponse, type MockServer } from '../../helpers/mock-server';
34
import textChatResponse from '../../fixtures/text-chat-response.json';
45
import type { Config } from '../../../src/config/schema';
@@ -8,6 +9,7 @@ describe('text chat command', () => {
89

910
afterEach(() => {
1011
server?.close();
12+
resetStatusBar();
1113
});
1214

1315
it('sends chat request and gets response', async () => {
@@ -70,7 +72,7 @@ describe('text chat command', () => {
7072
output: 'json',
7173
timeout: 10,
7274
verbose: false,
73-
quiet: false,
75+
quiet: true,
7476
noColor: true,
7577
yes: false,
7678
dryRun: true,
@@ -85,7 +87,7 @@ describe('text chat command', () => {
8587
try {
8688
await chatCommand.execute(config, {
8789
message: ['Hello'],
88-
quiet: false,
90+
quiet: true,
8991
verbose: false,
9092
noColor: true,
9193
yes: false,

test/commands/video/task-get.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { describe, it, expect, afterEach } from 'bun:test';
2+
import { resetStatusBar } from '../../../src/client/http';
23
import { default as taskGetCommand } from '../../../src/commands/video/task-get';
34
import { createMockServer, jsonResponse, type MockServer } from '../../helpers/mock-server';
45
import videoTaskSuccess from '../../fixtures/video-task-success.json';
@@ -8,6 +9,7 @@ describe('video task get command', () => {
89

910
afterEach(() => {
1011
server?.close();
12+
resetStatusBar();
1113
});
1214

1315
it('has correct name', () => {

0 commit comments

Comments
 (0)