mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 04:18:05 +00:00
fix(cliproxy): correct relative import paths in colocated tests
This commit is contained in:
@@ -31,9 +31,9 @@ describe('version-checker stale cache fallback', () => {
|
||||
const {
|
||||
getVersionCachePath,
|
||||
writeInstalledVersion,
|
||||
} = await import('../../../src/cliproxy/binary/version-cache');
|
||||
const { VERSION_CACHE_DURATION_MS } = await import('../../../src/cliproxy/binary/types');
|
||||
const { checkForUpdates } = await import('../../../src/cliproxy/binary/version-checker');
|
||||
} = await import('../version-cache');
|
||||
const { VERSION_CACHE_DURATION_MS } = await import('../types');
|
||||
const { checkForUpdates } = await import('../version-checker');
|
||||
const plusBinDir = path.join(tempHome, '.ccs', 'cliproxy', 'bin', 'plus');
|
||||
|
||||
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 () => {
|
||||
const { getVersionListCachePath } = await import('../../../src/cliproxy/binary/version-cache');
|
||||
const { VERSION_CACHE_DURATION_MS } = await import('../../../src/cliproxy/binary/types');
|
||||
const { fetchAllVersions } = await import('../../../src/cliproxy/binary/version-checker');
|
||||
const { getVersionListCachePath } = await import('../version-cache');
|
||||
const { VERSION_CACHE_DURATION_MS } = await import('../types');
|
||||
const { fetchAllVersions } = await import('../version-checker');
|
||||
const plusBinDir = path.join(tempHome, '.ccs', 'cliproxy', 'bin', 'plus');
|
||||
|
||||
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 () => {
|
||||
const { getExecutableName } = await import('../../../src/cliproxy/platform-detector');
|
||||
const { ensureBinary } = await import('../../../src/cliproxy/binary/lifecycle');
|
||||
const { getExecutableName } = await import('../platform-detector');
|
||||
const { ensureBinary } = await import('../lifecycle');
|
||||
|
||||
const plusBinDir = path.join(tempHome, '.ccs', 'cliproxy', 'bin', 'plus');
|
||||
fs.mkdirSync(plusBinDir, { recursive: true });
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
detectTierFromModel,
|
||||
getThinkingValueForTier,
|
||||
} from '../../config/thinking-config';
|
||||
import { CLIProxyProvider } from '../types';
|
||||
import { CLIProxyProvider } from '../../types';
|
||||
|
||||
// ========================================
|
||||
// applyThinkingSuffix
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
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', () => {
|
||||
it('skips the tunnel for single-provider Codex remote HTTPS launches', () => {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
import { describe, it, expect } from 'bun:test';
|
||||
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('detectRunningProxy with invalid ports', () => {
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
fetchClaudeQuota,
|
||||
fetchAllClaudeQuotas,
|
||||
} from '../quota-fetcher-claude';
|
||||
import { sanitizeEmail } from '../auth/auth-utils';
|
||||
import { sanitizeEmail } from '../../auth/auth-utils';
|
||||
|
||||
let tmpDir: string;
|
||||
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 fetchCodexQuota: typeof import('../quota-fetcher-codex').fetchCodexQuota;
|
||||
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(
|
||||
accountId: string,
|
||||
@@ -34,13 +34,13 @@ beforeEach(async () => {
|
||||
mock.restore();
|
||||
|
||||
const configGenerator = await import(
|
||||
`../config/config-generator?codex-config-generator=${moduleVersion}`
|
||||
`../../config/config-generator?codex-config-generator=${moduleVersion}`
|
||||
);
|
||||
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('../accounts/account-manager', () => accountManager);
|
||||
mock.module('../../config/config-generator', () => configGenerator);
|
||||
mock.module('../../accounts/account-manager', () => accountManager);
|
||||
({ registerAccount } = accountManager);
|
||||
|
||||
({
|
||||
|
||||
@@ -23,7 +23,7 @@ describe('Gemini CLI Quota Fetcher', () => {
|
||||
let fetchGeminiCliQuota: typeof import('../quota-fetcher-gemini-cli').fetchGeminiCliQuota;
|
||||
let resolveGeminiCliProjectId: typeof import('../quota-fetcher-gemini-cli').resolveGeminiCliProjectId;
|
||||
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 {
|
||||
const authDir = getProviderAuthDir('gemini');
|
||||
@@ -59,7 +59,7 @@ describe('Gemini CLI Quota Fetcher', () => {
|
||||
delete process.env.CCS_DIR;
|
||||
|
||||
const configGenerator = await import(
|
||||
`../config/config-generator?gemini-config-generator=${moduleVersion}`
|
||||
`../../config/config-generator?gemini-config-generator=${moduleVersion}`
|
||||
);
|
||||
({
|
||||
buildGeminiCliBuckets,
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
stopQuotaMonitor,
|
||||
clearQuotaCache,
|
||||
} from '../quota-manager';
|
||||
import { __testExports as executorTestExports } from '../executor';
|
||||
import { __testExports as executorTestExports } from '../../executor';
|
||||
|
||||
// Setup test isolation
|
||||
let tmpDir: string;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
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() {
|
||||
return import(
|
||||
|
||||
@@ -32,7 +32,7 @@ describe('cliproxy routing strategy service', () => {
|
||||
process.env.CCS_DIR = scopedConfigDir;
|
||||
process.env.CCS_HOME = tempHome;
|
||||
|
||||
({ runWithScopedConfigDir } = await import('../../../src/utils/config-manager'));
|
||||
({ runWithScopedConfigDir } = await import('../../../utils/config-manager'));
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -91,7 +91,7 @@ describe('cliproxy routing strategy service', () => {
|
||||
|
||||
it('falls back to the saved local default when live CLIProxy is unavailable', async () => {
|
||||
await withScopedConfig(async () => {
|
||||
const { mutateUnifiedConfig } = await import('../../../src/config/unified-config-loader');
|
||||
const { mutateUnifiedConfig } = await import('../../../config/unified-config-loader');
|
||||
mutateUnifiedConfig((config) => {
|
||||
if (config.cliproxy) {
|
||||
config.cliproxy.routing = { strategy: 'fill-first' };
|
||||
@@ -116,7 +116,7 @@ describe('cliproxy routing strategy service', () => {
|
||||
expect(result.applied).toBe('config-only');
|
||||
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();
|
||||
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 () => {
|
||||
await withScopedConfig(async () => {
|
||||
const { mutateUnifiedConfig } = await import('../../../src/config/unified-config-loader');
|
||||
const { mutateUnifiedConfig } = await import('../../../config/unified-config-loader');
|
||||
mutateUnifiedConfig((config) => {
|
||||
if (config.cliproxy) {
|
||||
config.cliproxy.routing = {
|
||||
@@ -206,7 +206,7 @@ describe('cliproxy routing strategy service', () => {
|
||||
expect(result.enabled).toBe(true);
|
||||
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();
|
||||
expect(persisted?.cliproxy?.routing?.session_affinity).toBe(true);
|
||||
expect(persisted?.cliproxy?.routing?.session_affinity_ttl).toBe('2h');
|
||||
|
||||
Reference in New Issue
Block a user