From 72afe8fe0488c1cd2b11a2c20cfe77ed69eca26b Mon Sep 17 00:00:00 2001 From: diegosouzapw Date: Sun, 26 Apr 2026 03:35:54 -0300 Subject: [PATCH] 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 --- tests/integration/_chatPipelineHarness.ts | 3 +++ tests/integration/proxy-registry-flow.test.ts | 3 +++ tests/unit/guide-settings-route.test.ts | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/tests/integration/_chatPipelineHarness.ts b/tests/integration/_chatPipelineHarness.ts index 57b2d745ed..da8ca1d13b 100644 --- a/tests/integration/_chatPipelineHarness.ts +++ b/tests/integration/_chatPipelineHarness.ts @@ -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(); diff --git a/tests/integration/proxy-registry-flow.test.ts b/tests/integration/proxy-registry-flow.test.ts index 1a6c71ba35..4ee9aa511c 100644 --- a/tests/integration/proxy-registry-flow.test.ts +++ b/tests/integration/proxy-registry-flow.test.ts @@ -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"); diff --git a/tests/unit/guide-settings-route.test.ts b/tests/unit/guide-settings-route.test.ts index a77fdd1be4..4e082b617b 100644 --- a/tests/unit/guide-settings-route.test.ts +++ b/tests/unit/guide-settings-route.test.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 () => {