diff --git a/common/predictive-text/unit_tests/headless/worker-trie-integration.js b/common/predictive-text/unit_tests/headless/worker-trie-integration.js index 8cd257878d1..70583a978ee 100644 --- a/common/predictive-text/unit_tests/headless/worker-trie-integration.js +++ b/common/predictive-text/unit_tests/headless/worker-trie-integration.js @@ -15,7 +15,7 @@ describe('LMLayer using the trie model', function () { beforeEach(function() { worker = Worker.constructInstance(); - lmLayer = new LMLayer(capabilities(), worker); + lmLayer = new LMLayer(capabilities(), worker, true); }); afterEach(function () { @@ -82,7 +82,8 @@ describe('LMLayer using the trie model', function () { var suggestions = rawSuggestions.filter(function skimKeepSuggestions(s) { return s.tag !== 'keep' }) - assert.isAtLeast(suggestions.length, 1) + assert.isAtLeast(rawSuggestions.length, 1); + assert.isAtLeast(suggestions.length, 1); // We SHOULD get 'naïve' suggested var topSuggestion = suggestions[0]; diff --git a/common/web/lm-worker/src/test/mocha/cases/worker-model-compositor.js b/common/web/lm-worker/src/test/mocha/cases/worker-model-compositor.js index 86312aefe5e..15b9274970b 100644 --- a/common/web/lm-worker/src/test/mocha/cases/worker-model-compositor.js +++ b/common/web/lm-worker/src/test/mocha/cases/worker-model-compositor.js @@ -189,9 +189,19 @@ describe('ModelCompositor', function() { await Promise.all([firstPredict, secondPredict]); - const terminatedSuggestions = await firstPredict; + // We can't make many solid guarantees about the state at which the first predict() + // call was interrupted. + // + // Possible cases: + // - an early OS-level context switch can land between processing the root search node + // and the first possible search result (even for a single char) + // - It's possible to interrupt after the first result (exact match) and before any + // secondary corrections may be found + // - It's possible to interrupt "too late" if the correction search proceeds quickly, + // returning a standard full set. + await firstPredict; const finalSuggestions = await secondPredict; - assert.isOk(terminatedSuggestions.find((entry) => entry.displayAs == 'a')); + assert.isOk(finalSuggestions.find((entry) => entry.displayAs == 'applied')); }); });