* feat: don't format when model is not mercury * chore: bump * fix: remove mercury-coder-nextedit * refactor: remove refs to mercury-coder-nextedit * feat: add util function for converting model name to enum * refactor: add new types * refactor: create an abstract base class for providers * refactor: add child provider for instinct * refactor: add provider for mercury coder * refactor: provider factory * refactor: use factory to create model providers based on helper.modelName * refactor: clean up redundant logic to be more provider-friendly * add buildPromptMetadata as an abstract method * refactor: use handlebars and provider-specific template renderers * refactor: use this.modelProvider instead of prompt engine * refactor: remove redundant helper * fix: update vitest after refactor * feat: add test for convertNextEditModelNameToEnum * fix: add isSecurityConcern imports * feat: add functions to return next edit menu items and update config * fix: get rid of callbacks * feat: render next edit menu items * fix: get rid of redundant completion request * feat: update next edit status on vscode workspace config update, refactor out common logic * feat: add continue.enableNextEdit * feat: add aborted field to check for false positives * fix: remove zetaDataset suffix * feat: make sure that we are tracking completions * feat: log aborts and move id generation to the top * feat: all requests are tracked. when request is aborted, log as aborted with zero-value data. else, graduate it from pending completion and set aborted to false * feat: add aborted to schema * feat: add a toggleNextEditEnabled command * feat: show (NE) in the status bar when next edit is enabled, add keymap * feat: add command definitions for toggleNextEditEnabled * refactor: handle validation in VsCodeExtension * feat: check if model does not support next edit * feat: use better menu item labels * fix: casing * chore: bump * feat: add a function to disable next edit * feat: disable next edit before e2e tests * chore: bump * fix: add a small delay to wait for UI loading * fix: NE is shown for all statuses * fix: wait for the NE to pop up * fix: wait longer for disableNextEdit, clear potential next edit notifications * fix: roll back clearAllNotifications * fix: try disabling next edit before each * fix: revert * feat: add sane defaults when no workspace settings are set * fix: fall back to false * fix: debugging * chore: change name * fix: try waiting for text * debug: more debug logs * fix: clear notifs * fix: suppress warning * fix: string matching * fix: jump label overlapping with the inline tip label (#7399) * feat: add methods to temporarily hide and show tooltip * feat: hide the inline tooltip when the jumpmanager's tooltip is shown * feat: focus on chat input after apply * revert * fix: HOTFIX local assistant loading (#7354) * fix: local assistant loading * fix: no need for excluding .continue/.continue * test: cases for config.yml and config.yaml names * feat: remove hide/show logic for creating a new svgbuilder instance * feat: use a new svgBuilder istance * chore: update package-lock.json --------- Co-authored-by: uinstinct <61635505+uinstinct@users.noreply.github.com> Co-authored-by: Dallin Romney <dallinromney@gmail.com> Co-authored-by: Ting-Wai <40179554+tingwai@users.noreply.github.com> --------- Co-authored-by: uinstinct <61635505+uinstinct@users.noreply.github.com> Co-authored-by: Dallin Romney <dallinromney@gmail.com> Co-authored-by: Ting-Wai <40179554+tingwai@users.noreply.github.com>
140 lines
3.9 KiB
TypeScript
140 lines
3.9 KiB
TypeScript
import { expect } from "chai";
|
|
import {
|
|
CodeLens,
|
|
TextEditor,
|
|
VSBrowser,
|
|
WebView,
|
|
} from "vscode-extension-tester";
|
|
|
|
import { EditActions } from "../actions/Edit.actions";
|
|
import { GlobalActions } from "../actions/Global.actions";
|
|
import { GUIActions } from "../actions/GUI.actions";
|
|
import { DEFAULT_TIMEOUT } from "../constants";
|
|
import { GUISelectors } from "../selectors/GUI.selectors";
|
|
import { TestUtils } from "../TestUtils";
|
|
|
|
describe("Edit Test", () => {
|
|
let view: WebView;
|
|
let editor: TextEditor;
|
|
let originalEditorText = "Hello world!";
|
|
let { userMessage, llmResponse } = TestUtils.generateTestMessagePair();
|
|
|
|
before(async function () {
|
|
this.timeout(DEFAULT_TIMEOUT.XL);
|
|
await GUIActions.moveContinueToSidebar(VSBrowser.instance.driver);
|
|
await GlobalActions.openTestWorkspace();
|
|
({ editor } = await GlobalActions.createAndOpenNewTextFile());
|
|
await GlobalActions.disableNextEdit();
|
|
});
|
|
|
|
beforeEach(async function () {
|
|
this.timeout(DEFAULT_TIMEOUT.XL);
|
|
|
|
await GUIActions.toggleGui();
|
|
|
|
await editor.typeTextAt(1, 1, originalEditorText);
|
|
await editor.selectText(originalEditorText);
|
|
|
|
await EditActions.invokeEditShortcut(editor);
|
|
|
|
({ view } = await GUIActions.switchToReactIframe());
|
|
|
|
await GUIActions.sendMessage({
|
|
view,
|
|
message: userMessage,
|
|
inputFieldIndex: 0,
|
|
});
|
|
|
|
await view.switchBack();
|
|
|
|
await TestUtils.waitForSuccess(async () => {
|
|
const editorText = await editor.getText();
|
|
return editorText.includes(llmResponse);
|
|
});
|
|
});
|
|
|
|
afterEach(async function () {
|
|
this.timeout(DEFAULT_TIMEOUT.XL);
|
|
|
|
await editor.clearText();
|
|
|
|
({ view } = await GUIActions.switchToReactIframe());
|
|
|
|
const tipTapEditor = await GUISelectors.getMessageInputFieldAtIndex(
|
|
view,
|
|
0,
|
|
);
|
|
await tipTapEditor.clear();
|
|
});
|
|
|
|
async function getCodeLensWithRetry(editor: TextEditor, text: string) {
|
|
let codeLens: CodeLens | undefined;
|
|
await TestUtils.waitForSuccess(async () => {
|
|
codeLens = await editor.getCodeLens(text);
|
|
expect(codeLens).to.not.be.undefined;
|
|
}, DEFAULT_TIMEOUT.SM);
|
|
return codeLens;
|
|
}
|
|
|
|
it.only("Accepts an Edit in the GUI", async () => {
|
|
({ view } = await GUIActions.switchToReactIframe());
|
|
|
|
await EditActions.acceptEditInGUI(view);
|
|
|
|
await view.switchBack();
|
|
|
|
await TestUtils.waitForSuccess(async () => {
|
|
const editorText = await editor.getText();
|
|
|
|
expect(
|
|
!editorText.includes(originalEditorText) &&
|
|
editorText.includes(llmResponse),
|
|
).to.be.true;
|
|
}, DEFAULT_TIMEOUT.SM);
|
|
}).timeout(DEFAULT_TIMEOUT.XL);
|
|
|
|
it("Rejects an Edit in the GUI", async () => {
|
|
({ view } = await GUIActions.switchToReactIframe());
|
|
|
|
await EditActions.rejectEditInGUI(view);
|
|
|
|
await view.switchBack();
|
|
|
|
await TestUtils.waitForSuccess(async () => {
|
|
const editorText = await editor.getText();
|
|
|
|
expect(
|
|
editorText.includes(originalEditorText) &&
|
|
!editorText.includes(llmResponse),
|
|
).to.be.true;
|
|
}, DEFAULT_TIMEOUT.SM);
|
|
}).timeout(DEFAULT_TIMEOUT.XL);
|
|
|
|
it("Accepts an Edit using CodeLens buttons", async () => {
|
|
const acceptCodeLens = await editor.getCodeLens("Accept");
|
|
await acceptCodeLens?.click();
|
|
|
|
await TestUtils.waitForSuccess(async () => {
|
|
const editorText = await editor.getText();
|
|
|
|
expect(
|
|
!editorText.includes(originalEditorText) &&
|
|
editorText.includes(llmResponse),
|
|
).to.be.true;
|
|
}, DEFAULT_TIMEOUT.SM);
|
|
}).timeout(DEFAULT_TIMEOUT.XL);
|
|
|
|
it("Rejects an Edit using CodeLens buttons", async () => {
|
|
const rejectCodeLens = await getCodeLensWithRetry(editor, "Reject");
|
|
await rejectCodeLens?.click();
|
|
|
|
await TestUtils.waitForSuccess(async () => {
|
|
const editorText = await editor.getText();
|
|
|
|
expect(
|
|
editorText.includes(originalEditorText) &&
|
|
!editorText.includes(llmResponse),
|
|
).to.be.true;
|
|
}, DEFAULT_TIMEOUT.SM);
|
|
}).timeout(DEFAULT_TIMEOUT.XL);
|
|
});
|