fix(cliproxy): correct relative import paths in colocated tests

This commit is contained in:
Tam Nhu Tran committed 2026-04-29 17:10:05 -04:00
1 parent 1c72b4b8d5
commit 273214d166
10 files changed
+26 -26

No files matched your search

@@ -31,9 +31,9 @@ describe('version-checker stale cache fallback', () => {
const { const {
getVersionCachePath, getVersionCachePath,
writeInstalledVersion, writeInstalledVersion,
} = await import('../../../src/cliproxy/binary/version-cache'); } = await import('../version-cache');
const { VERSION_CACHE_DURATION_MS } = await import('../../../src/cliproxy/binary/types'); const { VERSION_CACHE_DURATION_MS } = await import('../types');
const { checkForUpdates } = await import('../../../src/cliproxy/binary/version-checker'); const { checkForUpdates } = await import('../version-checker');
const plusBinDir = path.join(tempHome, '.ccs', 'cliproxy', 'bin', 'plus'); const plusBinDir = path.join(tempHome, '.ccs', 'cliproxy', 'bin', 'plus');
fs.mkdirSync(plusBinDir, { recursive: true }); fs.mkdirSync(plusBinDir, { recursive: true });
@@ -60,9 +60,9 @@ describe('version-checker stale cache fallback', () => {
}); });
it('uses a stale release-list cache when GitHub list lookup fails', async () => { it('uses a stale release-list cache when GitHub list lookup fails', async () => {
const { getVersionListCachePath } = await import('../../../src/cliproxy/binary/version-cache'); const { getVersionListCachePath } = await import('../version-cache');
const { VERSION_CACHE_DURATION_MS } = await import('../../../src/cliproxy/binary/types'); const { VERSION_CACHE_DURATION_MS } = await import('../types');
const { fetchAllVersions } = await import('../../../src/cliproxy/binary/version-checker'); const { fetchAllVersions } = await import('../version-checker');
const plusBinDir = path.join(tempHome, '.ccs', 'cliproxy', 'bin', 'plus'); const plusBinDir = path.join(tempHome, '.ccs', 'cliproxy', 'bin', 'plus');
fs.mkdirSync(plusBinDir, { recursive: true }); fs.mkdirSync(plusBinDir, { recursive: true });
@@ -90,8 +90,8 @@ describe('version-checker stale cache fallback', () => {
}); });
it('skips update lookups when runtime startup prefers the installed binary', async () => { it('skips update lookups when runtime startup prefers the installed binary', async () => {
const { getExecutableName } = await import('../../../src/cliproxy/platform-detector'); const { getExecutableName } = await import('../platform-detector');
const { ensureBinary } = await import('../../../src/cliproxy/binary/lifecycle'); const { ensureBinary } = await import('../lifecycle');
const plusBinDir = path.join(tempHome, '.ccs', 'cliproxy', 'bin', 'plus'); const plusBinDir = path.join(tempHome, '.ccs', 'cliproxy', 'bin', 'plus');
fs.mkdirSync(plusBinDir, { recursive: true }); fs.mkdirSync(plusBinDir, { recursive: true });
@@ -11,7 +11,7 @@ import {
detectTierFromModel, detectTierFromModel,
getThinkingValueForTier, getThinkingValueForTier,
} from '../../config/thinking-config'; } from '../../config/thinking-config';
import { CLIProxyProvider } from '../types'; import { CLIProxyProvider } from '../../types';
// ======================================== // ========================================
// applyThinkingSuffix // applyThinkingSuffix
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'bun:test'; import { describe, expect, it } from 'bun:test';
import { shouldStartHttpsTunnel } from '../executor/https-tunnel-policy'; import { shouldStartHttpsTunnel } from '../../executor/https-tunnel-policy';
describe('HTTPS tunnel startup policy', () => { describe('HTTPS tunnel startup policy', () => {
it('skips the tunnel for single-provider Codex remote HTTPS launches', () => { it('skips the tunnel for single-provider Codex remote HTTPS launches', () => {
@@ -7,7 +7,7 @@
import { describe, it, expect } from 'bun:test'; import { describe, it, expect } from 'bun:test';
import { detectRunningProxy } from '../proxy-detector'; import { detectRunningProxy } from '../proxy-detector';
import { CLIPROXY_DEFAULT_PORT } from '../config/config-generator'; import { CLIPROXY_DEFAULT_PORT } from '../../config/config-generator';
describe('Proxy Detector Port Validation', () => { describe('Proxy Detector Port Validation', () => {
describe('detectRunningProxy with invalid ports', () => { describe('detectRunningProxy with invalid ports', () => {
@@ -14,7 +14,7 @@ import {
fetchClaudeQuota, fetchClaudeQuota,
fetchAllClaudeQuotas, fetchAllClaudeQuotas,
} from '../quota-fetcher-claude'; } from '../quota-fetcher-claude';
import { sanitizeEmail } from '../auth/auth-utils'; import { sanitizeEmail } from '../../auth/auth-utils';
let tmpDir: string; let tmpDir: string;
let originalCcsHome: string | undefined; let originalCcsHome: string | undefined;
@@ -17,7 +17,7 @@ let buildCodexQuotaWindows: typeof import('../quota-fetcher-codex').buildCodexQu
let buildCodexCoreUsageSummary: typeof import('../quota-fetcher-codex').buildCodexCoreUsageSummary; let buildCodexCoreUsageSummary: typeof import('../quota-fetcher-codex').buildCodexCoreUsageSummary;
let fetchCodexQuota: typeof import('../quota-fetcher-codex').fetchCodexQuota; let fetchCodexQuota: typeof import('../quota-fetcher-codex').fetchCodexQuota;
let getUnknownCodexWindowLabels: typeof import('../quota-fetcher-codex').getUnknownCodexWindowLabels; let getUnknownCodexWindowLabels: typeof import('../quota-fetcher-codex').getUnknownCodexWindowLabels;
let registerAccount: typeof import('../accounts/account-manager').registerAccount; let registerAccount: typeof import('../../accounts/account-manager').registerAccount;
function createCodexAccount( function createCodexAccount(
accountId: string, accountId: string,
@@ -34,13 +34,13 @@ beforeEach(async () => {
mock.restore(); mock.restore();
const configGenerator = await import( const configGenerator = await import(
`../config/config-generator?codex-config-generator=${moduleVersion}` `../../config/config-generator?codex-config-generator=${moduleVersion}`
); );
const accountManager = await import( const accountManager = await import(
`../accounts/account-manager?codex-account-manager=${moduleVersion}` `../../accounts/account-manager?codex-account-manager=${moduleVersion}`
); );
mock.module('../config/config-generator', () => configGenerator); mock.module('../../config/config-generator', () => configGenerator);
mock.module('../accounts/account-manager', () => accountManager); mock.module('../../accounts/account-manager', () => accountManager);
({ registerAccount } = accountManager); ({ registerAccount } = accountManager);
({ ({
@@ -23,7 +23,7 @@ describe('Gemini CLI Quota Fetcher', () => {
let fetchGeminiCliQuota: typeof import('../quota-fetcher-gemini-cli').fetchGeminiCliQuota; let fetchGeminiCliQuota: typeof import('../quota-fetcher-gemini-cli').fetchGeminiCliQuota;
let resolveGeminiCliProjectId: typeof import('../quota-fetcher-gemini-cli').resolveGeminiCliProjectId; let resolveGeminiCliProjectId: typeof import('../quota-fetcher-gemini-cli').resolveGeminiCliProjectId;
let geminiTestExports: typeof import('../quota-fetcher-gemini-cli').__testExports; let geminiTestExports: typeof import('../quota-fetcher-gemini-cli').__testExports;
let getProviderAuthDir: typeof import('../config/config-generator').getProviderAuthDir; let getProviderAuthDir: typeof import('../../config/config-generator').getProviderAuthDir;
function writeGeminiToken(token: Record<string, unknown>, filename = 'gemini-test.json'): string { function writeGeminiToken(token: Record<string, unknown>, filename = 'gemini-test.json'): string {
const authDir = getProviderAuthDir('gemini'); const authDir = getProviderAuthDir('gemini');
@@ -59,7 +59,7 @@ describe('Gemini CLI Quota Fetcher', () => {
delete process.env.CCS_DIR; delete process.env.CCS_DIR;
const configGenerator = await import( const configGenerator = await import(
`../config/config-generator?gemini-config-generator=${moduleVersion}` `../../config/config-generator?gemini-config-generator=${moduleVersion}`
); );
({ ({
buildGeminiCliBuckets, buildGeminiCliBuckets,
@@ -16,7 +16,7 @@ import {
stopQuotaMonitor, stopQuotaMonitor,
clearQuotaCache, clearQuotaCache,
} from '../quota-manager'; } from '../quota-manager';
import { __testExports as executorTestExports } from '../executor'; import { __testExports as executorTestExports } from '../../executor';
// Setup test isolation // Setup test isolation
let tmpDir: string; let tmpDir: string;
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'bun:test'; import { describe, expect, it } from 'bun:test';
import type { ProxyTarget } from '../proxy/proxy-target-resolver'; import type { ProxyTarget } from '../../proxy/proxy-target-resolver';
async function loadRoutingHttpModule() { async function loadRoutingHttpModule() {
return import( return import(
@@ -32,7 +32,7 @@ describe('cliproxy routing strategy service', () => {
process.env.CCS_DIR = scopedConfigDir; process.env.CCS_DIR = scopedConfigDir;
process.env.CCS_HOME = tempHome; process.env.CCS_HOME = tempHome;
({ runWithScopedConfigDir } = await import('../../../src/utils/config-manager')); ({ runWithScopedConfigDir } = await import('../../../utils/config-manager'));
}); });
afterEach(() => { afterEach(() => {
@@ -91,7 +91,7 @@ describe('cliproxy routing strategy service', () => {
it('falls back to the saved local default when live CLIProxy is unavailable', async () => { it('falls back to the saved local default when live CLIProxy is unavailable', async () => {
await withScopedConfig(async () => { await withScopedConfig(async () => {
const { mutateUnifiedConfig } = await import('../../../src/config/unified-config-loader'); const { mutateUnifiedConfig } = await import('../../../config/unified-config-loader');
mutateUnifiedConfig((config) => { mutateUnifiedConfig((config) => {
if (config.cliproxy) { if (config.cliproxy) {
config.cliproxy.routing = { strategy: 'fill-first' }; config.cliproxy.routing = { strategy: 'fill-first' };
@@ -116,7 +116,7 @@ describe('cliproxy routing strategy service', () => {
expect(result.applied).toBe('config-only'); expect(result.applied).toBe('config-only');
expect(result.strategy).toBe('fill-first'); expect(result.strategy).toBe('fill-first');
const { loadUnifiedConfig } = await import('../../../src/config/unified-config-loader'); const { loadUnifiedConfig } = await import('../../../config/unified-config-loader');
const persisted = loadUnifiedConfig(); const persisted = loadUnifiedConfig();
expect(persisted?.cliproxy?.routing?.strategy).toBe('fill-first'); expect(persisted?.cliproxy?.routing?.strategy).toBe('fill-first');
}); });
@@ -171,7 +171,7 @@ describe('cliproxy routing strategy service', () => {
it('reads saved local session-affinity settings when live CLIProxy is unavailable', async () => { it('reads saved local session-affinity settings when live CLIProxy is unavailable', async () => {
await withScopedConfig(async () => { await withScopedConfig(async () => {
const { mutateUnifiedConfig } = await import('../../../src/config/unified-config-loader'); const { mutateUnifiedConfig } = await import('../../../config/unified-config-loader');
mutateUnifiedConfig((config) => { mutateUnifiedConfig((config) => {
if (config.cliproxy) { if (config.cliproxy) {
config.cliproxy.routing = { config.cliproxy.routing = {
@@ -206,7 +206,7 @@ describe('cliproxy routing strategy service', () => {
expect(result.enabled).toBe(true); expect(result.enabled).toBe(true);
expect(result.ttl).toBe('2h'); expect(result.ttl).toBe('2h');
const { loadUnifiedConfig } = await import('../../../src/config/unified-config-loader'); const { loadUnifiedConfig } = await import('../../../config/unified-config-loader');
const persisted = loadUnifiedConfig(); const persisted = loadUnifiedConfig();
expect(persisted?.cliproxy?.routing?.session_affinity).toBe(true); expect(persisted?.cliproxy?.routing?.session_affinity).toBe(true);
expect(persisted?.cliproxy?.routing?.session_affinity_ttl).toBe('2h'); expect(persisted?.cliproxy?.routing?.session_affinity_ttl).toBe('2h');