Files
hyperframes/packages/cli/src/utils/checkBrowser.networkChanged.test.ts
T
Miguel Ángel 44ee07a2da fix(cli): check drops a request a network change cut when the file loads again (#6823)
* 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
2026-10-30 11:32:18 +00:00

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`,
]);
});
});