Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

fix: failing dictionary test

Chadpihaca87f5382337
diff --git a/test/helpers/cliBridgeDictionary.test.js b/test/helpers/cliBridgeDictionary.test.js
index 63677b739..34fce1c86 100644
--- a/test/helpers/cliBridgeDictionary.test.js
+++ b/test/helpers/cliBridgeDictionary.test.js
@@ -113,21 +113,24 @@ test("POST /v1/dictionary/update removes only the named words", (t) => {
assert.deepEqual(ctx.db.getDictionary(), ["OpenWhispr", "Bob"]);
});
-test("POST /v1/dictionary/update broadcasts the new list to renderers", (t) => {
+test("POST /v1/dictionary/update broadcasts the new list to renderers", async (t) => {
+ // The route defers its broadcast with setImmediate, and the synchronous tests
+ // above never yield to the event loop, so their broadcasts are still queued
+ // here. Let them land before createBridge resets the recorder, or they are
+ // counted against this test.
+ await new Promise((resolve) => setImmediate(resolve));
+
const ctx = createBridge(t);
if (!ctx) return;
ctx.db.setDictionary(["OpenWhispr"]);
call(ctx.bridge, "POST", "/v1/dictionary/update", { add: ["Alice"] });
- return new Promise((resolve) => {
- setImmediate(() => {
- assert.equal(ctx.broadcasts.length, 1);
- assert.equal(ctx.broadcasts[0].channel, "dictionary-updated");
- assert.deepEqual(ctx.broadcasts[0].payload, ["OpenWhispr", "Alice"]);
- resolve();
- });
- });
+ await new Promise((resolve) => setImmediate(resolve));
+
+ assert.equal(ctx.broadcasts.length, 1);
+ assert.equal(ctx.broadcasts[0].channel, "dictionary-updated");
+ assert.deepEqual(ctx.broadcasts[0].payload, ["OpenWhispr", "Alice"]);
});
test("POST /v1/dictionary/update rejects a non-array field", (t) => {