дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 17:21:13 +02:00
The Settings window's title bar was 8px taller than the platform dialog, the search field, breadcrumb and content sat a few pixels off, the tree drew 12px chevrons, untitled sections were indented away from the group titles, checkbox rows were 26px apart and the button bar had no separator. The window is now titled "Settings – <project>", uses a 32px dialog title bar on macOS (--h-dialog-titlebar), 16px tree chevrons, 22px group and indent insets, 11/16/16/16 content padding, field-height checkbox rows and a hairline above the buttons. Also types the label/box pairs of the Appearance e2e check. Closes #7817 Co-authored-by: wildcatDownstairs <[email protected]>
221 рядки
11 KiB
TypeScript
221 рядки
11 KiB
TypeScript
import type { Page } from "@playwright/test";
|
|
import { expect, test } from "./fixtures";
|
|
|
|
async function selectPage(page: Page, id: string) {
|
|
await page.evaluate(async (id) => {
|
|
const path = "/src/features/settings/model/staging.ts";
|
|
(await import(/* @vite-ignore */ path)).selectPage(id);
|
|
}, id);
|
|
}
|
|
|
|
test("Git settings expose fetch tag modes and the check-only mode", async ({ workbench: page }, testInfo) => {
|
|
await page.keyboard.press("Meta+,");
|
|
const dialog = page.getByRole("dialog", { name: "Settings", exact: true });
|
|
await expect(dialog).toBeVisible();
|
|
await selectPage(page, "vcs.git");
|
|
const mode = dialog.getByRole("button", { name: "Fetch tags", exact: true });
|
|
await expect(mode).toHaveText("Auto");
|
|
await mode.click();
|
|
const choices = page.getByRole("listbox");
|
|
for (const label of ["Auto", "Sync", "Always", "Never"]) {
|
|
await expect(choices.getByRole("option", { name: new RegExp(`^${label}`) })).toBeVisible();
|
|
}
|
|
const starts = await choices
|
|
.getByRole("option")
|
|
.evaluateAll((rows) =>
|
|
rows.map((row) => row.querySelectorAll<HTMLElement>("[title]")[1]!.getBoundingClientRect().left),
|
|
);
|
|
for (const start of starts) expect(start).toBeCloseTo(starts[0]!);
|
|
await choices.screenshot({ path: testInfo.outputPath("fetch-tags-descriptions.png") });
|
|
const sync = choices.getByRole("option", { name: /^Sync/ });
|
|
await expect(sync).toContainText("Delete local tags missing on remote");
|
|
await sync.click();
|
|
await expect(mode).toHaveText("Sync");
|
|
const incoming = dialog.getByRole("button", { name: "Explicitly check for incoming commits on remotes" });
|
|
await incoming.click();
|
|
await choices.getByRole("option", { name: "Check without fetching", exact: true }).click();
|
|
await expect(incoming).toHaveText("Check without fetching");
|
|
await expect(dialog.getByRole("button", { name: "Apply", exact: true })).toBeEnabled();
|
|
});
|
|
|
|
test("indented rows lay out their own columns and font metrics stay on one row", async ({ workbench: page }) => {
|
|
await page.keyboard.press("Meta+,");
|
|
const dialog = page.getByRole("dialog", { name: "Settings", exact: true });
|
|
await expect(dialog).toBeVisible();
|
|
await selectPage(page, "appearance");
|
|
// IDEA's AppearanceConfigurable puts the Theme row in its own panel and the color scheme under
|
|
// `indent { }`, so each combo box follows its own label instead of sharing one column.
|
|
const [theme, scheme] = ["Theme", "Editor color scheme"].map((name) =>
|
|
dialog.getByRole("button", { name, exact: true }),
|
|
);
|
|
await expect(scheme!).toBeVisible();
|
|
const [themeLabel, schemeLabel] = await Promise.all(
|
|
["Theme", "Editor color scheme"].map((name) =>
|
|
dialog.locator("label").getByText(name, { exact: true }).first().boundingBox(),
|
|
),
|
|
);
|
|
const [themeBox, schemeBox] = await Promise.all([theme!.boundingBox(), scheme!.boundingBox()]);
|
|
for (const [label, box] of [
|
|
[themeLabel!, themeBox!],
|
|
[schemeLabel!, schemeBox!],
|
|
] as const)
|
|
expect(box.x - (label.x + label.width)).toBeLessThan(16);
|
|
expect(themeBox!.x).toBeLessThan(schemeBox!.x);
|
|
|
|
await selectPage(page, "editor.font");
|
|
const font = dialog.getByRole("combobox", { name: "Font", exact: true });
|
|
const size = dialog.getByRole("textbox", { name: "Size", exact: true });
|
|
const line = dialog.getByRole("textbox", { name: "Line height", exact: true });
|
|
await expect(line).toBeVisible();
|
|
const [fontBox, sizeBox, lineBox] = await Promise.all([font.boundingBox(), size.boundingBox(), line.boundingBox()]);
|
|
expect(fontBox!.x).toBeCloseTo(sizeBox!.x, 0);
|
|
expect(lineBox!.y).toBeCloseTo(sizeBox!.y, 0);
|
|
expect(lineBox!.x).toBeGreaterThan(sizeBox!.x + sizeBox!.width);
|
|
const weights = await Promise.all(
|
|
["Main font weight", "Bold font weight"].map((name) =>
|
|
dialog.getByRole("button", { name, exact: true }).boundingBox(),
|
|
),
|
|
);
|
|
const fallback = await dialog.getByRole("combobox", { name: "Fallback font", exact: true }).boundingBox();
|
|
for (const box of weights) expect(box!.x).toBeCloseTo(fallback!.x, 0);
|
|
for (const name of ["Main font weight", "Bold font weight", "Fallback font"]) {
|
|
const singleLine = await dialog.getByText(name, { exact: true }).evaluate((el) => {
|
|
const range = document.createRange();
|
|
range.selectNodeContents(el);
|
|
return range.getBoundingClientRect().height <= Number.parseFloat(getComputedStyle(el).lineHeight) + 1;
|
|
});
|
|
expect(singleLine, name).toBe(true);
|
|
}
|
|
});
|
|
|
|
test("toolchain, encoding and Subversion settings align field frames across sections", async ({ workbench: page }) => {
|
|
await page.keyboard.press("Meta+,");
|
|
const body = page.getByRole("dialog", { name: "Settings", exact: true }).locator("[class*='pageBody']");
|
|
for (const [id, title, count] of [
|
|
["languages.go", "Go", 2],
|
|
["languages.java", "Java", 4],
|
|
["languages.rust", "Rust", 4],
|
|
["languages.node", "JavaScript Runtime", 4],
|
|
["languages.php", "PHP", 4],
|
|
["build.maven", "Maven", 8],
|
|
["editor.fileEncodings", "File Encodings", 4],
|
|
["vcs.svn", "Subversion", 2],
|
|
] as const) {
|
|
await selectPage(page, id);
|
|
await expect(page.getByLabel("Breadcrumb").locator('[aria-current="page"]')).toHaveText(title);
|
|
if (id === "vcs.svn") {
|
|
await body.getByRole("checkbox", { name: "Use custom configuration directory" }).check();
|
|
await expect(body.getByRole("textbox", { name: /Configuration directory/ })).toBeEnabled();
|
|
}
|
|
const fields = body
|
|
.getByRole("button")
|
|
.and(body.locator("[aria-haspopup='listbox']"))
|
|
.or(body.getByRole("textbox"))
|
|
.or(body.getByRole("combobox"))
|
|
.and(body.locator(':not([aria-label="Thread count"])'));
|
|
await expect(fields).toHaveCount(count);
|
|
for (const width of [1200, 800, 520]) {
|
|
await page.setViewportSize({ width, height: 800 });
|
|
for (const group of [fields, body.getByRole("button", { name: "Browse…", exact: true })]) {
|
|
const edges = await group.evaluateAll((elements) =>
|
|
elements.map((element) => {
|
|
const { left, right } = element.getBoundingClientRect();
|
|
return [Math.round(left), Math.round(right)];
|
|
}),
|
|
);
|
|
for (const edge of edges.slice(1)) expect(edge, `${id} at ${width}px`).toEqual(edges[0]);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
for (const locale of ["en", "zh"]) {
|
|
test(`${locale} forms fit narrow settings panes without horizontal scrolling`, async ({ workbench: page }) => {
|
|
await page.keyboard.press("Meta+,");
|
|
await expect(page.getByRole("dialog", { name: "Settings", exact: true })).toBeVisible();
|
|
await page.evaluate(async (locale) => {
|
|
const path = "/src/platform/i18n.ts";
|
|
await (await import(/* @vite-ignore */ path)).setLocale(locale);
|
|
}, locale);
|
|
for (const id of ["appearance", "editor.font", "general", "general.httpProxy", "vcs.log"]) {
|
|
await selectPage(page, id);
|
|
const body = page.locator("[class*='pageBody']");
|
|
for (const width of [1000, 784, 640, 520]) {
|
|
await page.setViewportSize({ width, height: 760 });
|
|
await expect
|
|
.poll(() => body.evaluate((el) => el.scrollWidth - el.clientWidth), { message: `${id} at ${width}px` })
|
|
.toBeLessThanOrEqual(1);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
test("keeps Open project in options within narrow System Settings", async ({ workbench: page }) => {
|
|
await page.keyboard.press("Meta+,");
|
|
const dialog = page.getByRole("dialog", { name: "Settings", exact: true });
|
|
await expect(dialog).toBeVisible();
|
|
await selectPage(page, "general");
|
|
const group = dialog.getByRole("radiogroup", { name: "Open project in", exact: true });
|
|
const longest = group.getByRole("radio", { name: "New tab in current window", exact: true });
|
|
await expect(longest).toBeVisible();
|
|
await page.setViewportSize({ width: 520, height: 760 });
|
|
const overflow = await longest.evaluate(async (radio) => {
|
|
await new Promise<void>((resolve) => requestAnimationFrame(() => requestAnimationFrame(() => resolve())));
|
|
const label = radio.closest("label")!;
|
|
const group = radio.closest('[role="radiogroup"]')!;
|
|
const text = document.createRange();
|
|
text.selectNodeContents(label);
|
|
return text.getBoundingClientRect().right - group.getBoundingClientRect().right;
|
|
});
|
|
expect(overflow).toBeLessThanOrEqual(1);
|
|
});
|
|
|
|
test("Git Log settings group display and column options with aligned checkboxes", async ({ workbench: page }) => {
|
|
await page.keyboard.press("Meta+,");
|
|
const dialog = page.getByRole("dialog", { name: "Settings", exact: true });
|
|
await selectPage(page, "vcs.log");
|
|
const view = dialog.getByRole("region", { name: "View Options" });
|
|
const columns = dialog.getByRole("region", { name: "Visible columns" });
|
|
const tagNames = view.getByRole("checkbox", { name: "Show tag names" });
|
|
const hash = columns.getByRole("checkbox", { name: "Hash" });
|
|
await expect(view.getByRole("checkbox")).toHaveCount(4);
|
|
await expect(columns.getByRole("checkbox")).toHaveCount(4);
|
|
|
|
for (const width of [1000, 520]) {
|
|
await page.setViewportSize({ width, height: 760 });
|
|
// Read both rows together once the dialog has finished opening and relaid out.
|
|
await expect
|
|
.poll(async () => Math.abs((await tagNames.boundingBox())!.x - (await hash.boundingBox())!.x))
|
|
.toBeLessThan(0.5);
|
|
}
|
|
|
|
await expect(hash).not.toBeChecked();
|
|
await hash.focus();
|
|
await page.keyboard.press("Space");
|
|
await expect(hash).toBeChecked();
|
|
});
|
|
|
|
test("settings sidebar resizes with mouse and keyboard and remembers its width", async ({ workbench: page }) => {
|
|
await page.keyboard.press("Meta+,");
|
|
const dialog = page.getByRole("dialog", { name: "Settings", exact: true });
|
|
const handle = dialog.getByRole("separator", { name: "Settings pages", exact: true });
|
|
await expect(handle).toBeVisible();
|
|
const sidebar = dialog.locator("#navigation");
|
|
const initial = (await sidebar.boundingBox())!.width;
|
|
expect(initial / (await dialog.getByTestId("settings").boundingBox())!.width).toBeCloseTo(0.225, 2);
|
|
const box = (await handle.boundingBox())!;
|
|
await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2);
|
|
await page.mouse.down();
|
|
await page.mouse.move(box.x + 60, box.y + box.height / 2);
|
|
await page.mouse.up();
|
|
await expect.poll(async () => (await sidebar.boundingBox())!.width).toBeGreaterThan(initial + 40);
|
|
const resized = (await sidebar.boundingBox())!.width;
|
|
await dialog.getByRole("button", { name: "Cancel", exact: true }).click();
|
|
await page.keyboard.press("Meta+,");
|
|
await expect(handle).toBeVisible();
|
|
await expect.poll(async () => (await sidebar.boundingBox())!.width).toBeCloseTo(resized, 0);
|
|
await handle.focus();
|
|
await page.keyboard.press("ArrowLeft");
|
|
await expect.poll(async () => (await sidebar.boundingBox())!.width).toBeLessThan(resized);
|
|
});
|