mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-13 15:47:28 +00:00
test: verify install and runtime messages
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Command } from "commander";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { theme } from "../terminal/theme.js";
|
||||
import { registerPairingCli } from "./pairing-cli.js";
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
@@ -229,8 +230,12 @@ describe("pairing cli", () => {
|
||||
| { nextConfig?: { commands?: { ownerAllowFrom?: string[] } } }
|
||||
| undefined;
|
||||
expect(replaceCall?.nextConfig?.commands?.ownerAllowFrom).toEqual(["telegram:123"]);
|
||||
expect(log).toHaveBeenCalledWith(expect.stringContaining("Approved"));
|
||||
expect(log).toHaveBeenCalledWith(expect.stringContaining("Command owner configured"));
|
||||
expect(log.mock.calls).toEqual([
|
||||
[`${theme.success("Approved")} ${theme.muted("telegram")} sender ${theme.command("123")}.`],
|
||||
[
|
||||
`${theme.success("Command owner configured")} ${theme.command("telegram:123")} ${theme.muted("(commands.ownerAllowFrom was empty).")}`,
|
||||
],
|
||||
]);
|
||||
} finally {
|
||||
log.mockRestore();
|
||||
}
|
||||
|
||||
@@ -503,8 +503,8 @@ describe("scripts/docker/setup.sh", () => {
|
||||
const forceRecreateLine = log
|
||||
.split("\n")
|
||||
.find((line) => line.includes("up -d --force-recreate openclaw-gateway"));
|
||||
expect(forceRecreateLine).toEqual(
|
||||
expect.stringContaining("up -d --force-recreate openclaw-gateway"),
|
||||
expect(forceRecreateLine).toBe(
|
||||
`compose compose -f ${join(activeSandbox.rootDir, "docker-compose.yml")} up -d --force-recreate openclaw-gateway`,
|
||||
);
|
||||
expect(forceRecreateLine).not.toContain("docker-compose.sandbox.yml");
|
||||
await expectMissingPath(join(activeSandbox.rootDir, "docker-compose.sandbox.yml"));
|
||||
|
||||
@@ -184,9 +184,13 @@ describe("wide-area DNS zone writes", () => {
|
||||
zonePath: getWideAreaZonePath("openclaw.internal."),
|
||||
changed: true,
|
||||
});
|
||||
const expectedZoneText = renderWideAreaGatewayZoneText({
|
||||
...makeZoneOpts({ gatewayTlsEnabled: true, gatewayTlsFingerprintSha256: "abc123" }),
|
||||
serial: 2026031305,
|
||||
});
|
||||
expect(writeSpy).toHaveBeenCalledWith(
|
||||
getWideAreaZonePath("openclaw.internal."),
|
||||
expect.stringContaining("@ IN SOA ns1 hostmaster 2026031305 7200 3600 1209600 60"),
|
||||
expectedZoneText,
|
||||
"utf-8",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { resolvePreferredOpenClawTmpDir } from "../infra/tmp-openclaw-dir.js";
|
||||
import { withTempDir } from "../test-helpers/temp-dir.js";
|
||||
import { MediaAttachmentCache } from "./attachments.js";
|
||||
|
||||
@@ -60,7 +61,9 @@ describe("media understanding attachment URL fallback", () => {
|
||||
});
|
||||
// getPath should fall through to getBuffer URL fetch, write a temp file,
|
||||
// and return a path to that temp file instead of throwing.
|
||||
expect(result.path).toEqual(expect.stringMatching(/\S/u));
|
||||
expect(path.dirname(result.path)).toBe(resolvePreferredOpenClawTmpDir());
|
||||
expect(path.basename(result.path).startsWith("openclaw-media-")).toBe(true);
|
||||
expect(path.extname(result.path)).toBe(".jpg");
|
||||
expect(fetchRemoteMediaMock).toHaveBeenCalledTimes(1);
|
||||
const fetchInput = fetchRemoteMediaMock.mock.calls[0]?.[0] as
|
||||
| { url?: unknown; fetchImpl?: unknown; maxBytes?: unknown; ssrfPolicy?: unknown }
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { VERSION } from "../version.js";
|
||||
import {
|
||||
createRequestCaptureJsonFetch,
|
||||
installPinnedHostnameTestHooks,
|
||||
@@ -24,8 +25,8 @@ describe("transcribeOpenAiCompatibleAudio", () => {
|
||||
|
||||
const headers = new Headers(getRequest().init?.headers);
|
||||
expect(headers.get("originator")).toBe("openclaw");
|
||||
expect(headers.get("version")).toEqual(expect.stringMatching(/\S/u));
|
||||
expect(headers.get("user-agent")).toMatch(/^openclaw\//);
|
||||
expect(headers.get("version")).toBe(VERSION);
|
||||
expect(headers.get("user-agent")).toBe(`openclaw/${VERSION}`);
|
||||
});
|
||||
|
||||
it("does not add hidden attribution headers on custom OpenAI-compatible hosts", async () => {
|
||||
|
||||
@@ -258,9 +258,7 @@ describe("model override pipeline wiring", () => {
|
||||
|
||||
await expect(resultPromise).resolves.toEqual({ prependContext: "fast" });
|
||||
expect(logger.error).toHaveBeenCalledWith(
|
||||
expect.stringContaining(
|
||||
"[hooks] before_prompt_build handler from slow-plugin failed: timed out after 5ms",
|
||||
),
|
||||
);
|
||||
} finally {
|
||||
vi.useRealTimers();
|
||||
|
||||
@@ -378,7 +378,11 @@ describe("ensureApiKeyFromEnvOrPrompt", () => {
|
||||
expect(result).toBe("env-key");
|
||||
expectMinimaxEnvRefCredentialStored(setCredential);
|
||||
expect(note).toHaveBeenCalledWith(
|
||||
expect.stringContaining("Could not validate provider reference"),
|
||||
[
|
||||
"Could not validate provider reference filemain:/providers/minimax/apiKey.",
|
||||
"secrets.providers.filemain.path is not readable: /tmp/does-not-exist-secrets.json | ENOENT: no such file or directory, lstat '/tmp/does-not-exist-secrets.json' | secrets.providers.filemain.path is not readable: /tmp/does-not-exist-secrets.json | ENOENT: no such file or directory, lstat '/tmp/does-not-exist-secrets.json'",
|
||||
"Check your provider configuration and try again.",
|
||||
].join("\n"),
|
||||
"Reference check failed",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -350,9 +350,10 @@ describe("collectInstalledRootDependencyManifestErrors", () => {
|
||||
mkdirSync(join(packageRoot, "dist"), { recursive: true });
|
||||
writeFileSync(join(packageRoot, "package.json"), "{not-json\n", "utf8");
|
||||
|
||||
expect(collectInstalledRootDependencyManifestErrors(packageRoot)).toEqual([
|
||||
expect.stringMatching(/^installed package\.json could not be parsed:/u),
|
||||
]);
|
||||
const errors = collectInstalledRootDependencyManifestErrors(packageRoot);
|
||||
expect(errors).toHaveLength(1);
|
||||
expect(errors[0]?.startsWith("installed package.json could not be parsed:")).toBe(true);
|
||||
expect(errors[0]?.endsWith(".")).toBe(true);
|
||||
} finally {
|
||||
rmSync(packageRoot, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user