дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-03 16:51:16 +02:00
The Bookmarks tool window tree starts collapsed and expands just enough to reveal a newly added bookmark. Expansion state is kept per tree, and a bookmark replaced by an edit is not treated as new. Co-authored-by: solhovoy <[email protected]>
93 рядки
4.7 KiB
TypeScript
93 рядки
4.7 KiB
TypeScript
import { expect, test } from "./fixtures";
|
|
|
|
test("line bookmarks keep their code or description readable in the dock", async ({ workbench: page }) => {
|
|
await page.setViewportSize({ width: 880, height: 640 });
|
|
const name = "QuarterlySettlementReconciliationCoordinator.ts";
|
|
const path = `/dev/acme-api/${name}`;
|
|
const code = "reconcileCheckoutOrders();";
|
|
const description = "Review settlement totals";
|
|
await page.evaluate(
|
|
async ({ path, code }) => {
|
|
const backendModule = "/src/editor/core/backend.ts";
|
|
const { docBackend } = await import(/* @vite-ignore */ backendModule);
|
|
docBackend().files.set(path, [...Array(27).fill("// Settlement rules"), code, "verifyTotals();", ""].join("\n"));
|
|
const services = "/src/workbench/contributions.ts";
|
|
const { editorService } = await import(/* @vite-ignore */ services);
|
|
await editorService().openFile(path);
|
|
},
|
|
{ path, code },
|
|
);
|
|
await expect(page.locator(".cm-content")).toContainText(code);
|
|
await page.evaluate(
|
|
async ({ path, description }) => {
|
|
const actionsModule = "/src/platform/actions.ts";
|
|
const { executeAction } = await import(/* @vite-ignore */ actionsModule);
|
|
await executeAction("navigate.toggleBookmark", { path, line: 27 });
|
|
await executeAction("navigate.toggleBookmark", { path, line: 29 });
|
|
const bookmarkModule = "/src/features/search/bookmarks/store.ts";
|
|
const { assignMnemonic, updateBookmarks } = await import(/* @vite-ignore */ bookmarkModule);
|
|
updateBookmarks((items: unknown[]) => assignMnemonic(items, path, 28, "verifyTotals();", "4", description));
|
|
await executeAction("toolwindow.bookmarks");
|
|
const layoutModule = "/src/workbench/toolwindows/store.ts";
|
|
const { setToolWindowSize } = await import(/* @vite-ignore */ layoutModule);
|
|
setToolWindowSize("left", 240);
|
|
},
|
|
{ path, description },
|
|
);
|
|
|
|
const tree = page.getByRole("tree", { name: "Bookmarks" });
|
|
await page.getByRole("button", { name: "Expand All", exact: true }).click();
|
|
await expect(tree.getByText(name, { exact: true })).toBeVisible();
|
|
const snippet = tree.getByText(code, { exact: true });
|
|
await expect.poll(() => snippet.evaluate((el) => el.clientWidth)).toBeGreaterThanOrEqual(105);
|
|
await expect(tree.getByText("28:", { exact: true })).toBeVisible();
|
|
await expect(tree.getByText("29:", { exact: true })).toBeVisible();
|
|
await expect(tree.getByText(description, { exact: true })).toBeVisible();
|
|
await expect(tree.getByText("(empty line)", { exact: true })).toBeVisible();
|
|
expect(await tree.evaluate((el) => el.scrollWidth - el.clientWidth)).toBe(0);
|
|
|
|
const row = tree.getByRole("treeitem").filter({ hasText: code });
|
|
await row.click();
|
|
await page.keyboard.press("Enter");
|
|
await expect
|
|
.poll(() =>
|
|
page.evaluate(async () => {
|
|
const module = "/src/workbench/contributions.ts";
|
|
const { editorService } = await import(/* @vite-ignore */ module);
|
|
const cursor = editorService().activeCursor();
|
|
return { path: cursor?.path, line: cursor?.line };
|
|
}),
|
|
)
|
|
.toEqual({ path, line: 27 });
|
|
});
|
|
|
|
test("selecting a bookmark shows its code in the preview below the side-docked Bookmarks tree", async ({
|
|
workbench: page,
|
|
}) => {
|
|
const path = "/dev/acme-api/PreviewBookmark.ts";
|
|
await page.evaluate(async (path) => {
|
|
const backend = "/src/editor/core/backend.ts";
|
|
const { docBackend } = await import(/* @vite-ignore */ backend);
|
|
docBackend().files.set(path, "const previewBookmark = true;");
|
|
const store = "/src/features/search/bookmarks/store.ts";
|
|
const { updateBookmarks, toggleBookmark } = await import(/* @vite-ignore */ store);
|
|
updateBookmarks((items: unknown[]) => toggleBookmark(items, path, 0, "const previewBookmark = true;"));
|
|
const actions = "/src/platform/actions.ts";
|
|
await (await import(/* @vite-ignore */ actions)).executeAction("toolwindow.bookmarks");
|
|
}, path);
|
|
|
|
const previewButton = page.getByRole("button", { name: "Editor Preview" });
|
|
if ((await previewButton.getAttribute("aria-pressed")) !== "true") await previewButton.click();
|
|
const tree = page.getByRole("tree", { name: "Bookmarks" });
|
|
await page.getByRole("button", { name: "Expand All", exact: true }).click();
|
|
await tree.getByRole("treeitem", { name: /const previewBookmark/ }).click();
|
|
const preview = page.locator("#bookmarks-preview");
|
|
await expect(preview).toBeVisible();
|
|
const treeBounds = await tree.boundingBox();
|
|
const previewBounds = await preview.boundingBox();
|
|
expect(treeBounds).not.toBeNull();
|
|
expect(previewBounds).not.toBeNull();
|
|
expect(previewBounds!.y).toBeGreaterThanOrEqual(treeBounds!.y + treeBounds!.height);
|
|
await expect(preview.locator(".cm-content")).toContainText("const previewBookmark = true;");
|
|
});
|