mirror of
https://github.com/farcasclaudiu/openclaw.git
synced 2026-06-28 21:01:43 +03:00
perf(test): remove extra module resets in cli and message suites
This commit is contained in:
@@ -91,7 +91,6 @@ describe("browser extension install", () => {
|
|||||||
const dir = path.join(tmp, "browser", "chrome-extension");
|
const dir = path.join(tmp, "browser", "chrome-extension");
|
||||||
writeManifest(dir);
|
writeManifest(dir);
|
||||||
|
|
||||||
vi.resetModules();
|
|
||||||
const { Command } = await import("commander");
|
const { Command } = await import("commander");
|
||||||
const { registerBrowserExtensionCommands } = await import("./browser-cli-extension.js");
|
const { registerBrowserExtensionCommands } = await import("./browser-cli-extension.js");
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import fs from "node:fs";
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { fileURLToPath } from "node:url";
|
import { fileURLToPath } from "node:url";
|
||||||
import { movePathToTrash } from "../browser/trash.js";
|
import { movePathToTrash } from "../browser/trash.js";
|
||||||
import { STATE_DIR } from "../config/paths.js";
|
import { resolveStateDir } from "../config/paths.js";
|
||||||
import { danger, info } from "../globals.js";
|
import { danger, info } from "../globals.js";
|
||||||
import { copyToClipboard } from "../infra/clipboard.js";
|
import { copyToClipboard } from "../infra/clipboard.js";
|
||||||
import { defaultRuntime } from "../runtime.js";
|
import { defaultRuntime } from "../runtime.js";
|
||||||
@@ -32,7 +32,7 @@ export function resolveBundledExtensionRootDir(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function installedExtensionRootDir() {
|
function installedExtensionRootDir() {
|
||||||
return path.join(STATE_DIR, "browser", "chrome-extension");
|
return path.join(resolveStateDir(), "browser", "chrome-extension");
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasManifest(dir: string) {
|
function hasManifest(dir: string) {
|
||||||
@@ -48,7 +48,7 @@ export async function installChromeExtension(opts?: {
|
|||||||
throw new Error("Bundled Chrome extension is missing. Reinstall OpenClaw and try again.");
|
throw new Error("Bundled Chrome extension is missing. Reinstall OpenClaw and try again.");
|
||||||
}
|
}
|
||||||
|
|
||||||
const stateDir = opts?.stateDir ?? STATE_DIR;
|
const stateDir = opts?.stateDir ?? resolveStateDir();
|
||||||
const dest = path.join(stateDir, "browser", "chrome-extension");
|
const dest = path.join(stateDir, "browser", "chrome-extension");
|
||||||
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ async function writeConfigFile(home: string, config: Record<string, unknown>): P
|
|||||||
describe("config cli", () => {
|
describe("config cli", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
vi.resetModules();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ beforeEach(async () => {
|
|||||||
process.env.TELEGRAM_BOT_TOKEN = "";
|
process.env.TELEGRAM_BOT_TOKEN = "";
|
||||||
process.env.DISCORD_BOT_TOKEN = "";
|
process.env.DISCORD_BOT_TOKEN = "";
|
||||||
testConfig = {};
|
testConfig = {};
|
||||||
vi.resetModules();
|
|
||||||
await setRegistry(createTestRegistry([]));
|
await setRegistry(createTestRegistry([]));
|
||||||
callGatewayMock.mockReset();
|
callGatewayMock.mockReset();
|
||||||
webAuthExists.mockReset().mockResolvedValue(false);
|
webAuthExists.mockReset().mockResolvedValue(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user