Файли
openidea/e2e/moduleSourcesLayout.spec.ts
T
l0ng-ai ec0370ec23 fix(settings): fit Module Sources to the available width (#4953)
Put the folder tree and marked roots in a resizable split in Project Structure › Modules › Sources. The panels stack when the available width is too small for a side-by-side layout. The summary shows populated root groups and uses the 13 px workbench font for folder paths.
2026-11-21 12:58:16 +08:00

53 рядки
3.0 KiB
TypeScript

import { expect, ipcCalls, stubDesktop, test } from "./fixtures";
test("Module Sources fits in a narrow dialog and keeps marking folders after resizing", async ({ workbench: page }) => {
await page.setViewportSize({ width: 1200, height: 820 });
await stubDesktop(page);
await page.evaluate(async () => {
const project = "/src/platform/project.ts";
const { useProject } = await import(/* @vite-ignore */ project);
const root = useProject.getState().project!.root;
const settings = { ...useProject.getState().settings, projectStructure: { sourceRoots: ["src"] } };
useProject.setState({ settings });
const handlers = window.__ipc.handlers;
handlers.fs_read_dir = ({ path }) =>
path === root ? ["src", "audit-fixtures"].map((name) => ({ name, path: `${root}/${name}`, kind: "dir" })) : [];
handlers.settings_get_global = () => settings;
handlers.settings_set = () => settings;
const actions = "/src/platform/actions.ts";
await (await import(/* @vite-ignore */ actions)).executeAction("file.projectStructure", "modules");
});
const dialog = page.getByRole("dialog", { name: "Project Structure" });
const tree = dialog.getByRole("tree", { name: "Content root" });
const marked = dialog.getByRole("region", { name: "Marked folders" });
const divider = dialog.getByRole("separator", { name: "Marked folders" });
await expect(divider).toHaveAttribute("aria-orientation", "vertical");
await expect(marked.getByText("Source Folders")).toBeVisible();
await expect(marked.getByText("Test Source Folders")).toHaveCount(0);
const width = (await tree.boundingBox())!.width;
await divider.press("ArrowRight");
await expect.poll(async () => (await tree.boundingBox())!.width).toBeGreaterThan(width + 4);
const folder = tree.getByRole("treeitem", { name: "audit-fixtures", exact: true });
await folder.click();
await page.setViewportSize({ width: 640, height: 720 });
await expect(divider).toHaveAttribute("aria-orientation", "horizontal");
await expect(folder).toHaveAttribute("aria-selected", "true");
const content = dialog.locator("[class*='psDialogBody']");
expect(await content.evaluate((element) => element.scrollWidth)).toBe(
await content.evaluate((element) => element.clientWidth),
);
expect((await marked.boundingBox())!.y).toBeGreaterThan((await tree.boundingBox())!.y);
await dialog.getByRole("toolbar", { name: "Mark as" }).getByRole("button", { name: "Tests", exact: true }).click();
await expect(marked.getByText("Test Source Folders")).toBeVisible();
await expect(marked.getByText("audit-fixtures", { exact: true })).toHaveCSS("font-size", "13px");
await expect(marked.getByRole("button", { name: "Unmark audit-fixtures", exact: true })).toBeVisible();
expect(await ipcCalls(page, "settings_set")).toEqual([]);
await dialog.getByRole("button", { name: "Apply", exact: true }).click();
await expect
.poll(() => ipcCalls(page, "settings_set"))
.toMatchObject([{ key: "projectStructure.testRoots", value: '["audit-fixtures"]' }]);
});