| 1 | import fs from "node:fs"; |
| 2 | import path from "node:path"; |
| 3 | |
| 4 | import { describe, expect, test } from "vitest"; |
| 5 | import { testConfigHandler } from "../test/fixtures"; |
| 6 | import { TEST_DIR } from "../test/testDir"; |
| 7 | import { getConfigTsPath } from "../util/paths"; |
| 8 | |
| 9 | import { defaultConfig } from "./default"; |
| 10 | |
| 11 | describe.skip("Test the ConfigHandler and E2E config loading", () => { |
| 12 | test("should show only local profile", () => { |
| 13 | const profiles = testConfigHandler.currentOrg?.profiles; |
| 14 | expect(profiles?.length).toBe(1); |
| 15 | expect(profiles?.[0].profileDescription.id).toBe("local"); |
| 16 | |
| 17 | const currentProfile = testConfigHandler.currentProfile; |
| 18 | expect(currentProfile?.profileDescription.id).toBe("local"); |
| 19 | }); |
| 20 | |
| 21 | test("should load the default config successfully", async () => { |
| 22 | const result = await testConfigHandler.loadConfig(); |
| 23 | expect(result.config!.modelsByRole.chat.length).toBe( |
| 24 | defaultConfig.models?.length, |
| 25 | ); |
| 26 | }); |
| 27 | |
| 28 | test("should add a system message from config.ts", async () => { |
| 29 | const configTs = `export function modifyConfig(config: Config): Config { |
| 30 | config.systemMessage = "SYSTEM"; |
| 31 | return config; |
| 32 | }`; |
| 33 | fs.writeFileSync(getConfigTsPath(), configTs); |
| 34 | await new Promise((resolve) => setTimeout(resolve, 1000)); |
| 35 | const config = await testConfigHandler.reloadConfig("test"); |
| 36 | /** |
| 37 | * @ts-ignore is applied because this test is skipped |
| 38 | */ |
| 39 | // @ts-ignore |
| 40 | expect(config.systemMessage).toBe("SYSTEM"); |
| 41 | }); |
| 42 | |
| 43 | test("should acknowledge override from .continuerc.json", async () => { |
| 44 | fs.writeFileSync( |
| 45 | path.join(TEST_DIR, ".continuerc.json"), |
| 46 | JSON.stringify({ systemMessage: "SYSTEM2" }), |
| 47 | ); |
| 48 | const config = await testConfigHandler.reloadConfig("test"); |
| 49 | /** |
| 50 | * @ts-ignore is applied because this test is skipped |
| 51 | */ |
| 52 | // @ts-ignore |
| 53 | expect(config.systemMessage).toBe("SYSTEM2"); |
| 54 | }); |
| 55 | }); |