Pin the discovery frame against a real capture

The gateway and backend halves of `discovered_printers` are hand-synced, so
every hand-written example in this file agrees with whichever side wrote it -
which is exactly how the two ends of /ws/edge/v1 drifted into different
protocols before. A capture is the only thing that catches that.

This one came off a live LAN with a Bambu P1P and H2C on it, through the
gateway's own serde enum, with its fleet file pointed at an empty file so
nothing was filtered out. The addresses and the shape are as captured.

The two serials are placeholders of the captured shape. They identify
someone's physical hardware, no test depends on their value, and no other
fixture here carries one - so the real ones are not something to commit on
the owner's behalf.
This commit is contained in:
2026-10-19 08:20:58 +00:00
parent cd7aed0028
commit 818f28ea5d
2 changed files with 43 additions and 0 deletions
+18
View File
@@ -10,6 +10,7 @@ import "../src/validation/formats";
import currentCapture from "./fixtures/gateway_frames.json";
import legacyCapture from "./fixtures/gateway_frames_legacy_nulls.json";
import discoveryCapture from "./fixtures/gateway_discovery_frame.json";
/**
* A contract test, not a unit test: it checks that what continuum-proxy
@@ -152,6 +153,23 @@ describe("gateway -> backend frames", () => {
driver_ready: true,
};
it("accepts the real scan captured from a live LAN", () => {
// The one case a hand-written example cannot cover. Everything below
// agrees with how this test file imagines the gateway behaves; this
// agrees with what the gateway actually emitted, through its own serde
// enum, about two real printers. The two halves of this message are
// hand-synced, so a capture is the only thing that catches a drift.
for (const frame of discoveryCapture.frames) {
check(EdgeClientMessageSchema, frame);
}
// Guards against a fixture that validates because it is empty.
const printers = discoveryCapture.frames[0].printers;
expect(printers.length).toBeGreaterThan(0);
// And against one that validates because every field is absent: the
// address is the entire reason this message exists.
expect(printers.every((p) => p.address.length > 0 && p.vendor.length > 0)).toBe(true);
});
it("accepts a scan result", () => {
check(EdgeClientMessageSchema, {
type: "discovered_printers",