test: repair current main gate regressions

This commit is contained in:
Peter Steinberger
2026-03-22 22:19:57 +00:00
parent d6c63163b4
commit 47e8ffc2e9
6 changed files with 16 additions and 10 deletions

View File

@@ -38,8 +38,8 @@ vi.mock("openclaw/plugin-sdk/reply-runtime", async (importOriginal) => {
};
});
vi.mock("openclaw/plugin-sdk/channel-runtime", async (importOriginal) => {
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/channel-runtime")>();
vi.mock("openclaw/plugin-sdk/conversation-runtime", async (importOriginal) => {
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/conversation-runtime")>();
return {
...actual,
recordInboundSession: vi.fn(async (params: { ctx: MsgContext }) => {

View File

@@ -18,6 +18,14 @@ async function readCommandSource(relativePath: string): Promise<string> {
const absolutePath = path.join(process.cwd(), relativePath);
const source = await fs.readFile(absolutePath, "utf8");
const reexportMatch = source.match(/^export \* from "(?<target>[^"]+)";$/m)?.groups?.target;
const runtimeImportMatch = source.match(/import\("(?<target>\.[^"]+\.runtime\.js)"\)/m)?.groups
?.target;
if (runtimeImportMatch) {
const resolvedTarget = path.join(path.dirname(absolutePath), runtimeImportMatch);
const tsResolvedTarget = resolvedTarget.replace(/\.js$/u, ".ts");
const runtimeSource = await fs.readFile(tsResolvedTarget, "utf8");
return `${source}\n${runtimeSource}`;
}
if (!reexportMatch) {
return source;
}

View File

@@ -1,6 +1,6 @@
import { Command } from "commander";
import fs from "node:fs/promises";
import path from "node:path";
import { Command } from "commander";
import { beforeEach, describe, expect, it, vi } from "vitest";
import type { OpenClawConfig, ConfigFileSnapshot } from "../config/types.openclaw.js";
import type { UpdateRunResult } from "../infra/update-runner.js";

View File

@@ -4,6 +4,7 @@ import path from "node:path";
import { describe, expect, it } from "vitest";
import { withTempHome } from "../../../test/helpers/temp-home.js";
import type { OpenClawConfig } from "../config.js";
import { resolveStorePath } from "./paths.js";
import {
resolveAllAgentSessionStoreTargets,
resolveAllAgentSessionStoreTargetsSync,
@@ -91,15 +92,11 @@ describe("resolveSessionStoreTargets", () => {
expect(targets).toEqual([
{
agentId: "main",
storePath: path.resolve(
path.join(process.env.HOME ?? "", ".openclaw/agents/main/sessions/sessions.json"),
),
storePath: resolveStorePath(cfg.session?.store, { agentId: "main", env: process.env }),
},
{
agentId: "work",
storePath: path.resolve(
path.join(process.env.HOME ?? "", ".openclaw/agents/work/sessions/sessions.json"),
),
storePath: resolveStorePath(cfg.session?.store, { agentId: "work", env: process.env }),
},
]);
});

View File

@@ -34,7 +34,6 @@ function createEmptyPluginRegistry(): PluginRegistry {
diagnostics: [],
};
}
const sessionBindingState = vi.hoisted(() => {
const records = new Map<string, SessionBindingRecord>();
let nextId = 1;

View File

@@ -69,6 +69,7 @@ describe("formatPluginSourceForTable", () => {
{
OPENCLAW_BUNDLED_PLUGINS_DIR: path.join(ignoredHome, "ignored-bundled"),
OPENCLAW_STATE_DIR: path.join(ignoredHome, "ignored-state"),
OPENCLAW_HOME: undefined,
HOME: ignoredHome,
},
() =>
@@ -76,6 +77,7 @@ describe("formatPluginSourceForTable", () => {
env: {
...process.env,
HOME: homeDir,
OPENCLAW_HOME: undefined,
OPENCLAW_BUNDLED_PLUGINS_DIR: "~/bundled",
OPENCLAW_STATE_DIR: "~/state",
},