дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 17:21:13 +02:00
caretKeysEverywhere bound "Control+H", which is not a key stroke, so Move Caret Left was never bound; it passed on macOS only because Ctrl+H deletes backward there. compactMode expects the 30px status bar, toolbarCustomization measures the first visible item after the Center group, the commit check spec accepts a sub-pixel clip, and codeLensLayout waits for the editor to measure.
57 рядки
2.6 KiB
TypeScript
57 рядки
2.6 KiB
TypeScript
import type { Locator, Page } from "@playwright/test";
|
|
import { expect, openFromTree, stubDesktop, test } from "./fixtures";
|
|
|
|
/** Opens the sample with the server's lenses `titles` above its first line, at editor font `fontSize`. */
|
|
async function lensRow(page: Page, fontSize: number, titles: string[]): Promise<{ editor: Locator; row: Locator }> {
|
|
const editor = await openFromTree(page, "build.gradle.kts");
|
|
await stubDesktop(page);
|
|
await page.evaluate(
|
|
async ({ fontSize, titles }) => {
|
|
const projectPath = "/src/platform/project.ts";
|
|
const { useProject } = await import(/* @vite-ignore */ projectPath);
|
|
const settings = useProject.getState().settings;
|
|
useProject.setState({ settings: { ...settings, editor: { ...settings?.editor, fontSize } } });
|
|
const at = { line: 0, col: 0 };
|
|
window.__ipc.handlers.lsp_code_lens = () =>
|
|
titles.map((title) => ({ range: { start: at, end: at }, command: { title, command: "noop", arguments: [] } }));
|
|
},
|
|
{ fontSize, titles },
|
|
);
|
|
// An edit asks the server for its lenses again.
|
|
await editor.locator(".cm-line").first().click();
|
|
await page.keyboard.press("End");
|
|
await page.keyboard.type(" ");
|
|
const row = editor.locator(".cm-openidea-lens");
|
|
await expect(row).toContainText(titles[0]!);
|
|
return { editor, row };
|
|
}
|
|
|
|
test("a Code Vision row fits CJK hints at a large editor font", async ({ workbench: page }) => {
|
|
const { editor, row } = await lensRow(page, 20, ["10 个用法", "无用法"]);
|
|
const overflow = await row.evaluate((el) => {
|
|
const box = el.getBoundingClientRect();
|
|
return [...el.querySelectorAll(".cm-openidea-lensItem")].map((item) => {
|
|
const range = document.createRange();
|
|
range.selectNodeContents(item);
|
|
const text = range.getBoundingClientRect();
|
|
return Math.max(box.top - text.top, text.bottom - box.bottom);
|
|
});
|
|
});
|
|
expect(overflow).toHaveLength(2);
|
|
for (const px of overflow) expect(px).toBeLessThanOrEqual(0);
|
|
// The editor measured the taller row: the lines below it still sit beside their numbers.
|
|
const line = editor.locator(".cm-line", { hasText: "class OrderController" });
|
|
const number = editor.locator(".cm-lineNumbers .cm-gutterElement", { hasText: /^8$/ });
|
|
await expect
|
|
.poll(async () => {
|
|
const [lineBox, numberBox] = await Promise.all([line.boundingBox(), number.boundingBox()]);
|
|
return Math.abs(lineBox!.y - numberBox!.y);
|
|
})
|
|
.toBeLessThanOrEqual(1);
|
|
});
|
|
|
|
test("a Code Vision row keeps its height at the default editor font", async ({ workbench: page }) => {
|
|
const { row } = await lensRow(page, 13, ["3 usages"]);
|
|
expect((await row.boundingBox())!.height).toBe(16);
|
|
});
|