Файли
openidea/e2e/debugThreadLayout.spec.ts
T
l0ng-ai 6b2b4a96e7 fix(debugger): align the thread selector with the frames pane (#4961)
- Give the thread selector the width of the call stack header, with the standard workbench font and a fixed chevron at the trailing edge.
- Show a leading icon for running, suspended, and breakpoint threads in both the header and the menu. Keep the status text in the menu and make the selected thread's full name and status available in the header tooltip and accessible description.
2026-11-21 14:33:37 +08:00

67 рядки
2.8 KiB
TypeScript

import { expect, ipcCalls, stubDesktop, test } from "./fixtures";
test("shows thread states in the compact frames header and switches frames by keyboard", async ({
workbench: page,
}) => {
await page.setViewportSize({ width: 940, height: 740 });
await stubDesktop(page);
await page.evaluate(async () => {
const stateModule = "/src/features/debugger/state.ts";
const workbenchModule = "/src/workbench/contributions.ts";
const { adoptSession } = await import(/* @vite-ignore */ stateModule);
const { toolWindowService } = await import(/* @vite-ignore */ workbenchModule);
const frame = (id: number, name: string) => ({
id,
name,
path: null,
line: 0,
column: 0,
presentationHint: null,
});
const handlers = window.__ipc.handlers;
handlers.debug_stack_trace = ({ threadId }) => [frame(Number(threadId) * 10, "writeLedger")];
handlers.debug_scopes = () => [];
adoptSession(97, {
name: "Settlement",
adapter: "debugpy",
status: "paused",
stoppedThread: 1,
selectedThread: 1,
stopReason: "breakpoint",
suspendedThreads: [{ id: 2, reason: "pause", description: null }],
threads: [
{ id: 1, name: "MainThread" },
{ id: 2, name: "Audit writer" },
{ id: 3, name: "Regional settlement reconciliation worker with a long queue name" },
],
selectedFrame: 10,
frames: [frame(10, "settle")],
});
toolWindowService().show("debug", true);
});
const debug = page.getByRole("region", { name: "Debug", exact: true });
const thread = debug.getByRole("button", { name: "Thread", exact: true });
await expect(thread).toBeVisible();
const remainder = await thread.evaluate((button) => button.parentElement!.clientWidth - button.clientWidth);
expect(remainder).toBeLessThan(12);
await expect(thread).toHaveAccessibleDescription("MainThread (At breakpoint)");
const frames = debug.getByRole("listbox", { name: "Frames" });
await expect(frames.getByText("settle", { exact: true })).toBeVisible();
await thread.press("ArrowDown");
const menu = page.getByRole("listbox", { name: "Thread" });
await expect(menu).toBeInViewport({ ratio: 1 });
await expect(menu.getByRole("option", { name: "MainThread At breakpoint" })).toBeVisible();
await expect(menu.getByRole("option", { name: "Audit writer Suspended" })).toBeVisible();
await expect(
menu.getByRole("option", { name: /Regional settlement reconciliation worker .* Running/ }),
).toBeVisible();
await page.keyboard.press("ArrowDown");
await page.keyboard.press("Enter");
await expect(menu).toBeHidden();
await expect(thread).toHaveAccessibleDescription("Audit writer (Suspended)");
await expect(frames.getByText("writeLedger", { exact: true })).toBeVisible();
expect(await ipcCalls(page, "debug_stack_trace")).toEqual([{ session: 97, threadId: 2 }]);
});