mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 16:08:56 +00:00
* fix(cli): check drops a request a network change cut when the file loads again * style(cli): format the network-change check fix * fix(cli): drop the comment the ratchet would count * fix(cli): a check out of time drops the requests a network change cut
37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
import { createServer } from "node:http";
|
|
import type { AddressInfo } from "node:net";
|
|
import { describe, expect, it } from "vitest";
|
|
import { networkChangesStillFailing } from "./checkBrowser.js";
|
|
|
|
describe("networkChangesStillFailing", () => {
|
|
it("names the cut requests whose file is still unreachable, not the ones that load again", async () => {
|
|
const server = createServer((req, res) => {
|
|
res.statusCode = req.url === "/gone.mp4" ? 404 : 206;
|
|
res.end("x");
|
|
});
|
|
await new Promise<void>((resolve) => server.listen(0, "127.0.0.1", resolve));
|
|
const base = `http://127.0.0.1:${(server.address() as AddressInfo).port}`;
|
|
const draft = (url: string) => ({
|
|
code: "request_failed",
|
|
severity: "error" as const,
|
|
message: url,
|
|
time: 31,
|
|
url,
|
|
networkChanged: true,
|
|
});
|
|
try {
|
|
const failing = await networkChangesStillFailing([
|
|
draft(`${base}/clip.mp4`),
|
|
draft(`${base}/gone.mp4`),
|
|
{ ...draft(`${base}/other.mp4`), networkChanged: false },
|
|
]);
|
|
expect([...failing]).toEqual([`${base}/gone.mp4`]);
|
|
} finally {
|
|
server.close();
|
|
}
|
|
expect([...(await networkChangesStillFailing([draft(`${base}/clip.mp4`)]))]).toEqual([
|
|
`${base}/clip.mp4`,
|
|
]);
|
|
});
|
|
});
|