Skip to content

Commit

Permalink
fix(web): remedy unit-test stability issues
Browse files Browse the repository at this point in the history
Fixes: #11844
  • Loading branch information
jahorton committed Jul 8, 2024
1 parent 2f3a0cb commit 8eba5d0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
});
});
Expand Down

0 comments on commit 8eba5d0

Please sign in to comment.