feat: add a test only env variable

This commit is contained in:
Jacob Kim 2025-07-23 09:38:00 -07:00
parent c5a22b3e4a
commit 8e8b42f301
3 changed files with 21 additions and 92 deletions

View file

@ -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));
}

View file

@ -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);

View file

@ -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);