|
1 | | -import { mkdtemp, readFile, rm, stat } from "node:fs/promises"; |
2 | | -import os from "node:os"; |
| 1 | +import { readFile, stat } from "node:fs/promises"; |
3 | 2 | import path from "node:path"; |
4 | 3 | import { describe, expect, it } from "vitest"; |
5 | 4 | import { |
|
9 | 8 | syncNativeLocale, |
10 | 9 | type NativeI18nEntry, |
11 | 10 | } from "../../scripts/native-app-i18n.ts"; |
| 11 | +import { cleanupTempDirs, makeTempDir } from "../helpers/temp-dir.js"; |
12 | 12 |
|
13 | 13 | describe("native app i18n inventory", () => { |
14 | 14 | it("collects stable Android and Apple UI entries", async () => { |
@@ -123,7 +123,8 @@ describe("native app i18n inventory", () => { |
123 | 123 | }); |
124 | 124 |
|
125 | 125 | it("creates a first-run locale artifact and leaves a complete artifact unchanged", async () => { |
126 | | - const translationsDir = await mkdtemp(path.join(os.tmpdir(), "openclaw-native-i18n-")); |
| 126 | + const tempDirs: string[] = []; |
| 127 | + const translationsDir = makeTempDir(tempDirs, "openclaw-native-i18n-"); |
127 | 128 | const entries: NativeI18nEntry[] = [ |
128 | 129 | { |
129 | 130 | id: "native.android.hello", |
@@ -193,12 +194,13 @@ describe("native app i18n inventory", () => { |
193 | 194 | expect(await readFile(artifactPath, "utf8")).toBe(firstContents); |
194 | 195 | expect((await stat(artifactPath)).mtimeMs).toBe(firstModifiedAt); |
195 | 196 | } finally { |
196 | | - await rm(translationsDir, { force: true, recursive: true }); |
| 197 | + cleanupTempDirs(tempDirs); |
197 | 198 | } |
198 | 199 | }); |
199 | 200 |
|
200 | 201 | it("rejects native printf placeholder drift", async () => { |
201 | | - const translationsDir = await mkdtemp(path.join(os.tmpdir(), "openclaw-native-i18n-")); |
| 202 | + const tempDirs: string[] = []; |
| 203 | + const translationsDir = makeTempDir(tempDirs, "openclaw-native-i18n-"); |
202 | 204 | const cases = [ |
203 | 205 | { |
204 | 206 | entry: { |
@@ -237,7 +239,7 @@ describe("native app i18n inventory", () => { |
237 | 239 | ); |
238 | 240 | } |
239 | 241 | } finally { |
240 | | - await rm(translationsDir, { force: true, recursive: true }); |
| 242 | + cleanupTempDirs(tempDirs); |
241 | 243 | } |
242 | 244 | }); |
243 | 245 |
|
|
0 commit comments