test: read an ErrorResponse off the broker; every answer has its own messageId
Step 2 replaced uuid by crypto.randomUUID() at three call sites (AlexaStatusMessage, AlexaErrorResponse, Device.sendSceneResponse) and only the first was asserted, in the ES module test. With the messageId dropped or set to a constant in the other two, the suite still passed 22/22, and no test read an ErrorResponse at all. New: an ErrorResponse compared whole against the documented shape (header, endpoint, payload, no context), and one test that sends two directives each to a light, an unreachable light and a scene and requires six different version 4 UUIDs. The Response, StateReport, scene and change report tests check the messageId too; the pattern lives in the harness. Checked in a scratch copy: a missing or constant messageId at each of the three sites now fails the suite (the missing one in AlexaStatusMessage does not compile). No change to src/ or dist/. npm test: 24 pass in 5.5 s. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
1d88c7811a
commit
f74773132a
4 changed files with 78 additions and 12 deletions
|
|
@ -5,7 +5,7 @@ import assert from "node:assert/strict";
|
|||
import { Alex2MQTT, AlexaInterfaceType, DisplayCategory, EndpointHealth, PowerController } from "alex2node";
|
||||
import harness from "./helpers/harness.js";
|
||||
|
||||
const { setup, directive, until } = harness;
|
||||
const { setup, directive, until, UUID_V4 } = harness;
|
||||
|
||||
test("import { Alex2MQTT } from \"alex2node\": discovery, a directive and a change report on the ES module build", async () => {
|
||||
const { alexa, bridge } = await setup(Alex2MQTT, "root");
|
||||
|
|
@ -30,8 +30,7 @@ test("import { Alex2MQTT } from \"alex2node\": discovery, a directive and a chan
|
|||
const [response] = alexa.on("root/lamp-1/alexaResponce");
|
||||
assert.equal(response.event.header.name, "Response");
|
||||
assert.equal(response.event.header.correlationToken, "ct1");
|
||||
// crypto.randomUUID() writes the messageId: a version 4 UUID, as uuid's v4() did
|
||||
assert.match(response.event.header.messageId, /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/);
|
||||
assert.match(response.event.header.messageId, UUID_V4);
|
||||
|
||||
assert.equal(await lamp.getChangeReport().addPowerControllerProp(PowerController.OFF).send(), "root/changeReport");
|
||||
await until(() => alexa.on("root/changeReport").length === 1, 3000, "change report");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue