* 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>
200 lines
6.8 KiB
TypeScript
200 lines
6.8 KiB
TypeScript
import { expect } from "chai";
|
|
import {
|
|
EditorView,
|
|
InputBox,
|
|
Key,
|
|
TextEditor,
|
|
VSBrowser,
|
|
WebDriver,
|
|
WebElement,
|
|
WebView,
|
|
Workbench,
|
|
until,
|
|
} from "vscode-extension-tester";
|
|
|
|
import { GlobalActions } from "../actions/Global.actions";
|
|
import { GUIActions } from "../actions/GUI.actions";
|
|
import { KeyboardShortcutsActions } from "../actions/KeyboardShortcuts.actions";
|
|
import { DEFAULT_TIMEOUT } from "../constants";
|
|
import { GUISelectors } from "../selectors/GUI.selectors";
|
|
import { TestUtils } from "../TestUtils";
|
|
|
|
describe("Keyboard Shortcuts", () => {
|
|
let driver: WebDriver;
|
|
let editor: TextEditor;
|
|
let view: WebView;
|
|
|
|
before(async function () {
|
|
this.timeout(DEFAULT_TIMEOUT.XL);
|
|
await GUIActions.moveContinueToSidebar(VSBrowser.instance.driver);
|
|
await GlobalActions.disableNextEdit();
|
|
});
|
|
|
|
beforeEach(async function () {
|
|
this.timeout(DEFAULT_TIMEOUT.XL);
|
|
|
|
await TestUtils.waitForSuccess(async () => {
|
|
await new Workbench().executeCommand("Create: New File...");
|
|
await (
|
|
await InputBox.create(DEFAULT_TIMEOUT.MD)
|
|
).selectQuickPick("Text File");
|
|
});
|
|
|
|
driver = VSBrowser.instance.driver;
|
|
|
|
editor = (await new EditorView().openEditor("Untitled-1")) as TextEditor;
|
|
});
|
|
|
|
afterEach(async function () {
|
|
this.timeout(DEFAULT_TIMEOUT.XL * 1000);
|
|
await view.switchBack();
|
|
await editor.clearText();
|
|
await new EditorView().closeAllEditors();
|
|
});
|
|
|
|
it("Should correctly undo and redo using keyboard shortcuts when writing a chat message", async () => {
|
|
await GUIActions.executeFocusContinueInputShortcut(driver);
|
|
({ view } = await GUIActions.switchToReactIframe());
|
|
const chatInput = await TestUtils.waitForSuccess(async () => {
|
|
return GUISelectors.getMessageInputFieldAtIndex(view, 0);
|
|
});
|
|
|
|
await chatInput.sendKeys("HELLO ");
|
|
await TestUtils.waitForTimeout(DEFAULT_TIMEOUT.XS);
|
|
|
|
await chatInput.sendKeys("WORLD ");
|
|
await TestUtils.waitForTimeout(DEFAULT_TIMEOUT.XS);
|
|
|
|
await chatInput.sendKeys("HELLO ");
|
|
await TestUtils.waitForTimeout(DEFAULT_TIMEOUT.XS);
|
|
|
|
await chatInput.sendKeys("CONTINUE");
|
|
await TestUtils.waitForTimeout(DEFAULT_TIMEOUT.XS);
|
|
|
|
await chatInput.sendKeys(TestUtils.osControlKey + "z");
|
|
await driver.wait(
|
|
until.elementTextIs(chatInput, "HELLO WORLD"),
|
|
DEFAULT_TIMEOUT.SM,
|
|
);
|
|
|
|
await chatInput.sendKeys(TestUtils.osControlKey + "z");
|
|
await driver.wait(until.elementTextIs(chatInput, ""), DEFAULT_TIMEOUT.SM);
|
|
|
|
await chatInput.sendKeys(Key.SHIFT + TestUtils.osControlKey + "z");
|
|
await driver.wait(
|
|
until.elementTextIs(chatInput, "HELLO"),
|
|
DEFAULT_TIMEOUT.SM,
|
|
);
|
|
|
|
await chatInput.sendKeys(Key.SHIFT + TestUtils.osControlKey + "z");
|
|
await driver.wait(
|
|
until.elementTextIs(chatInput, "HELLO WORLD"),
|
|
DEFAULT_TIMEOUT.SM,
|
|
);
|
|
|
|
await chatInput.sendKeys(Key.SHIFT + TestUtils.osControlKey + "z");
|
|
await driver.wait(
|
|
until.elementTextIs(chatInput, "HELLO WORLD HELLO"),
|
|
DEFAULT_TIMEOUT.SM,
|
|
);
|
|
|
|
await chatInput.sendKeys(Key.SHIFT + TestUtils.osControlKey + "z");
|
|
await driver.wait(
|
|
until.elementTextIs(chatInput, "HELLO WORLD HELLO CONTINUE"),
|
|
DEFAULT_TIMEOUT.SM,
|
|
);
|
|
}).timeout(DEFAULT_TIMEOUT.XL);
|
|
|
|
it("Should not create a code block when Cmd+L is pressed without text highlighted", async () => {
|
|
const text = "Hello, world!";
|
|
|
|
await editor.setText(text);
|
|
|
|
await GUIActions.executeFocusContinueInputShortcut(driver);
|
|
|
|
({ view } = await GUIActions.switchToReactIframe());
|
|
|
|
await TestUtils.expectNoElement(async () => {
|
|
return GUISelectors.getInputBoxCodeBlockAtIndex(view, 0);
|
|
}, DEFAULT_TIMEOUT.XS);
|
|
await GUIActions.executeFocusContinueInputShortcut(driver);
|
|
}).timeout(DEFAULT_TIMEOUT.XL);
|
|
|
|
it("Fresh VS Code window → sidebar closed → cmd+L with no code highlighted → opens sidebar and focuses input → cmd+L closes sidebar", async () => {
|
|
await GUIActions.executeFocusContinueInputShortcut(driver);
|
|
({ view } = await GUIActions.switchToReactIframe());
|
|
const textInput = await TestUtils.waitForSuccess(() =>
|
|
GUISelectors.getMessageInputFieldAtIndex(view, 0),
|
|
);
|
|
const activeElement: WebElement = await driver.switchTo().activeElement();
|
|
const textInputHtml = await textInput.getAttribute("outerHTML");
|
|
const activeElementHtml = await activeElement.getAttribute("outerHTML");
|
|
expect(textInputHtml).to.equal(activeElementHtml);
|
|
expect(await textInput.isDisplayed()).to.equal(true);
|
|
|
|
await GUIActions.executeFocusContinueInputShortcut(driver);
|
|
|
|
await driver.wait(until.elementIsNotVisible(textInput), DEFAULT_TIMEOUT.XS);
|
|
expect(await textInput.isDisplayed()).to.equal(false);
|
|
}).timeout(DEFAULT_TIMEOUT.XL);
|
|
|
|
it("Send a message → focus code editor (not sidebar) → cmd+L → should focus sidebar and start a new session", async () => {
|
|
await GUIActions.executeFocusContinueInputShortcut(driver);
|
|
({ view } = await GUIActions.switchToReactIframe());
|
|
|
|
const { userMessage: userMessage0 } = TestUtils.generateTestMessagePair(0);
|
|
|
|
await GUIActions.sendMessage({
|
|
view,
|
|
message: userMessage0,
|
|
inputFieldIndex: 0,
|
|
});
|
|
|
|
await view.switchBack();
|
|
|
|
KeyboardShortcutsActions.HACK__typeWithSelect(editor, "hello");
|
|
|
|
await TestUtils.waitForTimeout(DEFAULT_TIMEOUT.XS);
|
|
|
|
await GUIActions.executeFocusContinueInputShortcut(driver);
|
|
|
|
({ view } = await GUIActions.switchToReactIframe());
|
|
|
|
await TestUtils.waitForTimeout(DEFAULT_TIMEOUT.XS);
|
|
|
|
const textInput = await TestUtils.waitForSuccess(() =>
|
|
GUISelectors.getMessageInputFieldAtIndex(view, 0),
|
|
);
|
|
const activeElement: WebElement = await driver.switchTo().activeElement();
|
|
const textInputHtml = await textInput.getAttribute("outerHTML");
|
|
const activeElementHtml = await activeElement.getAttribute("outerHTML");
|
|
expect(textInputHtml).to.equal(activeElementHtml);
|
|
|
|
await GUIActions.executeFocusContinueInputShortcut(driver);
|
|
|
|
await driver.wait(until.elementIsNotVisible(textInput), DEFAULT_TIMEOUT.XS);
|
|
expect(await textInput.isDisplayed()).to.equal(false);
|
|
}).timeout(DEFAULT_TIMEOUT.XL);
|
|
|
|
it("Should create a code block when Cmd+L is pressed with text highlighted", async () => {
|
|
const text = "Hello, world!";
|
|
|
|
await editor.setText(text);
|
|
await editor.selectText(text);
|
|
|
|
await GUIActions.executeFocusContinueInputShortcut(driver);
|
|
|
|
({ view } = await GUIActions.switchToReactIframe());
|
|
|
|
const codeBlock = await TestUtils.waitForSuccess(() =>
|
|
GUISelectors.getInputBoxCodeBlockAtIndex(view, 0),
|
|
);
|
|
const codeblockContent = await codeBlock.getAttribute(
|
|
"data-codeblockcontent",
|
|
);
|
|
|
|
expect(codeblockContent).to.equal(text);
|
|
|
|
await GUIActions.executeFocusContinueInputShortcut(driver);
|
|
}).timeout(DEFAULT_TIMEOUT.XL);
|
|
});
|