Файли
openidea/e2e/vcsOperationsLayout.spec.ts
T
Vadim LazukтаInf1mum d1afd0ae9f feat(vcs): build the commit message field on the editor so Vim works in it (#8283)
The commit message field was a textarea, outside Vim mode, and its Esc always blurred. It is now a reusable editor-based TextField (src/editor/TextField.tsx) carrying the embedded editor contributions, so Vim attaches when Vim mode is on. Margin guide, wrap at margin, subject counter, blank-line inspection, message history, Meta+Enter and the activation focus keep working. Vim claims Escape in a tool window's Vim field outside Normal mode, so Esc leaves Insert or Visual mode before the tool window's Focus Editor runs; in Normal mode Esc moves the focus as before. The field sets data-autofocus before paint and ignores the blur of a view being destroyed. The Commit dialog shares the field.

Co-authored-by: Inf1mum <[email protected]>
2026-12-06 04:25:56 +08:00

68 рядки
3.3 KiB
TypeScript

import { expect, fieldText, openFromTree, test } from "./fixtures";
test("VCS Operations keeps its centered title visible in a short window", async ({ workbench: page }) => {
await page.setViewportSize({ width: 640, height: 320 });
const editor = await openFromTree(page, "README.md");
const content = editor.locator(".cm-content");
await content.focus();
await page.evaluate(async () => {
const actions = "/src/platform/actions.ts";
await (await import(/* @vite-ignore */ actions)).executeAction("vcs.operations");
});
const menu = page.getByRole("menu", { name: "VCS Operations", exact: true });
const popup = menu.locator("..");
const title = popup.getByText("VCS Operations", { exact: true });
await expect(title).toHaveCSS("font-size", "13px");
await expect(title).toHaveCSS("font-weight", "600");
await expect
.poll(async () => {
const box = (await popup.boundingBox())!;
return Math.max(Math.abs(box.x + box.width / 2 - 320), Math.abs(box.y + box.height / 2 - 160));
})
.toBeLessThan(2);
const commit = menu.getByRole("menuitem", { name: /^Commit…/ });
await expect(commit).toBeFocused();
await expect(commit.locator('[data-menu-number="1"]')).toBeVisible();
await page.keyboard.press("End");
const history = menu.getByRole("menuitem", { name: /^Show Local History/ });
await expect(history).toBeFocused();
await expect(history).toBeInViewport({ ratio: 1 });
await expect.poll(() => popup.evaluate((el) => el.scrollTop)).toBeGreaterThan(0);
expect((await title.boundingBox())!.y).toBeGreaterThanOrEqual((await popup.boundingBox())!.y);
await page.keyboard.press("Escape");
await expect(menu).toBeHidden();
await expect(content).toBeFocused();
await page.evaluate(async () => {
const actions = "/src/platform/actions.ts";
await (await import(/* @vite-ignore */ actions)).executeAction("vcs.operations");
});
await expect(commit).toBeFocused();
await page.keyboard.press("1");
await expect(menu).toBeHidden();
const commitWindow = page.getByRole("region", { name: "Commit", exact: true });
await expect(commitWindow).toBeVisible();
const message = commitWindow.getByRole("textbox", { name: "Commit message" });
await expect(message).toBeFocused();
expect(await fieldText(message)).toBe("");
});
test("VCS Operations offers repository setup and Local History outside Git", async ({ workbench: page }) => {
const editor = await openFromTree(page, "README.md");
await editor.locator(".cm-content").focus();
await page.evaluate(async () => {
const project = "/src/platform/project.ts";
const { useProject } = await import(/* @vite-ignore */ project);
useProject.setState((s: { project: object }) => ({ project: { ...s.project, isGit: false } }));
const context = "/src/platform/context.ts";
(await import(/* @vite-ignore */ context)).setContext("vcsAvailable", false);
const actions = "/src/platform/actions.ts";
await (await import(/* @vite-ignore */ actions)).executeAction("vcs.operations");
});
const menu = page.getByRole("menu", { name: "VCS Operations", exact: true });
await expect(menu.getByRole("menuitem")).toHaveText([/Create Git Repository…/, /Show Local History/]);
await expect(menu.getByRole("menuitem", { name: /^Create Git Repository…/ })).toBeFocused();
});