Files
openidea/e2e/compactSettingsControls.spec.ts
T
Vladislav Kuzmin 461c71a50b test(settings): measure notification labels in the group list (#4892)
#4810 replaced the notification group table with a listbox, and the compact settings test still waited for a table cell, so it timed out before measuring anything. It now measures the group labels inside the listbox.

Fixes #4891

Co-authored-by: principalwater <67874880+principalwater@users.noreply.github.com>

Co-authored-by: principalwater <67874880+principalwater@users.noreply.github.com>
2026-11-21 06:55:23 +08:00

60 lines
2.6 KiB
TypeScript

import { expect, test } from "./fixtures";
for (const [id, selector] of [
["general", "[class*='radios'] label"],
["notifications", "[role='listbox'] [role='option'] > [class*='notificationGroupLabel']"],
["keymap", "[class*='presetLabel']"],
["editor.inspections", "[class*='profileControls'] > span:first-child"],
["vcs.issueNavigation", "[class*='pageBody'] button:not([aria-label])"],
] as const) {
test(`${id} keeps compact labels inside their controls`, async ({ workbench: page }) => {
await page.keyboard.press("Meta+,");
const dialog = page.getByRole("dialog");
await expect(dialog).toBeVisible();
await page.evaluate(async (id) => {
const localePath = "/src/platform/i18n.ts";
await (await import(/* @vite-ignore */ localePath)).setLocale("zh");
const stagingPath = "/src/features/settings/model/staging.ts";
(await import(/* @vite-ignore */ stagingPath)).selectPage(id);
}, id);
const labels = dialog.locator(selector);
await expect(labels.first()).toBeVisible();
for (const width of [1000, 640, 520]) {
await page.setViewportSize({ width, height: 760 });
const fits = await labels.evaluateAll((labels) =>
labels.every((label) => {
const box = label.getBoundingClientRect();
const range = document.createRange();
range.selectNodeContents(label);
const lines = [...range.getClientRects()].filter((r) => r.width > 0 && r.height > 0);
return (
lines.every((r) => r.left >= box.left - 1 && r.right <= box.right + 1 && r.height <= 24) &&
Math.max(...lines.map((r) => r.bottom)) - Math.min(...lines.map((r) => r.top)) <= 24
);
}),
);
expect(fits).toBe(true);
}
});
}
for (const [id, selector] of [
["general", "[class*='fontRow'] > label"],
["build.console", "[class*='inlineRow'] > label"],
] as const) {
test(`${id} keeps a readable width for inline text`, async ({ workbench: page }) => {
await page.keyboard.press("Meta+,");
await expect(page.getByRole("dialog", { name: "Settings", exact: true })).toBeVisible();
await page.evaluate(async (id) => {
const localePath = "/src/platform/i18n.ts";
await (await import(/* @vite-ignore */ localePath)).setLocale("zh");
const path = "/src/features/settings/model/staging.ts";
(await import(/* @vite-ignore */ path)).selectPage(id);
}, id);
const text = page.locator(selector).first();
await expect(text).toBeVisible();
await page.setViewportSize({ width: 520, height: 760 });
expect((await text.boundingBox())!.width).toBeGreaterThan(100);
});
}