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
|
|
@ -22,6 +22,10 @@ function cleanup(fn) {
|
|||
|
||||
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
|
||||
// What crypto.randomUUID() returns. Alexa wants a new messageId in every response and event and recommends a
|
||||
// version 4 UUID (Message guide, "Header object").
|
||||
const UUID_V4 = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
||||
|
||||
/** Poll fn every 15 ms until it returns something truthy. Throws "timeout waiting for <what>" after ms. */
|
||||
async function until(fn, ms = 3000, what = "condition") {
|
||||
const start = Date.now();
|
||||
|
|
@ -102,4 +106,4 @@ async function setup(Alex2MQTT, root, options = {}) {
|
|||
return { url, alexa, bridge };
|
||||
}
|
||||
|
||||
module.exports = { broker, watcher, directive, connected, setup, until, sleep, cleanup };
|
||||
module.exports = { broker, watcher, directive, connected, setup, until, sleep, cleanup, UUID_V4 };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue