Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web): remedy unit-test stability issues #11933

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading