mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-23 16:01:17 +00:00
test: repair current main gate regressions
This commit is contained in:
@@ -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 }) => {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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 }),
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -34,7 +34,6 @@ function createEmptyPluginRegistry(): PluginRegistry {
|
||||
diagnostics: [],
|
||||
};
|
||||
}
|
||||
|
||||
const sessionBindingState = vi.hoisted(() => {
|
||||
const records = new Map<string, SessionBindingRecord>();
|
||||
let nextId = 1;
|
||||
|
||||
@@ -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",
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user