дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 17:21:13 +02:00
#7048 exported the size loader only its own file uses, and its e2e test imported usages.ts from a literal path; knip reported both. Unexport the loader and import through a variable like the other spec in the file.
92 рядки
3.9 KiB
TypeScript
92 рядки
3.9 KiB
TypeScript
import { expect, test } from "./fixtures";
|
|
|
|
test("Show Usages distinguishes same-named files without losing the line or snippet", async ({ workbench: page }) => {
|
|
await page.setViewportSize({ width: 480, height: 620 });
|
|
await page.evaluate(async () => {
|
|
const usages = "/src/features/code-insight/usages.ts";
|
|
const { useUsagesPopup } = await import(/* @vite-ignore */ usages);
|
|
const symbol = "submitOrder";
|
|
useUsagesPopup.setState({
|
|
open: true,
|
|
anchor: { x: 30, y: 90 },
|
|
symbol,
|
|
groups: (
|
|
[
|
|
["/dev/acme-api/packages/billing/src/Routes.ts", "return submitOrder(invoice);"],
|
|
["/dev/acme-api/packages/checkout/src/Routes.ts", "return submitOrder(cart);"],
|
|
["/dev/acme-api/src/Worker.ts", "await submitOrder(job);"],
|
|
] as const
|
|
).map(([path, text]) => {
|
|
const col = text.indexOf(symbol);
|
|
return { path, usages: [{ path, line: 6, col, endCol: col + symbol.length, text }] };
|
|
}),
|
|
});
|
|
});
|
|
|
|
const popup = page.getByRole("dialog", { name: "Usages", exact: true });
|
|
const rows = popup.getByRole("option");
|
|
const billing = rows.filter({ hasText: "invoice" });
|
|
const checkout = rows.filter({ hasText: "cart" });
|
|
await expect(rows).toHaveCount(3);
|
|
for (const [row, directory] of [
|
|
[billing, "billing"],
|
|
[checkout, "checkout"],
|
|
] as const) {
|
|
await expect(row.getByText("Routes.ts", { exact: true })).toBeVisible();
|
|
const caption = row.getByText(directory, { exact: true });
|
|
await expect(caption).toBeVisible();
|
|
expect(await caption.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
|
await expect(row.getByText("7", { exact: true })).toBeVisible();
|
|
await expect(row.locator("mark")).toHaveText("submitOrder");
|
|
}
|
|
|
|
await expect(checkout.getByTitle("/dev/acme-api/packages/checkout/src/Routes.ts", { exact: true })).toBeVisible();
|
|
await expect(rows.filter({ hasText: "Worker.ts" }).getByText("src", { exact: true })).toHaveCount(0);
|
|
});
|
|
|
|
test("Show Usages resizes from its corner, the list fills it, and it reopens at that size", async ({
|
|
workbench: page,
|
|
}) => {
|
|
await page.setViewportSize({ width: 1200, height: 800 });
|
|
const show = () =>
|
|
page.evaluate(async () => {
|
|
const usages = "/src/features/code-insight/usages.ts";
|
|
const { useUsagesPopup } = await import(/* @vite-ignore */ usages);
|
|
const path = "/dev/app/src/Main.ts";
|
|
useUsagesPopup.setState({
|
|
open: true,
|
|
anchor: { x: 30, y: 60 },
|
|
symbol: "run",
|
|
groups: [
|
|
{
|
|
path,
|
|
usages: Array.from({ length: 40 }, (_, line) => ({ path, line, col: 0, endCol: 3, text: "run();" })),
|
|
},
|
|
],
|
|
});
|
|
});
|
|
await show();
|
|
const popup = page.getByRole("dialog", { name: "Usages", exact: true });
|
|
const list = popup.getByRole("listbox", { name: "Usages" });
|
|
const before = (await popup.boundingBox())!;
|
|
const listBefore = (await list.boundingBox())!;
|
|
const corner = (await popup.getByRole("separator", { name: "Resize" }).boundingBox())!;
|
|
await page.mouse.move(corner.x + corner.width / 2, corner.y + corner.height / 2);
|
|
await page.mouse.down();
|
|
await page.mouse.move(corner.x + 200, corner.y + 150, { steps: 5 });
|
|
await page.mouse.up();
|
|
const after = (await popup.boundingBox())!;
|
|
expect(after.width).toBeGreaterThan(before.width + 150);
|
|
expect(after.height).toBeGreaterThan(before.height + 100);
|
|
// The list, not empty space, takes the added height.
|
|
expect((await list.boundingBox())!.height).toBeGreaterThan(listBefore.height + 100);
|
|
await page.screenshot({ path: test.info().outputPath("usages-resized.png") });
|
|
|
|
await page.keyboard.press("Escape");
|
|
await expect(popup).toHaveCount(0);
|
|
await show();
|
|
const reopened = (await popup.boundingBox())!;
|
|
expect(Math.abs(reopened.width - after.width)).toBeLessThanOrEqual(1);
|
|
expect(Math.abs(reopened.height - after.height)).toBeLessThanOrEqual(1);
|
|
});
|