mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-17 23:47:33 +00:00
* test(studio): the edit accuracy bench uses the port its server bound A busy port made the CLI bind the next free one, and the bench then failed the case with "studio moved from port N to N+1" instead of using it. * test(studio): drop a comment the doc line already says * test(studio): the bench server test removes its temp dir * test(studio): the bench stops its Studio server on Windows too Windows has no process groups, so the group kill never reached the server and the stop waited forever (the new server test timed out on windows-latest). taskkill /T, the CLI helper for the same job, ends the tree there. * test(studio): a failed taskkill surfaces, and the server opens no console on Windows
29 lines
1.1 KiB
JavaScript
29 lines
1.1 KiB
JavaScript
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import { describe, expect, it } from "vitest";
|
|
import { startServer, stopServer } from "./case.mjs";
|
|
|
|
// Stands in for the CLI when the asked-for port is busy: it binds another port and announces that one.
|
|
const FAKE_CLI = `
|
|
const server = require("node:http").createServer((req, res) => res.end("[]"));
|
|
server.listen(0, "127.0.0.1", () => console.log("Studio: http://localhost:" + server.address().port));
|
|
`;
|
|
|
|
describe("starting the bench's Studio server", () => {
|
|
it("serves on the port the server bound, not the one asked for", async () => {
|
|
const root = mkdtempSync(join(tmpdir(), "hf-bench-server-"));
|
|
const cli = join(root, "cli.cjs");
|
|
writeFileSync(cli, FAKE_CLI);
|
|
const asked = 1;
|
|
const { child, port } = await startServer(cli, root, asked, [], root);
|
|
try {
|
|
expect(port).not.toBe(asked);
|
|
expect((await fetch(`http://127.0.0.1:${port}/api/projects`)).ok).toBe(true);
|
|
} finally {
|
|
await stopServer(child);
|
|
rmSync(root, { recursive: true, force: true });
|
|
}
|
|
});
|
|
});
|