mirror of
https://github.com/moltbot/moltbot.git
synced 2026-03-09 15:35:17 +00:00
Fix path-root flaky tests and restore status emoji defaults (#22274)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
||||
import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { SILENT_REPLY_TOKEN, type PluginRuntime } from "openclaw/plugin-sdk";
|
||||
@@ -178,8 +178,12 @@ describe("msteams messenger", () => {
|
||||
});
|
||||
|
||||
it("preserves parsed mentions when appending OneDrive fallback file links", async () => {
|
||||
const tmpDir = await mkdtemp(path.join(os.tmpdir(), "msteams-mention-"));
|
||||
const localFile = path.join(tmpDir, "note.txt");
|
||||
const previousStateDir = process.env.OPENCLAW_STATE_DIR;
|
||||
const tmpStateDir = await mkdtemp(path.join(os.tmpdir(), "msteams-mention-state-"));
|
||||
process.env.OPENCLAW_STATE_DIR = tmpStateDir;
|
||||
const workspaceDir = path.join(tmpStateDir, "workspace");
|
||||
await mkdir(workspaceDir, { recursive: true });
|
||||
const localFile = path.join(workspaceDir, "note.txt");
|
||||
await writeFile(localFile, "hello");
|
||||
|
||||
try {
|
||||
@@ -232,7 +236,12 @@ describe("msteams messenger", () => {
|
||||
},
|
||||
]);
|
||||
} finally {
|
||||
await rm(tmpDir, { recursive: true, force: true });
|
||||
if (previousStateDir === undefined) {
|
||||
delete process.env.OPENCLAW_STATE_DIR;
|
||||
} else {
|
||||
process.env.OPENCLAW_STATE_DIR = previousStateDir;
|
||||
}
|
||||
await rm(tmpStateDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -50,14 +50,14 @@ export type StatusReactionController = {
|
||||
|
||||
export const DEFAULT_EMOJIS: Required<StatusReactionEmojis> = {
|
||||
queued: "👀",
|
||||
thinking: "🤔",
|
||||
tool: "🔥",
|
||||
coding: "👨💻",
|
||||
web: "⚡",
|
||||
done: "👍",
|
||||
error: "😱",
|
||||
stallSoft: "🥱",
|
||||
stallHard: "😨",
|
||||
thinking: "🧠",
|
||||
tool: "🛠️",
|
||||
coding: "💻",
|
||||
web: "🌐",
|
||||
done: "✅",
|
||||
error: "❌",
|
||||
stallSoft: "⏳",
|
||||
stallHard: "⚠️",
|
||||
};
|
||||
|
||||
export const DEFAULT_TIMING: Required<StatusReactionTiming> = {
|
||||
|
||||
@@ -24,7 +24,9 @@ async function withAudioFixture(
|
||||
await fs.writeFile(tmpPath, Buffer.from("RIFF"));
|
||||
const ctx: MsgContext = { MediaPath: tmpPath, MediaType: "audio/wav" };
|
||||
const media = normalizeMediaAttachments(ctx);
|
||||
const cache = createMediaAttachmentCache(media);
|
||||
const cache = createMediaAttachmentCache(media, {
|
||||
localPathRoots: [os.tmpdir()],
|
||||
});
|
||||
|
||||
try {
|
||||
await run({ ctx, media, cache });
|
||||
|
||||
@@ -17,7 +17,9 @@ describe("runCapability deepgram provider options", () => {
|
||||
await fs.writeFile(tmpPath, Buffer.from("RIFF"));
|
||||
const ctx: MsgContext = { MediaPath: tmpPath, MediaType: "audio/wav" };
|
||||
const media = normalizeMediaAttachments(ctx);
|
||||
const cache = createMediaAttachmentCache(media);
|
||||
const cache = createMediaAttachmentCache(media, {
|
||||
localPathRoots: [os.tmpdir()],
|
||||
});
|
||||
|
||||
let seenQuery: Record<string, string | number | boolean> | undefined;
|
||||
let seenBaseUrl: string | undefined;
|
||||
|
||||
@@ -6,6 +6,7 @@ import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from "vitest
|
||||
import { resolveStateDir } from "../config/paths.js";
|
||||
import { sendVoiceMessageDiscord } from "../discord/send.js";
|
||||
import * as ssrf from "../infra/net/ssrf.js";
|
||||
import { resolvePreferredOpenClawTmpDir } from "../infra/tmp-openclaw-dir.js";
|
||||
import { optimizeImageToPng } from "../media/image-ops.js";
|
||||
import { captureEnv } from "../test-utils/env.js";
|
||||
import {
|
||||
@@ -50,7 +51,9 @@ async function createLargeTestJpeg(): Promise<{ buffer: Buffer; file: string }>
|
||||
}
|
||||
|
||||
beforeAll(async () => {
|
||||
fixtureRoot = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-media-test-"));
|
||||
fixtureRoot = await fs.mkdtemp(
|
||||
path.join(resolvePreferredOpenClawTmpDir(), "openclaw-media-test-"),
|
||||
);
|
||||
largeJpegBuffer = await sharp({
|
||||
create: {
|
||||
width: 400,
|
||||
@@ -334,7 +337,9 @@ describe("local media root guard", () => {
|
||||
});
|
||||
|
||||
it("allows local paths under an explicit root", async () => {
|
||||
const result = await loadWebMedia(tinyPngFile, 1024 * 1024, { localRoots: [os.tmpdir()] });
|
||||
const result = await loadWebMedia(tinyPngFile, 1024 * 1024, {
|
||||
localRoots: [resolvePreferredOpenClawTmpDir()],
|
||||
});
|
||||
expect(result.kind).toBe("image");
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user