mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-01 12:52:11 +03:00
fix: resolve CI-only test failures from environment differences
- guide-settings-route.test.ts: control XDG_CONFIG_HOME so OpenCode config path resolves to the test dummy dir (CI runners have XDG set) - proxy-registry-flow.test.ts: disable DASHBOARD_PASSWORD to prevent 401 on direct route handler calls (CI postinstall auto-generates it) - _chatPipelineHarness.ts: clear DASHBOARD_PASSWORD for all integration tests using the shared chat pipeline harness
This commit is contained in:
@@ -6,6 +6,9 @@ export async function createChatPipelineHarness(prefix) {
|
||||
const testDataDir = fs.mkdtempSync(path.join(os.tmpdir(), `omniroute-${prefix}-`));
|
||||
process.env.DATA_DIR = testDataDir;
|
||||
process.env.REQUIRE_API_KEY = "false";
|
||||
// Disable dashboard auth so direct route handler calls don't get 401
|
||||
// (CI postinstall auto-generates DASHBOARD_PASSWORD)
|
||||
process.env.DASHBOARD_PASSWORD = "";
|
||||
// FASE-01: API_KEY_SECRET is required for CRC operations (no hardcoded fallback)
|
||||
if (!process.env.API_KEY_SECRET) {
|
||||
process.env.API_KEY_SECRET = "test-harness-secret-" + Date.now();
|
||||
|
||||
@@ -6,6 +6,9 @@ import path from "node:path";
|
||||
|
||||
const TEST_DATA_DIR = fs.mkdtempSync(path.join(os.tmpdir(), "omniroute-proxy-registry-flow-"));
|
||||
process.env.DATA_DIR = TEST_DATA_DIR;
|
||||
// Disable dashboard auth for direct route handler calls in CI
|
||||
// (postinstall auto-generates DASHBOARD_PASSWORD, causing 401 on management routes)
|
||||
process.env.DASHBOARD_PASSWORD = "";
|
||||
|
||||
const core = await import("../../src/lib/db/core.ts");
|
||||
const providersDb = await import("../../src/lib/db/providers.ts");
|
||||
|
||||
@@ -10,6 +10,7 @@ const DUMMY_HOME = path.join(os.tmpdir(), "omniroute-qwen-test-" + Date.now());
|
||||
const QWEN_CONFIG_PATH = path.join(DUMMY_HOME, ".qwen", "settings.json");
|
||||
const QWEN_ENV_PATH = path.join(DUMMY_HOME, ".qwen", ".env");
|
||||
const OPENCODE_CONFIG_PATH = path.join(DUMMY_HOME, ".config", "opencode", "opencode.json");
|
||||
const originalXDG = process.env.XDG_CONFIG_HOME;
|
||||
|
||||
type QwenProviderEntry = {
|
||||
id?: string;
|
||||
@@ -31,11 +32,16 @@ function buildRequest(body: any) {
|
||||
test.beforeEach(async () => {
|
||||
// Mock os.homedir to return our dummy path
|
||||
os.homedir = () => DUMMY_HOME;
|
||||
// Force XDG_CONFIG_HOME so resolveOpencodeConfigPath resolves to our dummy dir
|
||||
// (CI runners often have XDG_CONFIG_HOME set, causing path mismatch)
|
||||
process.env.XDG_CONFIG_HOME = path.join(DUMMY_HOME, ".config");
|
||||
await fs.mkdir(path.dirname(QWEN_CONFIG_PATH), { recursive: true }).catch(() => {});
|
||||
});
|
||||
|
||||
test.afterEach(async () => {
|
||||
await fs.rm(DUMMY_HOME, { recursive: true, force: true }).catch(() => {});
|
||||
if (originalXDG === undefined) delete process.env.XDG_CONFIG_HOME;
|
||||
else process.env.XDG_CONFIG_HOME = originalXDG;
|
||||
});
|
||||
|
||||
test("guide-settings POST creates new qwen settings.json if it doesn't exist", async () => {
|
||||
|
||||
Reference in New Issue
Block a user