diff --git a/core/nextEdit/utils.ts b/core/nextEdit/utils.ts index 3e7ad0111..152e55933 100644 --- a/core/nextEdit/utils.ts +++ b/core/nextEdit/utils.ts @@ -1,9 +1,15 @@ -type NextEditModelName = "mercury-coder-nextedit" | "this field is not used"; +type NextEditModelName = "mercury-coder-nextedit"; export function isModelCapableOfNextEdit(modelName: string): boolean { - const supportedModels: NextEditModelName[] = [ - "mercury-coder-nextedit", - "this field is not used", - ]; + // In test mode, we can control whether next edit is enabled via environment variable. + if (process.env.NEXT_EDIT_TEST_ENABLED === "false") { + return false; + } + + if (process.env.NEXT_EDIT_TEST_ENABLED === "true") { + return true; + } + + const supportedModels: NextEditModelName[] = ["mercury-coder-nextedit"]; return supportedModels.some((supported) => modelName.includes(supported)); } diff --git a/extensions/vscode/e2e/tests/Autocomplete.test.ts b/extensions/vscode/e2e/tests/Autocomplete.test.ts index 7685d52ae..6f213d0cb 100644 --- a/extensions/vscode/e2e/tests/Autocomplete.test.ts +++ b/extensions/vscode/e2e/tests/Autocomplete.test.ts @@ -8,6 +8,10 @@ import { DEFAULT_TIMEOUT } from "../constants"; describe("Autocomplete", () => { let editor: TextEditor; + before(async function () { + process.env.NEXT_EDIT_TEST_ENABLED = "false"; + }) + beforeEach(async function () { this.timeout(DEFAULT_TIMEOUT.XL); diff --git a/extensions/vscode/e2e/tests/NextEdit.test.ts b/extensions/vscode/e2e/tests/NextEdit.test.ts index 7a834783f..6a44e0a70 100644 --- a/extensions/vscode/e2e/tests/NextEdit.test.ts +++ b/extensions/vscode/e2e/tests/NextEdit.test.ts @@ -8,60 +8,9 @@ import { DEFAULT_TIMEOUT } from "../constants"; describe("Next Edit", () => { let editor: TextEditor; - // before(async function () { - // // this.timeout(DEFAULT_TIMEOUT.XL); - - // // const globalContextPath = TestUtils.getGlobalContextFilePath(); - - // // // Update config.json to add optInNextEditFeature. - // // // globalContext.json does not exist in CI before this test runs. - // // if (await TestUtils.fileExists(globalContextPath)) { - // // const globalContext = await fs.readFile(globalContextPath, "utf8"); - // // const sharedConfig = JSON.parse(globalContext).sharedConfig; - - // // const sharedConfigWithNextEditEnabled = { - // // ...sharedConfig, - // // optInNextEditFeature: true, - // // }; - - // // const globalContextWithNextEditEnabled = { - // // ...JSON.parse(globalContext), - // // sharedConfig: sharedConfigWithNextEditEnabled, - // // }; - - // // await fs.writeFile( - // // globalContextPath, - // // JSON.stringify(globalContextWithNextEditEnabled, null, 2), - // // "utf8", - // // ); - // // } else { - // // await fs.writeFile( - // // globalContextPath, - // // JSON.stringify( - // // { - // // sharedConfig: { - // // optInNextEditFeature: true, - // // }, - // // selectedModelsByProfileId: { - // // local: { - // // chat: "TEST LLM", - // // edit: "TEST LLM", - // // apply: "TEST LLM", - // // embed: "Transformers.js (Built-In)", - // // autocomplete: "TEST LLM", - // // rerank: null, - // // summarize: null, - // // }, - // // }, - // // }, - // // null, - // // 2, - // // ), - // // ); - // // } - - // await NextEditActions.reload(); - // }).timeout(DEFAULT_TIMEOUT.XL); + before(async function () { + process.env.NEXT_EDIT_TEST_ENABLED = "true"; + }) beforeEach(async function () { this.timeout(DEFAULT_TIMEOUT.XL); @@ -77,39 +26,9 @@ describe("Next Edit", () => { await new EditorView().closeAllEditors(); }).timeout(DEFAULT_TIMEOUT.XL); - // after(async function () { - // // this.timeout(DEFAULT_TIMEOUT.XL); - - // // Update config.json to delete optInNextEditFeature. - // // const globalContext = await fs.readFile( - // // TestUtils.getGlobalContextFilePath(), - // // "utf8", - // // ); - // // const sharedConfig = JSON.parse(globalContext).sharedConfig; - - // // const sharedConfigWithoutNextEdit = { ...sharedConfig }; - // // delete sharedConfigWithoutNextEdit.optInNextEditFeature; - - // // const globalContextWithNextEditEnabled = { - // // ...JSON.parse(globalContext), - // // sharedConfig: sharedConfigWithoutNextEdit, - // // }; - - // // await fs.writeFile( - // // TestUtils.getGlobalContextFilePath(), - // // JSON.stringify(globalContextWithNextEditEnabled, null, 2), - // // "utf8", - // // ); - // await NextEditActions.reload(); - // }).timeout(DEFAULT_TIMEOUT.XL); - - // it("Should enable Next Edit feature in settings", async () => { - // expect(false).to.be.true; - // }).timeout(DEFAULT_TIMEOUT.XL); - - // it("Should check that autocomplete is disabled when next edit is enabled", async () => { - // expect(false).to.be.true; - // }).timeout(DEFAULT_TIMEOUT.XL); + after(async function () { + process.env.NEXT_EDIT_TEST_ENABLED = "false"; + }) it("Should force a Next Edit", async () => { const hasDecoration = await NextEditActions.forceNextEdit(editor);