дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 09:11:10 +02:00
Main toolbar items get a 10px pitch and the dropdowns 10/6px insets with a 16px chevron; stripe buttons get 5px padding on both sides; the status bar is 34px with 4px widget hover insets, its breadcrumbs lifted 5px, and the islands keep a 3px inset above it. Language Services moves after the caret position in the status bar. Compact mode keeps its previous metrics. Fixed-viewport e2e layouts (commit checks, project tree second click, main toolbar label compression next to the New Agent Task button) get room for the wider gaps and the taller status bar. Co-authored-by: wildcatDownstairs <[email protected]>
223 рядки
9.6 KiB
TypeScript
223 рядки
9.6 KiB
TypeScript
import { expect, openFromTree, test } from "./fixtures";
|
|
|
|
test("Customize Main Toolbar keeps layout actions above the groups and stacks them in a narrow window", async ({
|
|
workbench: page,
|
|
}) => {
|
|
const open = () =>
|
|
page.evaluate(async () => {
|
|
const path = "/src/platform/actions.ts";
|
|
await (await import(/* @vite-ignore */ path)).executeAction("toolbar.customize");
|
|
});
|
|
await open();
|
|
const dialog = page.getByRole("dialog", { name: "Customize Main Toolbar", exact: true });
|
|
const left = dialog.getByRole("listbox", { name: "Left group" });
|
|
const center = dialog.getByRole("listbox", { name: "Center group" });
|
|
const right = dialog.getByRole("listbox", { name: "Right group" });
|
|
const add = dialog.getByRole("button", { name: "Add…", exact: true });
|
|
const restore = dialog.getByRole("button", { name: "Restore Defaults", exact: true });
|
|
await expect(left).toBeFocused();
|
|
|
|
for (const width of [1120, 460]) {
|
|
await page.setViewportSize({ width, height: 620 });
|
|
await expect(async () => {
|
|
const [addBox, restoreBox, leftBox, centerBox, rightBox] = await Promise.all(
|
|
[add, restore, left, center, right].map((el) => el.boundingBox()),
|
|
);
|
|
expect(addBox!.y + addBox!.height).toBeLessThan(leftBox!.y);
|
|
expect(restoreBox!.y).toBe(addBox!.y);
|
|
if (width === 1120) {
|
|
expect(centerBox!.y).toBe(leftBox!.y);
|
|
expect(rightBox!.y).toBe(leftBox!.y);
|
|
expect(centerBox!.x).toBeGreaterThan(leftBox!.x + leftBox!.width);
|
|
expect(rightBox!.x).toBeGreaterThan(centerBox!.x + centerBox!.width);
|
|
} else {
|
|
expect(centerBox!.y).toBeGreaterThan(leftBox!.y + leftBox!.height);
|
|
expect(rightBox!.y).toBeGreaterThan(centerBox!.y + centerBox!.height);
|
|
expect(rightBox!.width).toBe(leftBox!.width);
|
|
}
|
|
}).toPass({ timeout: 3000 });
|
|
}
|
|
|
|
const actions = dialog.getByRole("toolbar", { name: "Toolbar actions" });
|
|
const project = (group: typeof left) => group.getByRole("option", { name: "Project Widget", exact: true });
|
|
await expect(project(left)).toHaveAttribute("aria-selected", "true");
|
|
await actions.getByRole("button", { name: "Move Down" }).click();
|
|
await expect(left.getByRole("option").nth(1)).toHaveText("Project Widget");
|
|
// Left has nothing further left; the arrows step through Center to Right and back.
|
|
await expect(actions.getByRole("button", { name: "Move to Left" })).toBeDisabled();
|
|
await actions.getByRole("button", { name: "Move to Center" }).click();
|
|
await expect(project(center)).toBeVisible();
|
|
await actions.getByRole("button", { name: "Move to Right" }).click();
|
|
await expect(project(right)).toBeVisible();
|
|
await expect(actions.getByRole("button", { name: "Move to Right" })).toBeDisabled();
|
|
await actions.getByRole("button", { name: "Remove", exact: true }).click();
|
|
await expect(project(right)).toHaveCount(0);
|
|
|
|
await add.click();
|
|
const search = dialog.getByRole("textbox", { name: "Search actions" });
|
|
await expect(search).toBeFocused();
|
|
await search.fill("Project Widget");
|
|
const available = dialog.getByRole("listbox", { name: "Actions and widgets to add" });
|
|
await available.getByRole("option", { name: /Project Widget/ }).click();
|
|
await expect(project(right)).toBeVisible();
|
|
await expect(search).toHaveCount(0);
|
|
|
|
await restore.click();
|
|
await expect(left.getByRole("option").first()).toHaveText("Project Widget");
|
|
await expect(project(right)).toHaveCount(0);
|
|
await dialog.getByRole("button", { name: "Cancel", exact: true }).click();
|
|
await expect(dialog).toBeHidden();
|
|
});
|
|
|
|
test("the Center group is centred in the main toolbar", async ({ workbench: page }) => {
|
|
const bar = page
|
|
.locator("header")
|
|
.filter({ has: page.locator("[data-toolbar-spacer]") })
|
|
.first();
|
|
await expect(bar.locator("[data-toolbar-center]")).toHaveCount(0);
|
|
await page.evaluate(async () => {
|
|
const path = "/src/platform/project.ts";
|
|
const { useProject } = await import(/* @vite-ignore */ path);
|
|
const settings = useProject.getState().settings;
|
|
useProject.setState({
|
|
settings: {
|
|
...settings,
|
|
appearance: {
|
|
...settings?.appearance,
|
|
mainToolbar: {
|
|
left: [],
|
|
center: ["project"],
|
|
right: ["action:navigate.searchEverywhere"],
|
|
hidden: ["agents.newTask"],
|
|
},
|
|
},
|
|
},
|
|
});
|
|
});
|
|
const group = bar.locator("[data-toolbar-center]");
|
|
await expect(group).toContainText("acme-api");
|
|
// 932: the narrow case where the group still fits between the fixed groups, which keep IDEA's
|
|
// 10px item gaps (MainToolbar.Icon.insets 6,5,4,5) and so need 6px more per gap than the old 4px.
|
|
for (const width of [1400, 932]) {
|
|
await page.setViewportSize({ width, height: 700 });
|
|
await expect(async () => {
|
|
const [barBox, groupBox] = await Promise.all([bar.boundingBox(), group.boundingBox()]);
|
|
const middle = groupBox!.x + groupBox!.width / 2;
|
|
expect(Math.abs(middle - (barBox!.x + barBox!.width / 2))).toBeLessThanOrEqual(1);
|
|
}).toPass({ timeout: 3000 });
|
|
}
|
|
// The old 900px width: no room to centre, so the group is pushed left of the right group, never over it.
|
|
await page.setViewportSize({ width: 900, height: 700 });
|
|
const rightGroup = bar.locator("[data-toolbar-center] ~ :not([data-toolbar-spacer])").first();
|
|
await expect(async () => {
|
|
const [barBox, groupBox, rightBox] = await Promise.all([
|
|
bar.boundingBox(),
|
|
group.boundingBox(),
|
|
rightGroup.boundingBox(),
|
|
]);
|
|
expect(groupBox!.x + groupBox!.width / 2).toBeLessThan(barBox!.x + barBox!.width / 2);
|
|
expect(groupBox!.x + groupBox!.width).toBeLessThanOrEqual(rightBox!.x);
|
|
}).toPass({ timeout: 3000 });
|
|
await page.screenshot({ path: "test-results/toolbar-center.png", animations: "disabled" });
|
|
});
|
|
|
|
test("the project colour gradient follows the Project widget", async ({ workbench: page }) => {
|
|
const frame = page.locator("[data-project-frame]");
|
|
const icon = page.locator("header [data-project-widget-icon]").first();
|
|
const anchor = () => frame.evaluate((el) => el.style.getPropertyValue("--project-gradient-x"));
|
|
const iconCenter = async () => {
|
|
const [frameBox, iconBox] = await Promise.all([frame.boundingBox(), icon.boundingBox()]);
|
|
return Math.round(iconBox!.x + iconBox!.width / 2 - frameBox!.x);
|
|
};
|
|
await expect(icon).toBeVisible();
|
|
await expect.poll(anchor).toBe(`${await iconCenter()}px`);
|
|
|
|
const layout = async (mainToolbar: object) =>
|
|
page.evaluate(async (mainToolbar) => {
|
|
const path = "/src/platform/project.ts";
|
|
const { useProject } = await import(/* @vite-ignore */ path);
|
|
const settings = useProject.getState().settings;
|
|
useProject.setState({ settings: { ...settings, appearance: { ...settings?.appearance, mainToolbar } } });
|
|
}, mainToolbar);
|
|
await layout({
|
|
left: [],
|
|
center: ["project"],
|
|
right: ["action:navigate.searchEverywhere"],
|
|
hidden: ["agents.newTask"],
|
|
});
|
|
for (const width of [1400, 900]) {
|
|
await page.setViewportSize({ width, height: 700 });
|
|
await expect(async () => {
|
|
const x = await iconCenter();
|
|
expect(Math.abs(x - width / 2)).toBeLessThan(150);
|
|
expect(await anchor()).toBe(`${x}px`);
|
|
}).toPass({ timeout: 3000 });
|
|
}
|
|
await page.screenshot({ path: "test-results/project-gradient-center.png", animations: "disabled" });
|
|
|
|
// Without the widget the gradient goes back to the frame's corner.
|
|
await layout({
|
|
left: [],
|
|
center: [],
|
|
right: ["action:navigate.searchEverywhere"],
|
|
hidden: ["project", "agents.newTask"],
|
|
});
|
|
await expect(icon).toHaveCount(0);
|
|
await expect.poll(anchor).toBe("");
|
|
});
|
|
|
|
test("main toolbar editor actions keep editor focus and run Collapse All / Expand All", async ({ workbench: page }) => {
|
|
const editor = await openFromTree(page, "App.tsx");
|
|
const content = editor.locator(".cm-content");
|
|
await content.click();
|
|
await page.keyboard.press("Meta+a");
|
|
await page.keyboard.insertText(
|
|
[
|
|
"export function formatOrder(total: number) {",
|
|
' const currency = "USD";',
|
|
" return currency + total.toFixed(2);",
|
|
"}",
|
|
].join("\n"),
|
|
);
|
|
await expect(content).toBeFocused();
|
|
|
|
await page.evaluate(async () => {
|
|
const path = "/src/platform/project.ts";
|
|
const { useProject } = await import(/* @vite-ignore */ path);
|
|
const settings = useProject.getState().settings;
|
|
useProject.setState({
|
|
settings: {
|
|
...settings,
|
|
appearance: {
|
|
...settings?.appearance,
|
|
mainToolbar: {
|
|
left: ["project"],
|
|
center: ["action:code.foldAll", "action:code.unfoldAll", "action:editor.nextTab"],
|
|
right: ["action:navigate.searchEverywhere"],
|
|
hidden: [],
|
|
},
|
|
},
|
|
},
|
|
});
|
|
});
|
|
|
|
const bar = page.locator("header").first();
|
|
await bar.getByRole("button", { name: "Collapse All", exact: true }).click({ delay: 80 });
|
|
await expect(editor.locator(".cm-foldPlaceholder")).toHaveCount(1);
|
|
await expect(content).toBeFocused();
|
|
|
|
await bar.getByRole("button", { name: "Expand All", exact: true }).click({ delay: 80 });
|
|
await expect(editor.locator(".cm-foldPlaceholder")).toHaveCount(0);
|
|
await expect(content).toBeFocused();
|
|
|
|
// With focus in a tool window, a toolbar click still leaves it so `!toolWindowFocus` actions run.
|
|
await openFromTree(page, "README.md");
|
|
const activeTab = page.locator("[role=tab][aria-selected=true]");
|
|
await expect(activeTab).toContainText("README.md");
|
|
const projectTree = page.getByRole("tree", { name: "Project" });
|
|
await projectTree.click();
|
|
await expect(projectTree).toBeFocused();
|
|
await bar.getByRole("button", { name: "Select Next Tab", exact: true }).click({ delay: 80 });
|
|
await expect(activeTab).toContainText("App.tsx");
|
|
});
|