The IDE you know, rebuilt in Rust. IntelliJ IDEA–style keymap, tool windows and search-everywhere in a fast native app: editor, code insight, debugger, Git, terminal, database and HTTP clients for 60+ languages.
TypeScript code-editorcross-platformdapdatabase-clientdebuggerdesktop-appdeveloper-toolsgithttp-clientideintellijlsprusttauriterminal
import { afterEach, describe, expect, it, vi } from "vitest";
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
import { RecordShortcutDialog } from "../keymap/RecordShortcutDialog";
afterEach(cleanup);
const action = { id: "my.action", title: "My Action", category: "Test" };
describe("Mouse Shortcut dialog", () => {
it("records and submits Option+Command+left click", () => {
const onSubmit = vi.fn();
render(
<RecordShortcutDialog
mouse
action={action}
actions={[action]}
draft={{ preset: "intellij-macos", overrides: {} }}
onCancel={() => {}}
onSubmit={onSubmit}
/>,
);
fireEvent.mouseDown(screen.getByRole("textbox", { name: "Mouse shortcut" }), {
button: 0,
altKey: true,
metaKey: true,
});
fireEvent.click(screen.getByRole("button", { name: "OK" }));
expect(onSubmit).toHaveBeenCalledWith("Alt+Meta+Button1", [], false);
});
it("records a side-button click with modifiers and submits it", () => {
const onSubmit = vi.fn();
render(
<RecordShortcutDialog
mouse
action={action}
actions={[action]}
draft={{ preset: "intellij-macos", overrides: {} }}
onCancel={() => {}}
onSubmit={onSubmit}
/>,
);
const pad = screen.getByRole("textbox", { name: "Mouse shortcut" });
fireEvent.mouseDown(pad, { button: 0 });
expect(screen.getByRole("button", { name: "OK" })).toBeDisabled();
fireEvent.mouseDown(pad, { button: 3, altKey: true });
fireEvent.click(screen.getByRole("button", { name: "OK" }));
expect(onSubmit).toHaveBeenCalledWith("Alt+Button4", [], false);
});
});
describe("Page swipe shortcut recording", () => {
it.each(["SwipeLeft", "SwipeRight"])("records and submits %s from the focused recorder", (stroke) => {
const onSubmit = vi.fn();
render(
<RecordShortcutDialog
action={action}
actions={[action]}
draft={{ preset: "intellij-macos", overrides: {} }}
onCancel={() => {}}
onSubmit={onSubmit}
/>,
);
screen.getByRole("textbox", { name: "First stroke" }).focus();
fireEvent(window, new CustomEvent("ide:page-swipe", { detail: stroke }));
fireEvent.click(screen.getByRole("button", { name: "OK" }));
expect(onSubmit).toHaveBeenCalledWith(stroke, [], false);
});
});