mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 05:17:26 +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 os from "node:os";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { SILENT_REPLY_TOKEN, type PluginRuntime } from "openclaw/plugin-sdk";
|
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 () => {
|
it("preserves parsed mentions when appending OneDrive fallback file links", async () => {
|
||||||
const tmpDir = await mkdtemp(path.join(os.tmpdir(), "msteams-mention-"));
|
const previousStateDir = process.env.OPENCLAW_STATE_DIR;
|
||||||
const localFile = path.join(tmpDir, "note.txt");
|
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");
|
await writeFile(localFile, "hello");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -232,7 +236,12 @@ describe("msteams messenger", () => {
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
} finally {
|
} 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> = {
|
export const DEFAULT_EMOJIS: Required<StatusReactionEmojis> = {
|
||||||
queued: "👀",
|
queued: "👀",
|
||||||
thinking: "🤔",
|
thinking: "🧠",
|
||||||
tool: "🔥",
|
tool: "🛠️",
|
||||||
coding: "👨💻",
|
coding: "💻",
|
||||||
web: "⚡",
|
web: "🌐",
|
||||||
done: "👍",
|
done: "✅",
|
||||||
error: "😱",
|
error: "❌",
|
||||||
stallSoft: "🥱",
|
stallSoft: "⏳",
|
||||||
stallHard: "😨",
|
stallHard: "⚠️",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const DEFAULT_TIMING: Required<StatusReactionTiming> = {
|
export const DEFAULT_TIMING: Required<StatusReactionTiming> = {
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ async function withAudioFixture(
|
|||||||
await fs.writeFile(tmpPath, Buffer.from("RIFF"));
|
await fs.writeFile(tmpPath, Buffer.from("RIFF"));
|
||||||
const ctx: MsgContext = { MediaPath: tmpPath, MediaType: "audio/wav" };
|
const ctx: MsgContext = { MediaPath: tmpPath, MediaType: "audio/wav" };
|
||||||
const media = normalizeMediaAttachments(ctx);
|
const media = normalizeMediaAttachments(ctx);
|
||||||
const cache = createMediaAttachmentCache(media);
|
const cache = createMediaAttachmentCache(media, {
|
||||||
|
localPathRoots: [os.tmpdir()],
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await run({ ctx, media, cache });
|
await run({ ctx, media, cache });
|
||||||
|
|||||||
@@ -17,7 +17,9 @@ describe("runCapability deepgram provider options", () => {
|
|||||||
await fs.writeFile(tmpPath, Buffer.from("RIFF"));
|
await fs.writeFile(tmpPath, Buffer.from("RIFF"));
|
||||||
const ctx: MsgContext = { MediaPath: tmpPath, MediaType: "audio/wav" };
|
const ctx: MsgContext = { MediaPath: tmpPath, MediaType: "audio/wav" };
|
||||||
const media = normalizeMediaAttachments(ctx);
|
const media = normalizeMediaAttachments(ctx);
|
||||||
const cache = createMediaAttachmentCache(media);
|
const cache = createMediaAttachmentCache(media, {
|
||||||
|
localPathRoots: [os.tmpdir()],
|
||||||
|
});
|
||||||
|
|
||||||
let seenQuery: Record<string, string | number | boolean> | undefined;
|
let seenQuery: Record<string, string | number | boolean> | undefined;
|
||||||
let seenBaseUrl: string | 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 { resolveStateDir } from "../config/paths.js";
|
||||||
import { sendVoiceMessageDiscord } from "../discord/send.js";
|
import { sendVoiceMessageDiscord } from "../discord/send.js";
|
||||||
import * as ssrf from "../infra/net/ssrf.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 { optimizeImageToPng } from "../media/image-ops.js";
|
||||||
import { captureEnv } from "../test-utils/env.js";
|
import { captureEnv } from "../test-utils/env.js";
|
||||||
import {
|
import {
|
||||||
@@ -50,7 +51,9 @@ async function createLargeTestJpeg(): Promise<{ buffer: Buffer; file: string }>
|
|||||||
}
|
}
|
||||||
|
|
||||||
beforeAll(async () => {
|
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({
|
largeJpegBuffer = await sharp({
|
||||||
create: {
|
create: {
|
||||||
width: 400,
|
width: 400,
|
||||||
@@ -334,7 +337,9 @@ describe("local media root guard", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("allows local paths under an explicit root", async () => {
|
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");
|
expect(result.kind).toBe("image");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user