|
1 | 1 | // Prompt template tests cover markdown discovery and fallback metadata. |
2 | | -import { mkdtemp, mkdir, rm, writeFile } from "node:fs/promises"; |
3 | | -import { tmpdir } from "node:os"; |
| 2 | +import { mkdir, writeFile } from "node:fs/promises"; |
4 | 3 | import { join } from "node:path"; |
5 | 4 | import { afterEach, describe, expect, it } from "vitest"; |
| 5 | +import { useAutoCleanupTempDirTracker } from "../../../test/helpers/temp-dir.js"; |
6 | 6 | import { loadPromptTemplates } from "./prompt-templates.js"; |
7 | 7 |
|
8 | | -const tempDirs: string[] = []; |
9 | | - |
10 | | -afterEach(async () => { |
11 | | - await Promise.all(tempDirs.splice(0).map((dir) => rm(dir, { recursive: true, force: true }))); |
12 | | -}); |
| 8 | +const tempDirs = useAutoCleanupTempDirTracker(afterEach); |
13 | 9 |
|
14 | 10 | describe("loadPromptTemplates", () => { |
15 | 11 | it("keeps fallback descriptions on a UTF-16 boundary", async () => { |
16 | | - const root = await mkdtemp(join(tmpdir(), "openclaw-prompt-templates-")); |
17 | | - tempDirs.push(root); |
| 12 | + const root = tempDirs.make("openclaw-prompt-templates-"); |
18 | 13 | const promptsDir = join(root, "prompts"); |
19 | 14 | await mkdir(promptsDir, { recursive: true }); |
20 | 15 | await writeFile(join(promptsDir, "emoji.md"), `${"a".repeat(59)}🚀tail\n`, "utf-8"); |
|
0 commit comments