Файли
openidea/e2e/copyPathLayout.spec.ts
T
l0ng-ai 83b14b4329 feat(project): Copy Path/Reference… in the Project view opens the previewing chooser (#6242)
The Project view's Copy Path/Reference... opened a submenu of names only. It
now opens the editor's chooser at the menu's position, previewing what each
row copies for the selection (several paths one per line): absolute path,
file name, path from content root and source root, plus the contributed rows
(repository path, remote link, agent reference). The chooser is provided to
@/editor/api by editor/core, so the API module stays free of popup imports.

Fixes #6032
2026-11-27 03:37:15 +08:00

60 рядки
3.0 KiB
TypeScript

import { expect, openFromTree, test } from "./fixtures";
test("Copy Path/Reference keeps its preview and shortcut visible and can be resized", async ({
workbench: page,
context,
}) => {
await context.grantPermissions(["clipboard-read", "clipboard-write"]);
const editor = await openFromTree(page, "build.gradle.kts");
await editor.locator(".cm-content").press("Meta+Shift+C");
const popup = page.getByRole("dialog", { name: "Copy Path/Reference…" });
const absolute = popup.getByRole("option", { name: /^Absolute Path(?! with)/ });
const preview = absolute.locator('[title$="/build.gradle.kts"]');
const shortcut = absolute.getByText(/⌘/);
await expect(preview).toBeVisible();
await expect(popup).toHaveCSS("width", "500px");
await expect(shortcut).toBeVisible();
const previewBox = (await preview.boundingBox())!;
const shortcutBox = (await shortcut.boundingBox())!;
expect(shortcutBox.x + shortcutBox.width).toBeLessThan(previewBox.x);
await expect(preview).toHaveCSS("font-size", "13px");
const handle = popup.getByRole("separator", { name: "Resize" });
const height = (await popup.boundingBox())!.height;
const corner = (await handle.boundingBox())!;
await page.mouse.move(corner.x + corner.width / 2, corner.y + corner.height / 2);
await page.mouse.down();
await page.mouse.move(corner.x + 125, corner.y + 25, { steps: 5 });
await page.mouse.up();
await expect.poll(async () => (await popup.boundingBox())!.width).toBeGreaterThan(595);
await expect.poll(async () => (await popup.boundingBox())!.height).toBeGreaterThan(height + 10);
await page.setViewportSize({ width: 440, height: 660 });
await expect(popup).toBeInViewport({ ratio: 1 });
await expect(shortcut).toBeInViewport({ ratio: 1 });
await expect(preview).toBeInViewport({ ratio: 1 });
const path = await preview.getAttribute("title");
await page.keyboard.type("absolute");
await expect(absolute).toHaveAttribute("aria-selected", "true");
await page.keyboard.press("Enter");
await expect(popup).toBeHidden();
await expect.poll(() => page.evaluate(() => navigator.clipboard.readText())).toBe(path);
});
test("Copy Path/Reference… in the Project view previews what each row copies", async ({ workbench: page, context }) => {
await context.grantPermissions(["clipboard-read", "clipboard-write"]);
await page.getByRole("treeitem", { name: "build.gradle.kts" }).click({ button: "right" });
await page.getByRole("menuitem", { name: "Copy Path/Reference…" }).click();
const popup = page.getByRole("dialog", { name: "Copy Path/Reference…" });
const name = popup.getByRole("option", { name: /^File Name/ });
await expect(name.locator('[title="build.gradle.kts"]')).toBeVisible();
await expect(popup.getByRole("option", { name: /^Path From Content Root/ })).toBeVisible();
await page.keyboard.type("file name");
await expect(name).toHaveAttribute("aria-selected", "true");
await page.keyboard.press("Enter");
await expect(popup).toBeHidden();
await expect.poll(() => page.evaluate(() => navigator.clipboard.readText())).toBe("build.gradle.kts");
});