Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions packages/cli/src/ui/hooks/useStatusLine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { renderHook, act } from '@testing-library/react';
import * as child_process from 'child_process';
import { StreamingState } from '../types.js';
import type { StatusLinePresetReasoning } from '../statusLinePresets.js';
import { useStatusLine } from './useStatusLine.js';

const debugLogMock = vi.hoisted(() => ({
log: vi.fn(),
Expand Down Expand Up @@ -145,10 +146,7 @@ function setStatusLineConfig(
}

describe('useStatusLine', () => {
// Must import dynamically after mocks are set up
let useStatusLine: typeof import('./useStatusLine.js').useStatusLine;

beforeEach(async () => {
beforeEach(() => {
vi.useFakeTimers();
vi.clearAllMocks();
lastExecCommand = undefined;
Expand Down Expand Up @@ -199,10 +197,6 @@ describe('useStatusLine', () => {
mockConfig.getContentGeneratorConfig.mockReturnValue({
contextWindowSize: 131072,
});

// Dynamic import to get fresh module after mocks
const mod = await import('./useStatusLine.js');
useStatusLine = mod.useStatusLine;
});

afterEach(() => {
Expand Down
10 changes: 4 additions & 6 deletions packages/cli/src/ui/voice/voice-keyterms-race.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as fs from 'node:fs';
import * as os from 'node:os';
import * as path from 'node:path';
import type { LoadedSettings } from '../../config/settings.js';
import { buildVoiceKeyterms } from './voice-keyterms.js';

const raceState = vi.hoisted(() => ({
target: '',
Expand Down Expand Up @@ -84,7 +85,7 @@ describe('buildVoiceKeyterms race checks', () => {
workspaceDir = '';
});

it('does not read a keyterms file swapped in before open', async () => {
it('does not read a keyterms file swapped in before open', () => {
workspaceDir = fs.mkdtempSync(path.join(os.tmpdir(), 'voice-keyterms-'));
const qwenDir = path.join(workspaceDir, '.qwen');
fs.mkdirSync(qwenDir, { recursive: true });
Expand All @@ -95,15 +96,14 @@ describe('buildVoiceKeyterms race checks', () => {
raceState.replacementText = 'SwapSecret\n';
raceState.enabled = true;

const { buildVoiceKeyterms } = await import('./voice-keyterms.js');
const terms = buildVoiceKeyterms(makeSettings(workspaceDir));

expect(raceState.swapped).toBe(true);
expect(terms).not.toContain('SwapSecret');
expect(terms).toContain('TypeScript'); // globals only
});

it('does not read a keyterms file rewritten in place before open', async () => {
it('does not read a keyterms file rewritten in place before open', () => {
workspaceDir = fs.mkdtempSync(path.join(os.tmpdir(), 'voice-keyterms-'));
const qwenDir = path.join(workspaceDir, '.qwen');
fs.mkdirSync(qwenDir, { recursive: true });
Expand All @@ -116,15 +116,14 @@ describe('buildVoiceKeyterms race checks', () => {
raceState.enabled = true;
raceState.mode = 'overwrite';

const { buildVoiceKeyterms } = await import('./voice-keyterms.js');
const terms = buildVoiceKeyterms(makeSettings(workspaceDir));

expect(raceState.swapped).toBe(true);
expect(terms).not.toContain('EvilTerm');
expect(terms).toContain('TypeScript'); // globals only
});

it('does not read content larger than the file size cap after open', async () => {
it('does not read content larger than the file size cap after open', () => {
workspaceDir = fs.mkdtempSync(path.join(os.tmpdir(), 'voice-keyterms-'));
const qwenDir = path.join(workspaceDir, '.qwen');
fs.mkdirSync(qwenDir, { recursive: true });
Expand All @@ -133,7 +132,6 @@ describe('buildVoiceKeyterms race checks', () => {

raceState.oversizedReadText = `HugeTermMarker\n${'x'.repeat(64 * 1024)}`;

const { buildVoiceKeyterms } = await import('./voice-keyterms.js');
const terms = buildVoiceKeyterms(makeSettings(workspaceDir));

expect(terms).not.toContain('HugeTermMarker');
Expand Down
Loading