дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-28 05:22:23 +02:00
Merge remote-tracking branch 'origin/main' into fix/editor-breadcrumb-layout
Цей коміт міститься в:
коміт
3eff08d2f8
82 files changed
+2861
-379
No files matched your search
@@ -6,6 +6,9 @@ import type { Page } from "@playwright/test";
|
||||
import { expect, stubDesktop, test } from "./fixtures";
|
||||
|
||||
const ROOT = "/dev/acme-api";
|
||||
const NESTED_REF = "teams/payments/reporting/month-end/exports/regions/europe/accounting/invoice-export";
|
||||
const TRACKING_REF = "origin/releases/payments/month-end/reconciliation/invoice-export";
|
||||
const BRANCH_FIXTURE = { root: ROOT, ref: NESTED_REF, upstream: TRACKING_REF };
|
||||
|
||||
async function openBranches(page: Page) {
|
||||
await page.evaluate(async () => {
|
||||
@@ -22,7 +25,7 @@ async function openBranches(page: Page) {
|
||||
|
||||
test.beforeEach(async ({ workbench: page }) => {
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(async (root) => {
|
||||
await page.evaluate(async ({ root, ref, upstream }) => {
|
||||
const h = window.__ipc.handlers;
|
||||
const branch = (name: string, current = false) => ({
|
||||
name,
|
||||
@@ -47,6 +50,7 @@ test.beforeEach(async ({ workbench: page }) => {
|
||||
h.vcs_tags = () => [];
|
||||
h.vcs_branches = () => [
|
||||
branch("main", true),
|
||||
{ ...branch(ref), upstream, ahead: 2, behind: 3 },
|
||||
...Array.from({ length: 40 }, (_, i) => branch(`task-${i}-a-long-branch-name-that-gets-cut-off`)),
|
||||
];
|
||||
const vcsModule = "/src/features/vcs/store.ts";
|
||||
@@ -54,7 +58,41 @@ test.beforeEach(async ({ workbench: page }) => {
|
||||
useVcs.setState({ available: true, root, repo: root, branchesLoaded: false, stashesLoaded: false });
|
||||
await refreshNow();
|
||||
await loadBranches();
|
||||
}, ROOT);
|
||||
}, BRANCH_FIXTURE);
|
||||
});
|
||||
|
||||
test("narrow Git Branches keeps a deeply nested branch and its controls readable", async ({ workbench: page }) => {
|
||||
await page.evaluate(() => {
|
||||
localStorage.setItem("openidea.vcs.branchesPopup.size", JSON.stringify({ w: 280, h: 420 }));
|
||||
});
|
||||
const popup = await openBranches(page);
|
||||
const search = popup.getByRole("textbox", { name: "Search branches and actions" });
|
||||
await search.fill("invoice-export");
|
||||
const row = popup.getByRole("option", { name: /invoice-export/ });
|
||||
await expect(row).toBeVisible();
|
||||
const name = row.locator("[class*=branchName]");
|
||||
const tracking = row.getByText(TRACKING_REF, { exact: true });
|
||||
const chevron = row.locator("svg").last();
|
||||
const folder = popup.getByRole("option", { name: "accounting", exact: true });
|
||||
const rowBox = (await row.boundingBox())!;
|
||||
const nameBox = (await name.boundingBox())!;
|
||||
const trackingBox = (await tracking.boundingBox())!;
|
||||
const chevronBox = (await chevron.boundingBox())!;
|
||||
const indent = (option: typeof row) =>
|
||||
option.locator("[data-row-key]").evaluate((el) => parseFloat(getComputedStyle(el).paddingInlineStart));
|
||||
expect(await indent(row)).toBeGreaterThan(await indent(folder));
|
||||
expect(chevronBox.x + chevronBox.width).toBeLessThanOrEqual(rowBox.x + rowBox.width);
|
||||
expect(nameBox.width).toBeGreaterThan(42);
|
||||
expect(trackingBox.width).toBeGreaterThan(12);
|
||||
expect(trackingBox.width).toBeLessThan(rowBox.width * 0.4);
|
||||
await expect(name).toHaveCSS("font-size", "13px");
|
||||
await expect(tracking).toHaveCSS("font-size", "13px");
|
||||
await expect(row.getByRole("img", { name: "3 incoming commits" })).toBeVisible();
|
||||
await expect(row.getByRole("img", { name: "2 outgoing commits" })).toBeVisible();
|
||||
await expect(row.locator("[data-row-key]")).toHaveAttribute("title", NESTED_REF);
|
||||
await expect(tracking).toHaveAttribute("title", TRACKING_REF);
|
||||
await chevron.click();
|
||||
await expect(page.getByRole("menu", { name: `Branch ${NESTED_REF}` })).toBeVisible();
|
||||
});
|
||||
|
||||
test("Git Branches resizes by its corner and right edge and reopens at that size", async ({ workbench: page }) => {
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import type { BuildModel, BuildTool } from "../src/platform/ipc";
|
||||
import { expect, stubDesktop, test } from "./fixtures";
|
||||
|
||||
const model: BuildModel = {
|
||||
maven: {
|
||||
projects: [
|
||||
{
|
||||
pom: "pom.xml",
|
||||
dir: "",
|
||||
groupId: "com.example",
|
||||
artifactId: "orders",
|
||||
version: "1.0.0",
|
||||
packaging: "jar",
|
||||
displayName: "Orders service",
|
||||
parent: null,
|
||||
modules: [],
|
||||
aggregated: false,
|
||||
plugins: [],
|
||||
dependencies: [],
|
||||
profiles: [],
|
||||
javaVersion: 21,
|
||||
command: "mvn",
|
||||
options: [],
|
||||
env: {},
|
||||
},
|
||||
],
|
||||
profiles: [],
|
||||
syncedAt: 1,
|
||||
stale: false,
|
||||
syncError: null,
|
||||
},
|
||||
gradle: [
|
||||
{
|
||||
dir: "",
|
||||
command: "gradle",
|
||||
env: {},
|
||||
javaVersion: 21,
|
||||
syncedAt: 1,
|
||||
stale: false,
|
||||
syncError: null,
|
||||
projects: [{ path: ":", name: "orders", dir: "", buildFile: "build.gradle", tasks: [] }],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
async function showTool(page: Page, tool: BuildTool) {
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(
|
||||
async ({ tool, model }) => {
|
||||
window.__ipc.handlers.build_model = () => model;
|
||||
window.__ipc.handlers.run_configs = () => [];
|
||||
const buildStore = "/src/features/build-tools/store.ts";
|
||||
await (await import(/* @vite-ignore */ buildStore)).loadModel();
|
||||
const layout = "/src/workbench/toolwindows/store.ts";
|
||||
const { setToolWindowSize, showToolWindow } = await import(/* @vite-ignore */ layout);
|
||||
showToolWindow(tool, true);
|
||||
setToolWindowSize("right", 190);
|
||||
},
|
||||
{ tool, model },
|
||||
);
|
||||
}
|
||||
|
||||
async function setWidth(page: Page, width: number) {
|
||||
await page.evaluate(async (px) => {
|
||||
const layout = "/src/workbench/toolwindows/store.ts";
|
||||
(await import(/* @vite-ignore */ layout)).setToolWindowSize("right", px);
|
||||
}, width);
|
||||
}
|
||||
|
||||
for (const tool of ["maven", "gradle"] as const) {
|
||||
const name = tool === "maven" ? "Maven" : "Gradle";
|
||||
test(`${name} keeps its toolbar actions reachable as the pane resizes`, async ({ workbench: page }) => {
|
||||
await showTool(page, tool);
|
||||
const toolbar = page.getByRole("toolbar", { name: `${name} actions` });
|
||||
const more = toolbar.getByRole("button", { name: "More Actions", exact: true });
|
||||
const menu = page.getByRole("menu", { name: "More Actions", exact: true });
|
||||
const skipTests = "Toggle 'Skip Tests' Mode";
|
||||
await expect(toolbar.getByRole("button", { name: `Reload All ${name} Projects` })).toBeVisible();
|
||||
await expect(toolbar.getByRole("button", { name: new RegExp(`Execute ${name}`) })).toBeVisible();
|
||||
await expect(page.getByRole("tree", { name: `${name} projects` })).toBeVisible();
|
||||
expect(await toolbar.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
||||
await more.click();
|
||||
await expect(menu.getByRole("menuitem", { name: "Analyze Dependencies…" })).toBeVisible();
|
||||
await expect(menu.getByRole("menuitem", { name: "Expand All" })).toBeVisible();
|
||||
await menu.getByRole("menuitemcheckbox", { name: skipTests, checked: false }).click();
|
||||
await expect(menu).toBeHidden();
|
||||
await more.click();
|
||||
await expect(menu.getByRole("menuitemcheckbox", { name: skipTests, checked: true })).toBeVisible();
|
||||
await setWidth(page, 360);
|
||||
await expect(menu).toBeHidden();
|
||||
await expect(more).toBeHidden();
|
||||
await expect(toolbar.getByRole("button", { name: skipTests, pressed: true })).toBeVisible();
|
||||
await expect(toolbar.getByRole("button", { name: "Collapse All" })).toBeVisible();
|
||||
await setWidth(page, 190);
|
||||
await expect(more).toBeVisible();
|
||||
await expect(menu).toBeHidden();
|
||||
});
|
||||
}
|
||||
@@ -65,6 +65,7 @@ test("completion lists the server's items and inserts the chosen one", async ({
|
||||
const popup = page.locator(".cm-tooltip-autocomplete");
|
||||
await expect(popup.getByText("total", { exact: true })).toBeVisible();
|
||||
await expect(popup.getByText("toDto", { exact: true })).toBeVisible();
|
||||
expect((await popup.boundingBox())!.width).toBeLessThan(360);
|
||||
const field = popup.locator("li").filter({ has: page.locator(".cm-completionLabel", { hasText: /^total$/ }) });
|
||||
await expect(field.locator(".cm-completionDetail")).toHaveCount(0);
|
||||
await expect(field.locator(".cm-lsp-type")).toHaveText("BigDecimal");
|
||||
@@ -83,6 +84,17 @@ test("completion lists the server's items and inserts the chosen one", async ({
|
||||
const label = await method.locator(".cm-completionLabel").boundingBox();
|
||||
// Subpixel rounding differs per platform/font; a mis-set inset is a whole icon column off.
|
||||
expect(Math.abs(label!.x - wordStart)).toBeLessThanOrEqual(2);
|
||||
const zoomedSize = await editor.locator(".cm-content").evaluate(async (content) => {
|
||||
const viewModule = "/node_modules/.vite/deps/@codemirror_view.js";
|
||||
const prefsModule = "/src/editor/core/cm/prefs.ts";
|
||||
const { EditorView } = await import(/* @vite-ignore */ viewModule);
|
||||
const { stepFontZoom } = await import(/* @vite-ignore */ prefsModule);
|
||||
const fontSize = Number.parseFloat(getComputedStyle(content).fontSize);
|
||||
stepFontZoom(EditorView.findFromDOM(content as HTMLElement)!, 6);
|
||||
return `${fontSize + 6}px`;
|
||||
});
|
||||
await expect(editor.locator(".cm-content")).toHaveCSS("font-size", zoomedSize);
|
||||
await expect(method.locator(".cm-completionLabel")).toHaveCSS("font-size", zoomedSize);
|
||||
await page.keyboard.type("toD");
|
||||
await expect(popup.getByText("total", { exact: true })).toBeHidden();
|
||||
// Refreshing the results rebuilds the list; the hint bar must stay below it, not jump to the top.
|
||||
@@ -98,6 +110,76 @@ test("completion lists the server's items and inserts the chosen one", async ({
|
||||
expect((await ipcCalls(page, "lsp_completion")).length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
test("long completion signatures fit the editor when the workbench is narrowed", async ({ workbench: page }) => {
|
||||
const editor = await openSample(page);
|
||||
const label = "transformOrder" + "AcrossParticipatingRegions".repeat(5);
|
||||
await page.evaluate((label) => {
|
||||
const item: CompletionItem = {
|
||||
label,
|
||||
labelDetail: "(order: Order, options: TransformationOptions)",
|
||||
labelDescription: "Promise<TransformationResult>",
|
||||
detail: `${label}(order: Order, options: TransformationOptions): Promise<TransformationResult>`,
|
||||
kind: "method",
|
||||
documentation: { kind: "markdown", value: "Transforms the order." },
|
||||
sortText: null,
|
||||
filterText: null,
|
||||
preselect: true,
|
||||
deprecated: false,
|
||||
insertText: `${label}()`,
|
||||
isSnippet: false,
|
||||
replaceRange: null,
|
||||
replaceRangeTab: null,
|
||||
additionalEdits: [],
|
||||
commitCharacters: [],
|
||||
command: null,
|
||||
data: null,
|
||||
server: 1,
|
||||
};
|
||||
window.__ipc.handlers.lsp_completion = () => ({ isIncomplete: false, items: [item] });
|
||||
}, label);
|
||||
await editor.locator(".cm-line", { hasText: "return order.toDto()" }).click();
|
||||
await page.keyboard.press("End");
|
||||
await page.keyboard.press("Enter");
|
||||
await page.keyboard.type("order.");
|
||||
await page.keyboard.press("Control+Space");
|
||||
|
||||
const popup = page.locator(".cm-tooltip-autocomplete");
|
||||
const option = popup.getByRole("option").filter({
|
||||
has: page.locator(".cm-completionLabel", { hasText: label }),
|
||||
});
|
||||
await expect(option.locator(".cm-completionLabel")).toHaveText(label);
|
||||
await page.setViewportSize({ width: 580, height: 900 });
|
||||
const bounds = (await editor.boundingBox())!;
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const box = (await popup.boundingBox())!;
|
||||
return Math.max(bounds.x - box.x, box.x + box.width - (bounds.x + bounds.width));
|
||||
})
|
||||
.toBeLessThanOrEqual(2);
|
||||
const geometry = await option.evaluate((row) => {
|
||||
const label = row.querySelector<HTMLElement>(".cm-completionLabel")!;
|
||||
const type = row.querySelector<HTMLElement>(".cm-lsp-type")!;
|
||||
return {
|
||||
nameTruncated: label.scrollWidth > label.clientWidth,
|
||||
nameWidth: label.clientWidth,
|
||||
typeWidth: type.clientWidth,
|
||||
typeOverflow: type.getBoundingClientRect().right - row.getBoundingClientRect().right,
|
||||
};
|
||||
});
|
||||
expect(geometry.nameTruncated).toBe(true);
|
||||
expect(geometry.nameWidth).toBeGreaterThan(40);
|
||||
expect(geometry.typeWidth).toBeGreaterThan(16);
|
||||
expect(geometry.typeOverflow).toBeLessThanOrEqual(1);
|
||||
|
||||
await page.keyboard.press("F1");
|
||||
await expect(popup.locator(".cm-completionInfo")).toContainText(
|
||||
`${label}(order: Order, options: TransformationOptions)`,
|
||||
);
|
||||
await page.keyboard.press("Enter");
|
||||
await expect(popup).toBeHidden();
|
||||
await expect(editor.locator(".cm-activeLine")).toContainText(`order.${label}()`);
|
||||
});
|
||||
|
||||
test("documentation shows beside the lookup instead of being clipped by it", async ({ workbench: page }, info) => {
|
||||
const editor = await openSample(page);
|
||||
await page.evaluate(async () => {
|
||||
@@ -416,6 +498,85 @@ test("indexed single-file rename previews all anchors and applies only after con
|
||||
expect(apply.edit).toMatchObject({ preconditions: [{ path: FILE, hash: "indexed-snapshot" }] });
|
||||
});
|
||||
|
||||
test("intention previews fit narrow windows and wrap long code lines", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 1600, height: 900 });
|
||||
const editor = await openSample(page);
|
||||
await page.evaluate(async () => {
|
||||
const path = "/src/platform/project.ts";
|
||||
const { useProject } = await import(/* @vite-ignore */ path);
|
||||
const { settings } = useProject.getState();
|
||||
useProject.setState({ settings: { ...settings, editor: { ...settings?.editor, fontSize: 16 } } });
|
||||
});
|
||||
await expect(editor.locator(".cm-content")).toHaveCSS("font-size", "16px");
|
||||
const replacement = "com.acme.orders." + "SharedDevelopmentOrderModel".repeat(6);
|
||||
await page.evaluate(
|
||||
({ file, replacement, edit }) => {
|
||||
window.__ipc.handlers.lsp_code_actions = () => [
|
||||
{
|
||||
title: "Replace Order with the fully qualified shared development order model",
|
||||
kind: "quickfix",
|
||||
isPreferred: true,
|
||||
disabledReason: null,
|
||||
edit: { files: [{ kind: "edit", path: file, edits: [{ range: edit, new_text: replacement }] }] },
|
||||
command: null,
|
||||
data: null,
|
||||
server: 1,
|
||||
},
|
||||
...Array.from({ length: 11 }, (_, i) => ({
|
||||
title: `Create alternative Order model ${i + 1}`,
|
||||
kind: "quickfix",
|
||||
isPreferred: false,
|
||||
disabledReason: null,
|
||||
edit: null,
|
||||
command: null,
|
||||
data: null,
|
||||
server: 1,
|
||||
})),
|
||||
];
|
||||
window.__ipc.handlers.lsp_execute_code_action = () => [];
|
||||
},
|
||||
{ file: FILE, replacement, edit: range(20, 19, 24) },
|
||||
);
|
||||
await caretAt(editor, page, "val order: Order", "Order ");
|
||||
await page.keyboard.press("Alt+Enter");
|
||||
const popup = page.getByRole("dialog", { name: "Intentions", exact: true });
|
||||
const options = popup.getByRole("listbox", { name: "Intentions" });
|
||||
const preview = popup.locator('[aria-label="Preview"]');
|
||||
await expect(preview.locator("pre")).toContainText(replacement);
|
||||
const wide = (await options.boundingBox())!;
|
||||
const widePreview = (await preview.boundingBox())!;
|
||||
expect(widePreview.x).toBeGreaterThanOrEqual(wide.x + wide.width - 1);
|
||||
|
||||
await page.setViewportSize({ width: 1050, height: 900 });
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const list = (await options.boundingBox())!;
|
||||
const code = (await preview.boundingBox())!;
|
||||
return code.x + code.width - list.x;
|
||||
})
|
||||
.toBeLessThanOrEqual(1);
|
||||
|
||||
await page.setViewportSize({ width: 520, height: 540 });
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const menu = (await popup.boundingBox())!;
|
||||
const list = (await options.boundingBox())!;
|
||||
const code = (await preview.boundingBox())!;
|
||||
return {
|
||||
popupFits: menu.x >= 0 && menu.y >= 0 && menu.x + menu.width <= 521 && menu.y + menu.height <= 541,
|
||||
previewBelow: code.y >= list.y + list.height - 1,
|
||||
previewFits: code.x >= menu.x && code.x + code.width <= menu.x + menu.width + 1,
|
||||
};
|
||||
})
|
||||
.toEqual({ popupFits: true, previewBelow: true, previewFits: true });
|
||||
expect(await preview.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
||||
await expect(preview.locator("pre")).toHaveCSS("font-size", "16px");
|
||||
await expect(options).toBeFocused();
|
||||
await page.keyboard.press("Enter");
|
||||
await expect(popup).toBeHidden();
|
||||
await expect.poll(() => ipcCalls(page, "lsp_execute_code_action")).toHaveLength(1);
|
||||
});
|
||||
|
||||
test("diagnostics underline the range and ⌥⏎ applies the preferred quick fix", async ({ workbench: page }) => {
|
||||
const editor = await openSample(page);
|
||||
await page.evaluate(
|
||||
|
||||
@@ -2,13 +2,10 @@ import { expect, stubDesktop, test } from "./fixtures";
|
||||
|
||||
test.use({ video: "on" });
|
||||
|
||||
test("Feign navigation selects the named service and offers ambiguous source targets", async ({
|
||||
workbench: page,
|
||||
}, testInfo) => {
|
||||
test.beforeEach(async ({ workbench: page }) => {
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(async () => {
|
||||
const backend = "/src/editor/core/backend.ts";
|
||||
const contributions = "/src/workbench/contributions.ts";
|
||||
const { docBackend } = await import(backend);
|
||||
const files: Map<string, string> = docBackend().files;
|
||||
const root = "/dev/acme-api";
|
||||
@@ -37,7 +34,9 @@ class UserController {
|
||||
files.set(`${root}/${service}/src/main/resources/application.properties`, `spring.application.name=${service}\n`);
|
||||
}
|
||||
window.__ipc.handlers.spring_route_sources = () =>
|
||||
[...files].filter(([p]) => p.endsWith("UserController.java")).map(([path, text]) => ({ path, text }));
|
||||
[...files]
|
||||
.filter(([path, text]) => /\.(java|kt)$/.test(path) && text.includes("Mapping"))
|
||||
.map(([path, text]) => ({ path, text }));
|
||||
window.__ipc.handlers.fs_read_text = ({ path }) => {
|
||||
if (!files.has(String(path))) throw { kind: "notFound", message: "No fixture file" };
|
||||
return files.get(String(path));
|
||||
@@ -60,7 +59,21 @@ class UserController {
|
||||
hidden: false,
|
||||
}));
|
||||
window.__ipc.handlers.lsp_goto = () => [];
|
||||
await (await import(contributions)).editorService().openFile(`${root}/client/src/main/java/UserClient.java`);
|
||||
window.__ipc.handlers.fs_probe = ({ path }) => ({
|
||||
size: files.get(String(path))?.length ?? 0,
|
||||
binary: false,
|
||||
tooLarge: false,
|
||||
});
|
||||
window.__ipc.handlers.find_files = () => [];
|
||||
});
|
||||
});
|
||||
|
||||
test("Feign navigation selects the named service and offers ambiguous source targets", async ({
|
||||
workbench: page,
|
||||
}, testInfo) => {
|
||||
await page.evaluate(async () => {
|
||||
const contributions = "/src/workbench/contributions.ts";
|
||||
await (await import(contributions)).editorService().openFile("/dev/acme-api/client/src/main/java/UserClient.java");
|
||||
});
|
||||
await expect(page.locator(".cm-content").last()).toContainText("@FeignClient");
|
||||
await page.screenshot({ path: testInfo.outputPath("feign-source.png"), animations: "disabled" });
|
||||
@@ -111,3 +124,94 @@ class UserController {
|
||||
await declarations.getByRole("option").filter({ hasText: "admin/" }).click();
|
||||
await expect(page.locator(".cm-content").last()).toContainText('return "admin"');
|
||||
});
|
||||
|
||||
test("a Spring endpoint lists Feign clients by module and flags unresolved services", async ({
|
||||
workbench: page,
|
||||
}, testInfo) => {
|
||||
await page.evaluate(async () => {
|
||||
const backend = "/src/editor/core/backend.ts";
|
||||
const contributions = "/src/workbench/contributions.ts";
|
||||
const files: Map<string, string> = (await import(backend)).docBackend().files;
|
||||
const root = "/dev/acme-api";
|
||||
const original = `${root}/client/src/main/java/UserClient.java`;
|
||||
const template = files.get(original)!;
|
||||
files.delete(original);
|
||||
for (const [module, type, service] of [
|
||||
["orders", "OrderUsers", "users"],
|
||||
["admin-ui", "AdminUsers", "admin"],
|
||||
["gateway", "GatewayUsers", "${SERVICE}"],
|
||||
] as const) {
|
||||
files.set(
|
||||
`${root}/${module}/src/main/java/${type}.java`,
|
||||
template.replace("UserClient", type).replace('"users"', `"${service}"`),
|
||||
);
|
||||
}
|
||||
files.set(
|
||||
`${root}/billing/src/main/kotlin/BillingUsers.kt`,
|
||||
`package shop
|
||||
import org.springframework.cloud.openfeign.FeignClient
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
|
||||
@FeignClient("users")
|
||||
interface BillingUsers {
|
||||
@GetMapping("/users/{userId}")
|
||||
fun find(): String
|
||||
}`,
|
||||
);
|
||||
await (await import(contributions)).editorService().openFile(`${root}/users/src/main/java/UserController.java`);
|
||||
});
|
||||
|
||||
await page.locator('[data-icon-source="spring"][title="GET /users/{id}"]').click();
|
||||
await expect(page.getByRole("menuitem", { name: "Generate Request in HTTP Client" })).toBeVisible();
|
||||
await page.screenshot({ path: testInfo.outputPath("controller-menu.png"), animations: "disabled" });
|
||||
await page.getByRole("menuitem", { name: "Find Feign Clients" }).click({ timeout: 5_000 });
|
||||
const picker = page.getByRole("dialog", { name: "Feign Clients" });
|
||||
const rows = picker.getByRole("option");
|
||||
await expect(rows).toHaveCount(3);
|
||||
await expect(rows.nth(0)).toContainText("BillingUsers.find");
|
||||
await expect(rows.nth(0)).toContainText("billing");
|
||||
await expect(rows.nth(1)).toContainText("OrderUsers.find");
|
||||
await expect(rows.nth(1)).toContainText("orders");
|
||||
await expect(rows.nth(2)).toContainText("GatewayUsers.find");
|
||||
await expect(rows.nth(2)).toContainText("Possible match");
|
||||
await page.screenshot({ path: testInfo.outputPath("feign-clients.png"), animations: "disabled" });
|
||||
await rows.nth(0).click();
|
||||
await expect(page.locator(".cm-content").last()).toContainText("interface BillingUsers");
|
||||
});
|
||||
|
||||
test("one possible client requires a choice and a changed workspace invalidates that choice", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.evaluate(async () => {
|
||||
const backend = "/src/editor/core/backend.ts";
|
||||
const api = "/src/editor/api.ts";
|
||||
const actions = "/src/platform/actions.ts";
|
||||
const contributions = "/src/workbench/contributions.ts";
|
||||
const root = "/dev/acme-api";
|
||||
const files: Map<string, string> = (await import(backend)).docBackend().files;
|
||||
files.set(`${root}/users/src/main/resources/application.properties`, "spring.application.name=${SERVICE}");
|
||||
await (await import(contributions)).editorService().openFile(`${root}/users/src/main/java/UserController.java`);
|
||||
const view = (await import(api)).activeEditor().view;
|
||||
view.dispatch({ selection: { anchor: view.state.doc.toString().indexOf("return") } });
|
||||
await (await import(actions)).executeAction("http.findFeignClients");
|
||||
});
|
||||
const picker = page.getByRole("dialog", { name: "Feign Clients" });
|
||||
const candidate = picker.getByRole("option");
|
||||
await expect(candidate).toHaveCount(1);
|
||||
await expect(candidate).toContainText("Possible match");
|
||||
await page.evaluate(async () => {
|
||||
const backend = "/src/editor/core/backend.ts";
|
||||
const ipc = "/src/platform/ipc.ts";
|
||||
const path = "/dev/acme-api/users/src/main/resources/application.properties";
|
||||
(await import(backend)).docBackend().files.set(path, "spring.application.name=users");
|
||||
(await import(ipc)).emitLocalIdeEvent({ type: "fsChanged", created: [], modified: [path], removed: [] });
|
||||
});
|
||||
await candidate.click();
|
||||
await expect(picker).not.toBeVisible();
|
||||
await expect(page.locator(".cm-content").last()).toContainText("class UserController");
|
||||
await page.evaluate(async () => {
|
||||
const actions = "/src/platform/actions.ts";
|
||||
await (await import(actions)).executeAction("http.findFeignClients");
|
||||
});
|
||||
await expect(page.locator(".cm-content").last()).toContainText("interface UserClient");
|
||||
});
|
||||
@@ -0,0 +1,73 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect, openFromTree, stubDesktop, test } from "./fixtures";
|
||||
|
||||
async function quickDocumentation(page: Page, markdown: string) {
|
||||
const editor = await openFromTree(page, "build.gradle.kts");
|
||||
await stubDesktop(page);
|
||||
await page.evaluate((value) => {
|
||||
window.__ipc.handlers.lsp_hover = () => ({ contents: { kind: "markdown", value }, range: null });
|
||||
}, markdown);
|
||||
const line = editor.locator(".cm-line", { hasText: "return order.toDto()" });
|
||||
await line.click();
|
||||
await page.keyboard.press("End");
|
||||
await page.keyboard.press("ArrowLeft");
|
||||
await page.keyboard.press("ArrowLeft");
|
||||
await page.keyboard.press("ArrowLeft");
|
||||
await page.keyboard.press("F1");
|
||||
const popup = page.getByRole("dialog", { name: "Documentation", exact: true });
|
||||
await expect(popup.locator(".cm-lsp-markdown")).toBeVisible();
|
||||
return popup;
|
||||
}
|
||||
|
||||
test("short quick documentation uses a readable width and a compact corner of actions", async ({ workbench: page }) => {
|
||||
const popup = await quickDocumentation(page, "Returns the total.");
|
||||
const back = popup.getByRole("button", { name: "Back", exact: true });
|
||||
const dock = popup.getByRole("button", { name: "Show in Documentation Tool Window" });
|
||||
await expect(dock).toBeVisible();
|
||||
const bounds = (await popup.boundingBox())!;
|
||||
expect(bounds.width).toBeGreaterThanOrEqual(298);
|
||||
expect(bounds.width).toBeLessThan(320);
|
||||
const backBounds = (await back.boundingBox())!;
|
||||
const dockBounds = (await dock.boundingBox())!;
|
||||
expect(backBounds.x).toBeGreaterThan(bounds.x + bounds.width / 2);
|
||||
expect(bounds.x + bounds.width - dockBounds.x - dockBounds.width).toBeLessThan(16);
|
||||
await expect(popup.locator(".cm-lsp-markdown")).toHaveCSS("font-size", "13px");
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(popup).toBeHidden();
|
||||
});
|
||||
|
||||
test("long quick documentation scrolls with its actions in view", async ({ workbench: page }) => {
|
||||
const signature = "fun calculateTotal(order: Order, options: ExtendedPricingOptions): CalculationResult";
|
||||
const markdown = [
|
||||
`\`\`\`kotlin\n${signature}\n\`\`\``,
|
||||
...Array.from({ length: 22 }, (_, i) => {
|
||||
return `Section ${i + 1}. Explains the applicable pricing rules, shipping restrictions and currency options.`;
|
||||
}),
|
||||
"End of pricing documentation.",
|
||||
].join("\n\n");
|
||||
const popup = await quickDocumentation(page, markdown);
|
||||
const dock = popup.getByRole("button", { name: "Show in Documentation Tool Window" });
|
||||
await expect(dock).toBeVisible();
|
||||
expect((await popup.boundingBox())!.width).toBeLessThan(508);
|
||||
await page.setViewportSize({ width: 430, height: 500 });
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const box = (await popup.boundingBox())!;
|
||||
return Math.max(-box.x, -box.y, box.x + box.width - 430, box.y + box.height - 500);
|
||||
})
|
||||
.toBeLessThanOrEqual(1);
|
||||
const body = popup.locator(".cm-lsp-markdown").locator("..");
|
||||
const last = popup.getByText("End of pricing documentation.");
|
||||
const dockBefore = (await dock.boundingBox())!;
|
||||
await expect(body.locator("pre")).toContainText(signature);
|
||||
const scroll = await body.evaluate((node) => {
|
||||
node.scrollTop = node.scrollHeight;
|
||||
return { top: node.scrollTop, horizontalOverflow: node.scrollWidth - node.clientWidth };
|
||||
});
|
||||
expect(scroll.top).toBeGreaterThan(0);
|
||||
expect(scroll.horizontalOverflow).toBeLessThanOrEqual(1);
|
||||
const lastBounds = (await last.boundingBox())!;
|
||||
expect(lastBounds.y + lastBounds.height).toBeLessThanOrEqual(dockBefore.y + 1);
|
||||
expect(await dock.boundingBox()).toEqual(dockBefore);
|
||||
await expect(dock).toBeInViewport();
|
||||
});
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
async function openConfigurations(page: Page) {
|
||||
await page.evaluate(async () => {
|
||||
async function openConfigurations(page: Page, target?: string) {
|
||||
await page.evaluate(async (target) => {
|
||||
const path = "/src/features/run/store.ts";
|
||||
const { useRun } = await import(/* @vite-ignore */ path);
|
||||
const base = {
|
||||
@@ -21,6 +21,7 @@ async function openConfigurations(page: Page) {
|
||||
...base,
|
||||
id: "layout:app",
|
||||
name: "Payments development server",
|
||||
target,
|
||||
beforeLaunch: [{ kind: "run", target: "layout:prepare" }],
|
||||
},
|
||||
{ ...base, id: "layout:prepare", name: "Prepare generated sources for the payments development server" },
|
||||
@@ -29,10 +30,31 @@ async function openConfigurations(page: Page) {
|
||||
loaded: true,
|
||||
editorOpen: true,
|
||||
});
|
||||
});
|
||||
}, target);
|
||||
await expect(page.getByRole("dialog", { name: "Run/Debug Configurations", exact: true })).toBeVisible();
|
||||
}
|
||||
|
||||
test("long run target names leave room for configuration names in the sidebar", async ({ workbench: page }) => {
|
||||
const target = "payments-development-shared-staging-runner-west";
|
||||
await openConfigurations(page, target);
|
||||
const dialog = page.getByRole("dialog", { name: "Run/Debug Configurations", exact: true });
|
||||
const tree = dialog.getByRole("tree", { name: "Run configurations", exact: true });
|
||||
const row = tree.getByRole("treeitem", { name: /^Payments development server/ });
|
||||
const name = row.getByText("Payments development server", { exact: true });
|
||||
const badge = row.getByText(`@ ${target}`, { exact: true });
|
||||
await expect(badge).toBeVisible();
|
||||
|
||||
for (const width of [1100, 520]) {
|
||||
await page.setViewportSize({ width, height: 820 });
|
||||
await expect.poll(async () => (await name.boundingBox())!.width).toBeGreaterThan(width === 1100 ? 80 : 50);
|
||||
await expect.poll(() => tree.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
||||
}
|
||||
|
||||
await expect(badge).toBeHidden();
|
||||
await expect(row).toHaveAttribute("title", new RegExp(`Payments development server @ ${target}`));
|
||||
await expect(dialog.getByRole("textbox", { name: "Name", exact: true })).toHaveValue("Payments development server");
|
||||
});
|
||||
|
||||
test("run configuration sidebar resizes with mouse and keyboard and remembers the layout", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
|
||||
@@ -60,6 +60,70 @@ for (const { width, split } of [{ width: 220 }, { width: 280 }, { width: 520 },
|
||||
});
|
||||
}
|
||||
|
||||
test("wide terminal search leaves the grid in place and avoids covering the active match", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.evaluate(async () => {
|
||||
const path = "/src/workbench/toolwindows/store.ts";
|
||||
const layout = await import(path);
|
||||
layout.setToolWindowSize("bottom", 280);
|
||||
layout.showToolWindow("terminal", true);
|
||||
});
|
||||
const terminal = page.getByRole("region", { name: "Terminal", exact: true });
|
||||
await expect(terminal.locator(".xterm-helper-textarea")).toBeFocused();
|
||||
const panel = terminal.getByRole("tabpanel");
|
||||
const before = (await panel.boundingBox())!;
|
||||
await page.evaluate(async () => {
|
||||
const path = "/src/features/terminal/runtime.ts";
|
||||
const { activeSession } = await import(path);
|
||||
const { term } = activeSession();
|
||||
await new Promise<void>((resolve) =>
|
||||
term.write(`\x1b[2J\x1b[1;${term.cols - 16}Hright-edge\x1b[1;2Hleft-side\x1b[6;1H`, resolve),
|
||||
);
|
||||
});
|
||||
|
||||
await page.keyboard.press("Meta+f");
|
||||
const search = terminal.getByRole("search", { name: "Find in terminal" });
|
||||
const input = search.getByRole("textbox", { name: "Find in terminal" });
|
||||
await expect(input).toBeFocused();
|
||||
expect(await panel.boundingBox()).toEqual(before);
|
||||
const top = (await search.boundingBox())!;
|
||||
expect(top.y).toBeCloseTo(before.y, 0);
|
||||
expect(top.x + top.width).toBeCloseTo(before.x + before.width, 0);
|
||||
expect(top.width).toBeLessThan(before.width);
|
||||
|
||||
await input.fill("right-edge");
|
||||
await expect(search.locator("[aria-live=polite]")).toHaveText("1/1");
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const box = (await search.boundingBox())!;
|
||||
return box.y + box.height;
|
||||
})
|
||||
.toBeCloseTo(before.y + before.height, 0);
|
||||
await expect(input).toBeFocused();
|
||||
expect(await panel.boundingBox()).toEqual(before);
|
||||
|
||||
await input.fill("left-side");
|
||||
await expect(search.locator("[aria-live=polite]")).toHaveText("1/1");
|
||||
await expect.poll(async () => (await search.boundingBox())!.y).toBeCloseTo(before.y, 0);
|
||||
|
||||
await page.evaluate(async () => {
|
||||
const path = "/src/workbench/toolwindows/store.ts";
|
||||
const { setToolWindowSize } = await import(path);
|
||||
setToolWindowSize("bottom", 130);
|
||||
});
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const box = (await search.boundingBox())!;
|
||||
return box.y + box.height - (await panel.boundingBox())!.y;
|
||||
})
|
||||
.toBeCloseTo(0, 0);
|
||||
await expect(input).toHaveValue("left-side");
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(search).toBeHidden();
|
||||
await expect(terminal.locator(".xterm-helper-textarea")).toBeFocused();
|
||||
});
|
||||
|
||||
test("terminal highlights visible occurrences of selected text in a single overlay layer", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
|
||||
Reference in new issue
Заблокувати користувача