From f4159d2a2d95cab594b0260c13fa1e55d042652c Mon Sep 17 00:00:00 2001 From: Nate Date: Mon, 11 Nov 2024 20:18:57 -0800 Subject: [PATCH] save to cache immediately so as not to fail tests --- core/autocomplete/CompletionProvider.ts | 11 ++--- .../filtering/test/filter.test.ts | 40 +++++++++---------- 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/core/autocomplete/CompletionProvider.ts b/core/autocomplete/CompletionProvider.ts index 24815f501..9667352fd 100644 --- a/core/autocomplete/CompletionProvider.ts +++ b/core/autocomplete/CompletionProvider.ts @@ -261,13 +261,10 @@ export class CompletionProvider { ////////// - // Do some stuff later so as not to block return. Latency matters - const completionToCache = outcome.completion; - setTimeout(async () => { - if (!outcome.cacheHit) { - (await this.autocompleteCache).put(outcome.prefix, completionToCache); - } - }, 100); + // Save to cache + if (!outcome.cacheHit) { + (await this.autocompleteCache).put(outcome.prefix, outcome.completion); + } // When using the JetBrains extension, Mark as displayed const ideType = (await this.ide.getIdeInfo()).ideType; diff --git a/core/autocomplete/filtering/test/filter.test.ts b/core/autocomplete/filtering/test/filter.test.ts index b2e025a4b..e6c07b951 100644 --- a/core/autocomplete/filtering/test/filter.test.ts +++ b/core/autocomplete/filtering/test/filter.test.ts @@ -14,7 +14,7 @@ const filterTestCases = (tests: AutocompleteFileringTestInput[]) => { return tests; }; -describe("llms/Mock", () => { +describe("Autocomplete filtering tests", () => { beforeAll(async () => { tearDownTestDir(); setUpTestDir(); @@ -24,27 +24,25 @@ describe("llms/Mock", () => { tearDownTestDir(); }); - describe("Autocomplete Filtering Tests", () => { - beforeEach(async () => { - await new Promise((resolve) => setTimeout(resolve, 50)); - }); + beforeEach(async () => { + await new Promise((resolve) => setTimeout(resolve, 50)); + }); - describe("Should return unmodified LLM output", () => { - it.each(filterTestCases(TEST_CASES_WITHOUT_DIFF))( - "$description", - async (testCase) => { - await testAutocompleteFiltering(testCase); - }, - ); - }); + describe("Should return unmodified LLM output", () => { + it.each(filterTestCases(TEST_CASES_WITHOUT_DIFF))( + "$description", + async (testCase) => { + await testAutocompleteFiltering(testCase); + }, + ); + }); - describe("Should return modified LLM output", () => { - it.each(filterTestCases(TEST_CASES_WITH_DIFF))( - "$description", - async (testCase) => { - await testAutocompleteFiltering(testCase); - }, - ); - }); + describe("Should return modified LLM output", () => { + it.each(filterTestCases(TEST_CASES_WITH_DIFF))( + "$description", + async (testCase) => { + await testAutocompleteFiltering(testCase); + }, + ); }); });