



























@@ -19,8 +19,8 @@ import {
1919import { installOpenAiResponsesMock } from "./test-helpers.openai-mock.js";
2020import { buildMockOpenAiResponsesProvider } from "./test-openai-responses-model.js";
212122-let writeConfigFile: typeof import("../config/config.js").writeConfigFile;
2322let resolveConfigPath: typeof import("../config/config.js").resolveConfigPath;
23+let createConfigIO: typeof import("../config/config.js").createConfigIO;
2424const GATEWAY_E2E_TIMEOUT_MS = 90_000;
2525let gatewayTestSeq = 0;
2626const GATEWAY_TEST_ENV_KEYS = [
@@ -137,7 +137,7 @@ describe("gateway e2e", () => {
137137});
138138139139beforeAll(async () => {
140-({ writeConfigFile, resolveConfigPath } = await import("../config/config.js"));
140+({ createConfigIO, resolveConfigPath } = await import("../config/config.js"));
141141});
142142143143it(
@@ -342,11 +342,14 @@ module.exports = {
342342delete process.env.OPENCLAW_GATEWAY_TOKEN;
343343344344const tempHome = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-wizard-home-"));
345+const configPath = path.join(tempHome, ".openclaw", "openclaw.json");
345346process.env.HOME = tempHome;
347+process.env.OPENCLAW_STATE_DIR = path.join(tempHome, ".openclaw");
348+process.env.OPENCLAW_CONFIG_PATH = configPath;
346349process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = await createEmptyBundledPluginsDir(tempHome);
347350process.env.OPENCLAW_DISABLE_BUNDLED_PLUGINS = "1";
348-delete process.env.OPENCLAW_STATE_DIR;
349-delete process.env.OPENCLAW_CONFIG_PATH;
351+clearRuntimeConfigSnapshot();
352+clearConfigCache();
350353351354const wizardToken = nextGatewayId("wiz-token");
352355const port = await getFreeGatewayPort();
@@ -358,7 +361,7 @@ module.exports = {
358361await prompter.intro("Wizard E2E");
359362await prompter.note("write token");
360363const token = await prompter.text({ message: "token" });
361-await writeConfigFile({
364+await createConfigIO({ configPath }).writeConfigFile({
362365gateway: { auth: { mode: "token", token } },
363366});
364367await prompter.outro("ok");
@@ -413,11 +416,18 @@ module.exports = {
413416);
414417expect(next.status).toBe("done");
415418416-const parsed = JSON.parse(await fs.readFile(resolveConfigPath(), "utf8"));
417-const token = (parsed as Record<string, unknown>)?.gateway as
418-| Record<string, unknown>
419-| undefined;
420-expect((token?.auth as { token?: string } | undefined)?.token).toBe(wizardToken);
419+await expect
420+.poll(
421+async () => {
422+const parsed = JSON.parse(await fs.readFile(configPath, "utf8"));
423+const token = (parsed as Record<string, unknown>)?.gateway as
424+| Record<string, unknown>
425+| undefined;
426+return (token?.auth as { token?: string } | undefined)?.token;
427+},
428+{ timeout: 5_000 },
429+)
430+.toBe(wizardToken);
421431} finally {
422432await disconnectGatewayClient(client);
423433await server.close({ reason: "wizard e2e complete" });
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。