Files
paseo/packages/server/scripts/transcribe-local-wav.test.ts
T
4117dce2d3 Fix local WAV transcription startup (#7103)
* fix(speech): complete local transcription providers

* test(speech): document lazy worker assumption

Co-authored-by: LauraGPT <18321252+LauraGPT@users.noreply.github.com>

---------

Co-authored-by: LauraGPT <lauragpt@users.noreply.github.com>
Co-authored-by: LauraGPT <18321252+LauraGPT@users.noreply.github.com>
2026-10-16 08:19:21 +02:00

41 lines
1.4 KiB
TypeScript

import { spawnSync } from "node:child_process";
import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { afterEach, describe, expect, test } from "vitest";
const tempDirs: string[] = [];
afterEach(() => {
for (const dir of tempDirs.splice(0)) {
rmSync(dir, { recursive: true, force: true });
}
});
describe("transcribe-local-wav CLI", () => {
test("initializes the complete speech provider configuration", () => {
const modelsDir = mkdtempSync(path.join(tmpdir(), "paseo-transcribe-local-"));
tempDirs.push(modelsDir);
const missingWav = path.join(modelsDir, "missing.wav");
const scriptPath = fileURLToPath(new URL("./transcribe-local-wav.ts", import.meta.url));
const result = spawnSync(
process.execPath,
["--import", "tsx", scriptPath, missingWav, "--models-dir", modelsDir],
{
encoding: "utf8",
timeout: 15_000,
},
);
expect(result.error).toBeUndefined();
expect(result.status).not.toBe(0);
// The worker client is lazy, so reaching the missing WAV proves provider initialization completed first.
expect(result.stderr).toContain("ENOENT");
expect(result.stderr).toContain(missingWav);
expect(result.stderr).not.toContain("Cannot read properties of undefined");
});
});