test(player): pin the stop URL's ids, the beacon's settle, the kept point's edges

The stop-URL contract passed with the two ids swapped and read the backend
from the working directory; nothing called a real beacon's onSettled or its
library pass-through; the kept-point rule was held by its constants only.
This commit is contained in:
2026-10-08 01:16:30 +02:00
parent 4e70f168b1
commit 5095047c81
4 changed files with 61 additions and 8 deletions
+28
View File
@@ -454,3 +454,31 @@ describe("uploadDownload's wire shape", () => {
expect(FakeXHR.last.headers["X-Upload-Display-Name"]).toBeUndefined();
});
});
// The library player re-reads its listings once its closing point is on the server: it cancelled
// their poll so an older answer could not put the point back, and only this callback brings them
// back. A beacon that never called it, or a slice that dropped it, left the lists stale with every
// test green.
describe("a beacon's settle callback", () => {
it("runs once the request is answered, and once it has failed", async () => {
const fetch = vi
.spyOn(globalThis, "fetch")
.mockResolvedValueOnce(new Response(null, { status: 204 }))
.mockRejectedValueOnce(new TypeError("offline"));
const answered = vi.fn();
const failed = vi.fn();
beacon("/api/a", {}, answered);
beacon("/api/b", {}, failed);
await vi.waitFor(() =>
expect([answered.mock.calls.length, failed.mock.calls.length]).toEqual([1, 1]),
);
expect(fetch.mock.calls.map(([url]) => url).slice(-2)).toEqual(["/api/a", "/api/b"]);
});
it("is passed on by the library progress beacon", async () => {
vi.spyOn(globalThis, "fetch").mockResolvedValue(new Response(null, { status: 204 }));
const settled = vi.fn();
downloadsApi.saveDownloadProgressBeacon(7, 125.4, 600, settled);
await vi.waitFor(() => expect(settled).toHaveBeenCalledTimes(1));
});
});