Порівняти коміти

..
Автор SHA1 Повідомлення Дата
l0ng-ai 9b4358f046 fix(database): show a running SQL statement in the editor and results
The console only tracked the running request for Run and Cancel; statement
marks and result tabs arrived after the request ended, and the Results view
said "No results" in the meantime. While a request runs, the submitted
statements are now highlighted with a spinner in the gutter and a ticking
elapsed time, and the Results view opens with an executing bar above the
previous result. Edits made meanwhile move the marks, and the outcomes land
on their statements. Cancel or an error clears the indication and keeps the
previous result and marks.

Fixes #4565
2026-11-20 04:05:59 +08:00
11 змінених файлів з 75 додано та 471 видалено

No files matched your search

-75
Переглянути файл
@@ -562,81 +562,6 @@ test("indexed single-file rename previews all anchors and applies only after con
expect(apply.edit).toMatchObject({ preconditions: [{ path: FILE, hash: "indexed-snapshot" }] });
});
test("rename keeps the typed name, uses the editor font and shows long preview names in a narrow dialog", async ({
workbench: page,
}) => {
const editor = await openSample(page);
await page.evaluate(
async ({ file, prepared }) => {
const projectModule = "/src/platform/project.ts";
const schemaModule = "/src/features/settings/model/schema.ts";
const [{ useProject }, { DEFAULT_SETTINGS }] = await Promise.all([
import(/* @vite-ignore */ projectModule),
import(/* @vite-ignore */ schemaModule),
]);
const base = useProject.getState().settings ?? DEFAULT_SETTINGS;
useProject.setState({ settings: { ...base, editor: { ...base.editor, fontSize: 17 } } });
window.__ipc.handlers.lsp_prepare_rename = () => prepared;
window.__ipc.handlers.lsp_rename = (args) => ({
preview: true,
incomplete: null,
edit: {
files: [
{
kind: "edit",
path: file,
edits: [{ range: prepared, new_text: args.newName }],
},
],
},
});
window.__ipc.handlers.apply_workspace_edit = () => null;
},
{ file: FILE, prepared: range(20, 12, 17) },
);
await caretAt(editor, page, "val order: Order", "order");
await page.keyboard.press("Shift+F6");
await expect(page.getByText(/Press ⇧F6 to show dialog/)).toBeVisible();
const name = "checkoutOrderWithDeliveryInstructionsAndInventoryReservation";
await page.keyboard.insertText(name);
await page.keyboard.press("Shift+F6");
await page.setViewportSize({ width: 440, height: 520 });
const dialog = page.getByRole("dialog", { name: "Rename 'order'", exact: true });
const input = dialog.getByRole("textbox", { name: "New name" });
await expect(input).toBeFocused();
await expect(input).toHaveValue(name);
await expect(input).toHaveCSS("font-size", "17px");
const [label, field] = await Promise.all([
dialog.getByText("New name", { exact: true }).boundingBox(),
input.boundingBox(),
]);
expect(label!.x + label!.width).toBeLessThan(field!.x);
const rename = dialog.getByRole("button", { name: "Rename", exact: true });
await input.fill("");
await expect(rename).toBeDisabled();
await input.press("Enter");
await expect(dialog).toBeVisible();
expect(await ipcCalls(page, "lsp_rename")).toHaveLength(0);
await input.fill(name);
await input.press("Enter");
const summary = `Rename 'order' to '${name}'`;
const preview = page.getByRole("dialog", { name: summary, exact: true });
const context = preview.getByText(summary, { exact: true });
await expect(context).toBeVisible();
const geometry = await context.evaluate((element) => ({
client: element.clientWidth,
content: element.scrollWidth,
}));
expect(geometry.content).toBeLessThanOrEqual(geometry.client + 1);
await expect(preview.getByText("1 occurrence in 1 file")).toBeVisible();
expect(await ipcCalls(page, "apply_workspace_edit")).toHaveLength(0);
await preview.getByRole("button", { name: "Do Refactor" }).click();
await expect.poll(() => ipcCalls(page, "apply_workspace_edit")).toHaveLength(1);
});
test("intention previews fit narrow windows and wrap long code lines", async ({ workbench: page }) => {
await page.setViewportSize({ width: 1600, height: 900 });
const editor = await openSample(page);
+3 -76
Переглянути файл
@@ -3,21 +3,15 @@
* the process. Processes are stubbed at the IPC layer; `crates/ide-run` covers spawning them.
*/
import type { Page } from "@playwright/test";
import type { RunConfig } from "../src/bindings";
import { expect, ipcCalls, stubDesktop, test } from "./fixtures";
const RUN_ID = 7;
/** One saved `npm run dev` configuration; `run_start` prints `output` and exits with `exit` unless null. */
async function stubRun(
page: Page,
output: { kind: string; text: string }[],
exit: number | null,
overrides: Partial<RunConfig> = {},
) {
async function stubRun(page: Page, output: { kind: string; text: string }[], exit: number | null) {
await stubDesktop(page);
await page.evaluate(
async ({ output, exit, runId, overrides }) => {
async ({ output, exit, runId }) => {
const config = {
id: "npm:dev",
name: "dev",
@@ -29,7 +23,6 @@ async function stubRun(
detected: false,
isTest: false,
debugAdapter: null,
...overrides,
};
const h = window.__ipc.handlers;
h.run_configs = () => [config];
@@ -50,7 +43,7 @@ async function stubRun(
await loadConfigs();
selectConfig(config.id);
},
{ output, exit, runId: RUN_ID, overrides },
{ output, exit, runId: RUN_ID },
);
}
@@ -184,72 +177,6 @@ test("Go reruns keep each package's exact failures and the original configuratio
]);
});
test("test results keep counts, actions and selected output visible as the pane narrows", async ({
workbench: page,
}) => {
await page.setViewportSize({ width: 1060, height: 740 });
const goPackage = "example.com/checkout";
const name = "TestCheckoutTotalsWithDiscountsAndPendingInventoryReservations";
const message = "expected subtotal 42, got 37";
const records = [
{ Action: "run", Test: name },
{ Action: "output", Test: name, Output: message + "\n" },
{ Action: "fail", Test: name, Elapsed: 0.125 },
{ Action: "pass", Test: "TestPayment", Elapsed: 0.02 },
{ Action: "skip", Test: "TestDelayedShipping" },
{ Action: "fail", Elapsed: 0.17 },
];
await stubRun(
page,
records.map((record) => ({ kind: "stdout", text: JSON.stringify({ Package: goPackage, ...record }) + "\n" })),
1,
{
id: "go:checkout-tests",
name: "Checkout tests",
kind: "go",
command: "go",
args: ["test", "-json"],
isTest: true,
},
);
await page.keyboard.press("Control+r");
const run = page.getByRole("region", { name: "Run", exact: true });
const tree = run.getByRole("tree", { name: "Test results" });
const row = tree.getByRole("treeitem", { name: new RegExp(name) });
await row.click();
const output = run.getByRole("log");
await expect(output).toContainText(message);
await expect.poll(async () => (await output.boundingBox())!.x > (await tree.boundingBox())!.x).toBe(true);
await page.setViewportSize({ width: 540, height: 740 });
await expect
.poll(async () => {
const [list, console] = await Promise.all([tree.boundingBox(), output.boundingBox()]);
return !!list && !!console && console.y >= list.y + list.height - 1;
})
.toBe(true);
const summary = run.getByRole("status").filter({ hasText: "1 failing" });
for (const count of ["1 failing", "1 passed", "1 ignored"]) await expect(summary.getByText(count)).toBeVisible();
await expect(row).toHaveAttribute("aria-selected", "true");
await expect(row.getByText("125 ms")).toBeVisible();
await expect(output).toContainText(message);
const toolbar = run.getByRole("toolbar", { name: "Test results" });
await toolbar.getByRole("button", { name: "More Actions" }).click();
await expect(page.getByRole("menuitem", { name: "Collapse All" })).toBeVisible();
await expect(page.getByRole("menuitem", { name: "Export Test Results…" })).toBeVisible();
await page.keyboard.press("Escape");
const divider = run.getByRole("separator");
const treeHeight = async () => (await tree.boundingBox())!.height;
const beforeResize = await treeHeight();
await divider.press("ArrowDown");
await expect.poll(treeHeight).toBeGreaterThan(beforeResize + 1);
const customizedHeight = await treeHeight();
await page.setViewportSize({ width: 1060, height: 740 });
await expect.poll(async () => (await output.boundingBox())!.x > (await tree.boundingBox())!.x).toBe(true);
await page.setViewportSize({ width: 540, height: 740 });
await expect.poll(async () => Math.abs((await treeHeight()) - customizedHeight)).toBeLessThan(2);
await expect(output).toContainText(message);
});
test("CMake builds the selected target in Build before starting only the application in Run", async ({
workbench: page,
}) => {
-70
Переглянути файл
@@ -261,34 +261,6 @@
font-size: var(--fs-tiny);
color: var(--fg-faint);
}
.symbolRename {
display: grid;
grid-template-columns: auto minmax(0, 1fr);
align-items: center;
gap: var(--space-2) var(--space-3);
padding: var(--space-3);
font-family: var(--font-ui);
font-size: var(--fs-ui);
}
.renameContext,
.symbolRenameNote {
grid-column: 1 / -1;
min-width: 0;
overflow-wrap: anywhere;
}
.renameContext {
color: var(--fg-emphasis);
}
.symbolRename .renameField {
width: 100%;
height: max(var(--h-field), calc(var(--openidea-editor-font-size, var(--fs-code)) + var(--space-2)));
font-family: var(--openidea-editor-font, var(--font-mono));
font-size: var(--openidea-editor-font-size, var(--fs-code));
}
.symbolRenameNote {
color: var(--fg-muted);
font-size: var(--fs-small);
}
/* Fits its content up to a cap; resized (`data-resized`), it keeps that size and the body scrolls. */
.docPopup {
@@ -426,36 +398,6 @@
flex-direction: column;
overflow: hidden;
}
.renamePreview [data-dialog-body] {
display: block;
overflow: auto;
}
.previewContext {
padding: var(--space-2) 14px 0;
overflow-wrap: anywhere;
color: var(--fg-emphasis);
font-size: var(--fs-ui);
}
.renamePreview .previewList {
overflow: visible;
}
.renamePreview .previewName {
min-width: 0;
max-width: 55%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.renamePreview .previewOp {
flex: 0 1 auto;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.renamePreview .previewWarning {
overflow-wrap: anywhere;
}
.previewSummary {
flex: none;
padding: 10px 14px 6px;
@@ -527,18 +469,6 @@
font-size: var(--fs-small);
color: var(--fg-editor);
}
.renamePreview .previewOccurrences .previewRow {
min-height: var(--h-row);
height: auto;
align-items: baseline;
padding-block: var(--space-1);
}
.renamePreview .previewCode {
font-family: var(--openidea-editor-font, var(--font-mono));
font-size: var(--openidea-editor-font-size, var(--fs-code));
white-space: pre-wrap;
overflow-wrap: anywhere;
}
.previewMatch {
background: var(--bg-search-match);
color: var(--fg-search-match, inherit);
+5 -63
Переглянути файл
@@ -1,5 +1,5 @@
/** React popups for LSP editor features, rendered as a workbench overlay. */
import { useEffect, useId, useMemo, useRef, useState, type CSSProperties, type KeyboardEvent } from "react";
import { useEffect, useMemo, useRef, useState, type CSSProperties, type KeyboardEvent } from "react";
import clsx from "clsx";
import {
Checkbox,
@@ -392,54 +392,6 @@ function RenamePopup({ popup }: { popup: Extract<LspPopup, { kind: "rename" }> }
);
}
function SymbolRenameDialog({ popup }: { popup: Extract<LspPopup, { kind: "symbolRename" }> }) {
const [value, setValue] = useState(popup.initial);
const field = useId();
const name = value.trim();
return (
<Dialog
open
title="Rename"
aria-label={popup.title}
onClose={closePopup}
blockWorkbenchShortcuts
width={440}
buttons={[
{
label: "Rename",
role: "default",
disabled: !name,
onClick: () => {
closePopup();
popup.onSubmit(name);
},
},
{ label: "Cancel", role: "cancel" },
]}
>
<div className={popup.themeClasses}>
<div className={styles.symbolRename}>
<div className={styles.renameContext}>{popup.title}</div>
<label htmlFor={field}>
<T>New name</T>
</label>
<Input
id={field}
className={styles.renameField}
mono
data-autofocus
autoSelect
value={value}
onChange={(e) => setValue(e.target.value)}
invalid={!name}
/>
{popup.note && <div className={styles.symbolRenameNote}>{popup.note}</div>}
</div>
</div>
</Dialog>
);
}
function DocPopup({ popup }: { popup: Extract<LspPopup, { kind: "doc" }> }) {
const focusSeq = useLspPopup((s) => s.focusSeq);
const scope = useRef<HTMLDivElement>(null);
@@ -584,7 +536,6 @@ function savePreviewSize(size: { w: number; h: number }) {
}
function PreviewDialog({ popup }: { popup: Extract<LspPopup, { kind: "preview" }> }) {
const rename = popup.renameThemeClasses !== undefined;
const root = useProject((s) => s.project?.root ?? "");
const { summary } = popup;
const [initialSize] = useState(loadPreviewSize);
@@ -592,9 +543,8 @@ function PreviewDialog({ popup }: { popup: Extract<LspPopup, { kind: "preview" }
<Dialog
open
onClose={closePopup}
title={rename ? "Rename" : popup.title}
aria-label={popup.title}
className={clsx(styles.previewDialog, rename && styles.renamePreview)}
title={popup.title}
className={styles.previewDialog}
width={560}
minWidth={400}
minHeight={220}
@@ -615,7 +565,6 @@ function PreviewDialog({ popup }: { popup: Extract<LspPopup, { kind: "preview" }
{ label: "Cancel", role: "cancel" },
]}
>
{rename && <div className={styles.previewContext}>{popup.title}</div>}
{popup.warnings?.map((w) => (
<div key={w} className={styles.previewWarning} role="note">
<Icon name="warning" size={14} />
@@ -624,10 +573,7 @@ function PreviewDialog({ popup }: { popup: Extract<LspPopup, { kind: "preview" }
))}
<div className={styles.previewSummary}>{describeSummary(summary)}</div>
{popup.occurrences ? (
<ul
className={clsx(styles.previewList, styles.previewOccurrences, popup.renameThemeClasses)}
aria-label={tx("Occurrences")}
>
<ul className={styles.previewList} aria-label={tx("Occurrences")}>
{popup.occurrences.map((o, i) => {
const lead = o.text.length - o.text.trimStart().length;
const text = o.text.trim();
@@ -650,9 +596,7 @@ function PreviewDialog({ popup }: { popup: Extract<LspPopup, { kind: "preview" }
{summary.entries.map((e) => (
<li key={e.path} className={styles.previewRow}>
<Icon name={fileIconName(basename(e.path), e.path)} size={14} className={styles.itemIcon} />
<span className={styles.previewName} title={relativePath(root, e.path)}>
{basename(e.path)}
</span>
<span className={styles.previewName}>{basename(e.path)}</span>
<span className={styles.previewPath} title={relativePath(root, e.path)}>
{relativePath(root, e.path)}
</span>
@@ -798,8 +742,6 @@ export function LspPopups() {
return <ListPopup key={seq} popup={popup} />;
case "rename":
return <RenamePopup key={seq} popup={popup} />;
case "symbolRename":
return <SymbolRenameDialog key={seq} popup={popup} />;
case "doc":
return <DocPopup key={seq} popup={popup} />;
case "definition":
-10
Переглянути файл
@@ -130,14 +130,6 @@ export type LspPopup =
hint?: string;
onSubmit: (name: string) => void;
}
| {
kind: "symbolRename";
title: string;
initial: string;
note?: string;
themeClasses: string;
onSubmit: (name: string) => void;
}
| {
kind: "preview";
title: string;
@@ -148,8 +140,6 @@ export type LspPopup =
warnings?: string[];
/** Individual occurrences with line previews (single-file syntax-based renames). */
occurrences?: PreviewOccurrence[];
/** The editor theme for a symbol rename and its occurrence snippets. */
renameThemeClasses?: string;
};
export interface PreviewOccurrence {
+7 -8
Переглянути файл
@@ -27,9 +27,9 @@ import { executeAction } from "@/platform/actions";
import { whenAllSynced, whenSynced, type EditorDocContext } from "@/editor/api";
import { structure } from "@/editor/structure";
import { docOf, incompleteNote, isUnavailable, lspRequest, reportLspError } from "./lsp";
import { offsetToPos, rangeToOffsets } from "./positions";
import { comparePos, offsetToPos, rangeToOffsets } from "./positions";
import { showHint } from "./hint";
import { openPopup, type PreviewOccurrence } from "./popupStore";
import { caretAnchor, openPopup, type PreviewOccurrence } from "./popupStore";
import { needsPreview, summarizeWorkspaceEdit } from "./workspaceEdit";
import { endInplaceRename, inplaceSession, startInplaceRename, type Span } from "./inplaceRename";
import { shortcutLabel } from "@/platform/keymap";
@@ -127,10 +127,10 @@ export async function startRename(view: EditorView) {
const oldName = view.state.sliceDoc(from, to);
const dialog = (initial: string) =>
openPopup({
kind: "symbolRename",
kind: "rename",
anchor: caretAnchor(view, from),
title: tx`Rename '${oldName}'`,
initial,
themeClasses: view.themeClasses,
onSubmit: (newName) => void finishRename(view, doc, pos, oldName, newName),
});
if (from === to) {
@@ -304,7 +304,6 @@ async function finishRename(view: EditorView, doc: EditorDocContext, pos: Pos, o
kind: "preview",
title: tx`Rename '${oldName}' to '${newName}'`,
summary,
renameThemeClasses: view.themeClasses,
...(note ? { warnings: [note] } : {}),
confirmLabel: note ? "Rename Anyway" : "Do Refactor",
onConfirm: () => void applyEdit(view, edit),
@@ -351,12 +350,13 @@ async function startSyntaxRename(
return true;
}
const { plan } = result;
const at = plan.occurrences.find((o) => comparePos(o.range.start, pos) <= 0 && comparePos(pos, o.range.end) <= 0);
openPopup({
kind: "symbolRename",
kind: "rename",
anchor: caretAnchor(view, rangeToOffsets(view.state.doc, (at ?? plan.occurrences[0]!).range).from),
title: tx`Rename '${plan.symbol.name}'`,
initial: plan.symbol.name,
note: `${SYNTAX_NOTE}: local occurrences only`,
themeClasses: view.themeClasses,
onSubmit: (newName) => void commitSyntaxRename(view, doc, plan, newName),
});
return true;
@@ -418,7 +418,6 @@ export async function commitSyntaxRename(
},
warnings: [...risks, `${SYNTAX_NOTE}. Only the occurrences below will be renamed.`],
occurrences,
renameThemeClasses: view.themeClasses,
confirmLabel: "Rename Anyway",
onConfirm: apply,
});
+6 -6
Переглянути файл
@@ -646,8 +646,8 @@ describe("rename wiring", () => {
const view = editor("const x = 1;\nf({ x });", "typescript", 6);
await startRename(view);
const popup = useLspPopup.getState().popup;
expect(popup?.kind).toBe("symbolRename");
if (popup?.kind !== "symbolRename") return;
expect(popup?.kind).toBe("rename");
if (popup?.kind !== "rename") return;
expect(popup.note).toContain("Based on syntax");
popup.onSubmit("y");
await vi.waitFor(() => expect(view.state.doc.toString()).toBe("const y = 1;\nf({ x: y });"));
@@ -661,7 +661,7 @@ describe("rename wiring", () => {
const view = editor("const x = 1;\nx;\nvar x;", "typescript", 6);
await startRename(view);
const popup = useLspPopup.getState().popup;
if (popup?.kind !== "symbolRename") throw new Error("no rename dialog");
if (popup?.kind !== "rename") throw new Error("no rename popup");
popup.onSubmit("y");
await vi.waitFor(() => expect(useLspPopup.getState().popup?.kind).toBe("preview"));
const preview = useLspPopup.getState().popup;
@@ -860,12 +860,12 @@ describe("rename wiring", () => {
await startRename(view);
expect(inplaceSession(view.state)?.oldName).toBe("x");
await startRename(view);
expect(useLspPopup.getState().popup?.kind).toBe("symbolRename");
expect(useLspPopup.getState().popup?.kind).toBe("rename");
if (finish === "cancel") closePopup();
release({ status: "ok", data: r(0, 6, 7) });
await older;
expect(inplaceSession(view.state)).toBeNull();
expect(useLspPopup.getState().popup?.kind ?? null).toBe(finish === "dialog" ? "symbolRename" : null);
expect(useLspPopup.getState().popup?.kind ?? null).toBe(finish === "dialog" ? "rename" : null);
});
it.each(["text", "document"])("drops pending preparation when the editor %s changes", async (change) => {
@@ -938,7 +938,7 @@ describe("rename wiring", () => {
);
cmd.syntaxLocals.mockReturnValueOnce(ok(local({ references: [] })));
await startRename(view);
expect(useLspPopup.getState().popup?.kind).toBe("symbolRename");
expect(useLspPopup.getState().popup?.kind).toBe("rename");
});
});
+8 -29
Переглянути файл
@@ -253,44 +253,26 @@
flex-direction: column;
height: 100%;
min-width: 0;
border-right: 1px solid var(--border);
}
.testToolbar,
.testStatusBar {
.testHeader {
flex: none;
display: flex;
flex-wrap: wrap;
align-items: center;
min-height: 28px;
gap: var(--space-2);
height: 28px;
padding: 0 4px 0 10px;
border-bottom: 1px solid var(--border);
}
.testToolbar {
gap: var(--space-0-5);
padding: var(--space-0-5) var(--space-1);
}
.testStatusBar {
gap: var(--space-0-5) var(--space-2);
padding: var(--space-0-5) var(--space-2);
font-size: var(--fs-ui);
color: var(--fg-secondary);
}
.testCounts {
flex: 1 1 auto;
display: flex;
flex-wrap: wrap;
gap: var(--space-0-5) var(--space-2);
gap: 10px;
min-width: 0;
overflow: hidden;
white-space: nowrap;
}
.testStatus,
.testTotalDuration {
flex: none;
}
.testTotalDuration {
margin-left: auto;
color: var(--fg-subtle);
font-size: var(--fs-small);
font-variant-numeric: tabular-nums;
}
.testTree {
flex: 1;
min-height: 0;
@@ -317,11 +299,8 @@
flex: none;
padding-right: 8px;
color: var(--fg-subtle);
font-family: var(--font-mono);
font-size: var(--fs-small);
font-variant-numeric: tabular-nums;
}
.testTree [aria-selected="true"] .testDuration {
color: var(--fg);
}
.testEmpty {
padding: 12px;
+6 -41
Переглянути файл
@@ -1,6 +1,5 @@
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
import { useEffect, useMemo, useRef, useState } from "react";
import clsx from "clsx";
import type { GroupImperativeHandle, Layout } from "react-resizable-panels";
import type { RunConfig } from "@/platform/ipc";
import type { RunTargetValid } from "@/platform/remoteSettings";
import { useAgentRunSettings, useWorkflowSettings } from "@/platform/workflowSettings";
@@ -48,7 +47,7 @@ import {
} from "./store";
import { rerunFailedConfigs } from "./testing/rerun";
import { formatDuration, nodeOutput } from "./testing";
import { TestStatusBar, TestTreeView } from "./TestTreeView";
import { TestTreeView } from "./TestTreeView";
import { StackTracePanel, useStackTraces, type StackTraceTab } from "./stackTrace";
import { closeRunTab, runTabMenu } from "./runTabs";
import { showApplicationUpdate, useApplicationUpdates } from "./applicationUpdate";
@@ -60,11 +59,6 @@ import { archivedAgentSessions, closeAgentArchive } from "./agentRuns";
import styles from "./Run.module.css";
import { tx } from "@/platform/i18n";
const TEST_SPLIT_DEFAULTS = {
horizontal: { tests: 34, console: 66 },
vertical: { tests: 48, console: 52 },
};
function failed(s: RunSession): boolean {
return s.status === "failed" || (s.status === "finished" && s.exitCode !== 0 && !s.stopped);
}
@@ -99,25 +93,6 @@ export function SessionPanel({
const softWrap = wrapOverride ?? defaultWrap;
const [selectedTest, setSelectedTest] = useState<string | null>(null);
const [findOpen, setFindOpen] = useState(false);
const body = useRef<HTMLDivElement>(null);
const [stackedTests, setStackedTests] = useState(false);
const testSplit = useRef<GroupImperativeHandle>(null);
const testLayouts = useRef<Record<keyof typeof TEST_SPLIT_DEFAULTS, Layout>>({ ...TEST_SPLIT_DEFAULTS });
const testOrientation = stackedTests ? "vertical" : "horizontal";
const hasTests = !!rt?.tests;
useLayoutEffect(() => {
const pane = body.current;
if (!hasTests || !pane) return;
const measure = () => setStackedTests(pane.clientWidth < 560);
measure();
if (typeof ResizeObserver === "undefined") return;
const resize = new ResizeObserver(measure);
resize.observe(pane);
return () => resize.disconnect();
}, [hasTests]);
useLayoutEffect(() => {
if (hasTests) testSplit.current?.setLayout(testLayouts.current[testOrientation]);
}, [hasTests, testOrientation]);
const running = isLive(session);
const cwd = runDirectory(session.config.cwd);
const baseConfig = useRun(() => baseConfigOf(session));
@@ -161,7 +136,6 @@ export function SessionPanel({
const consoleColumn = (
<div className={styles.consoleColumn}>
{rt.tests && <TestStatusBar results={rt.tests} version={version} running={running} />}
{rt.console.dropped > 0 && !testModel && (
<div className={styles.notice}>{tx`${rt.console.dropped.toLocaleString()} earlier lines were discarded`}</div>
)}
@@ -305,19 +279,10 @@ export function SessionPanel({
/>
</div>
</div>
<div ref={body} className={styles.sessionBody}>
<div className={styles.sessionBody}>
{rt.tests ? (
<SplitGroup
orientation={testOrientation}
id={`run-tests-${session.id}`}
className={styles.testSplit}
groupRef={testSplit}
defaultLayout={TEST_SPLIT_DEFAULTS[testOrientation]}
onLayoutChanged={(layout, meta) => {
if (meta.isUserInteraction) testLayouts.current[testOrientation] = meta.requestedLayout ?? layout;
}}
>
<SplitPanel id="tests" minSize={stackedTests ? "28%" : "140px"}>
<SplitGroup orientation="horizontal" id={`run-tests-${session.id}`} className={styles.testSplit}>
<SplitPanel id="tests" defaultSize="32%" minSize="140px">
<TestTreeView
results={rt.tests}
version={version}
@@ -331,7 +296,7 @@ export function SessionPanel({
/>
</SplitPanel>
<SplitHandle />
<SplitPanel id="console" minSize={stackedTests ? "28%" : "200px"}>
<SplitPanel id="console" minSize="200px">
{consoleColumn}
</SplitPanel>
</SplitGroup>
+12 -18
Переглянути файл
@@ -49,12 +49,6 @@ function Host(props: {
);
}
function moreItem(name: string) {
const trigger = screen.getByRole("button", { name: "More Actions" });
if (trigger.getAttribute("aria-expanded") !== "true") fireEvent.click(trigger);
return screen.getByRole("menuitem", { name });
}
describe("TestTreeView", () => {
beforeEach(() => localStorage.clear());
afterEach(() => vi.clearAllMocks());
@@ -270,17 +264,17 @@ describe("Expand All / Collapse All", () => {
expect(rows()).toContain("reuses()");
});
it("the menu runs the actions, and they are unavailable without suites", () => {
it("the buttons run the actions, and are unavailable without suites", () => {
const dispose = registerActions([
{ id: "run.expandAllTests", title: "Expand All", run: () => {} },
{ id: "run.collapseAllTests", title: "Collapse All", run: () => {} },
]);
onTestFinished(dispose);
const { unmount } = render(view(nested()));
fireEvent.click(moreItem("Expand All"));
expect(actions.executeAction).toHaveBeenCalledWith("run.expandAllTests");
fireEvent.click(moreItem("Collapse All"));
expect(actions.executeAction).toHaveBeenCalledWith("run.collapseAllTests");
fireEvent.click(screen.getByRole("button", { name: "Expand All" }));
expect(actions.executeAction).toHaveBeenCalledWith("run.expandAllTests", undefined);
fireEvent.click(screen.getByRole("button", { name: "Collapse All" }));
expect(actions.executeAction).toHaveBeenCalledWith("run.collapseAllTests", undefined);
unmount();
expect(testTree.expandAll).toBeNull();
@@ -288,8 +282,8 @@ describe("Expand All / Collapse All", () => {
flat.apply([{ type: "result", path: ["main_test"], status: "failed" }]);
flat.finish(1);
render(view(flat));
expect(moreItem("Expand All")).toHaveAttribute("aria-disabled", "true");
expect(moreItem("Collapse All")).toHaveAttribute("aria-disabled", "true");
expect(screen.getByRole("button", { name: "Expand All" })).toBeDisabled();
expect(screen.getByRole("button", { name: "Collapse All" })).toBeDisabled();
});
});
@@ -312,9 +306,9 @@ describe("Export Test Results", () => {
/>
);
it("the menu and the action open the dialog for the finished run", () => {
it("the button and the action open the dialog for the finished run", () => {
const { unmount } = render(view(finished(), false));
fireEvent.click(moreItem("Export Test Results…"));
fireEvent.click(screen.getByRole("button", { name: "Export Test Results…" }));
expect(screen.getByRole("dialog", { name: "Export Test Results" })).toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "Cancel" }));
act(() => testTree.exportResults!());
@@ -328,13 +322,13 @@ describe("Export Test Results", () => {
it("is unavailable while the tests run and without results", () => {
const { rerender } = render(view(finished(), true));
expect(moreItem("Export Test Results…")).toHaveAttribute("aria-disabled", "true");
expect(screen.getByRole("button", { name: "Export Test Results…" })).toBeDisabled();
expect(testTree.exportResults).toBeNull();
rerender(view(new TestResults(), false));
expect(moreItem("Export Test Results…")).toHaveAttribute("aria-disabled", "true");
expect(screen.getByRole("button", { name: "Export Test Results…" })).toBeDisabled();
expect(testTree.exportResults).toBeNull();
rerender(view(finished(), false));
expect(moreItem("Export Test Results…")).not.toHaveAttribute("aria-disabled", "true");
expect(screen.getByRole("button", { name: "Export Test Results…" })).toBeEnabled();
expect(testTree.exportResults).not.toBeNull();
});
});
+28 -75
Переглянути файл
@@ -9,7 +9,6 @@ import {
showContextMenu,
useContextMenuStore,
Spinner,
Toolbar,
Tree,
type MenuItem,
type TreeHandle,
@@ -84,41 +83,6 @@ export function StatusIcon({ status }: { status: TestStatus | null }) {
}
}
export function TestStatusBar({
results,
version,
running,
}: {
results: TestResults;
version: number;
running: boolean;
}) {
const counts = useMemo(() => results.counts(), [results, version]); // eslint-disable-line react-hooks/exhaustive-deps
const status = running
? "running"
: counts.failed
? "failed"
: counts.passed
? "passed"
: counts.skipped
? "skipped"
: null;
const duration = results.summary.durationMs;
return (
<div className={styles.testStatusBar} role="status">
<StatusIcon status={status} />
<span className={styles.testCounts}>
{counts.failed > 0 && <span className={styles.failed}>{tx`${counts.failed} failing`}</span>}
{counts.passed > 0 && <span>{tx`${counts.passed} passed`}</span>}
{counts.skipped > 0 && <span className={styles.skipped}>{tx`${counts.skipped} ignored`}</span>}
{counts.total === 0 && <span className={styles.skipped}>{running ? tx("Running…") : tx("No tests")}</span>}
</span>
{duration !== undefined && <span className={styles.testTotalDuration}>{formatDuration(duration)}</span>}
</div>
);
}
const isFailedTest = (n: TestNode) => n.children.length === 0 && nodeStatus(n) === "failed";
const treeModel = {
@@ -199,8 +163,6 @@ export function TestTreeView({
});
const sortButton = useRef<HTMLButtonElement>(null);
const [sortMenu, setSortMenu] = useState(false);
const moreButton = useRef<HTMLButtonElement>(null);
const [moreMenu, setMoreMenu] = useState(false);
const [expanded, setExpanded] = useState<Set<string> | null>(null);
const [exporting, setExporting] = useState(false);
const [selection, setSelection] = useState<Set<string>>(new Set());
@@ -264,6 +226,7 @@ export function TestTreeView({
}
};
const counts = useMemo(() => results.counts(), [results, version]); // eslint-disable-line react-hooks/exhaustive-deps
// Like IDEA, Sort by Duration applies once the run has finished, so rows don't jump while tests report.
const byDuration = sortByDuration && !running;
const roots = useMemo(() => {
@@ -313,9 +276,21 @@ export function TestTreeView({
const hasPrevFailed = findOccurrence(roots, selected, -1, treeModel) !== null;
const hasNextFailed = findOccurrence(roots, selected, 1, treeModel) !== null;
const status = running ? "running" : counts.failed > 0 ? "failed" : counts.total > 0 ? "passed" : null;
const duration = results.summary.durationMs;
return (
<div className={styles.testPane}>
<Toolbar className={styles.testToolbar} aria-label="Test results">
<div className={styles.testHeader}>
<StatusIcon status={status} />
<span className={styles.testCounts}>
{counts.failed > 0 && <span className={styles.failed}>{tx`${counts.failed} failing`}</span>}
{counts.passed > 0 && <span>{tx`${counts.passed} passed`}</span>}
{counts.skipped > 0 && <span className={styles.skipped}>{tx`${counts.skipped} ignored`}</span>}
{counts.total === 0 && <span className={styles.skipped}>{running ? tx("Running…") : tx("No tests")}</span>}
{duration !== undefined && <span className={styles.skipped}>{formatDuration(duration)}</span>}
</span>
<span className={styles.spacer} />
<IconButton
icon="test-show-passed"
size="small"
@@ -357,6 +332,14 @@ export function TestTreeView({
]}
onClose={() => setSortMenu(false)}
/>
<IconButton icon="expand-all" action="run.expandAllTests" size="small" iconSize={16} disabled={!hasSuites} />
<IconButton
icon="collapse-all"
action="run.collapseAllTests"
size="small"
iconSize={16}
disabled={!hasSuites}
/>
<IconButton
icon="arrow-up"
action="navigate.prevOccurrence"
@@ -374,42 +357,14 @@ export function TestTreeView({
disabled={!hasNextFailed}
/>
<IconButton
ref={moreButton}
icon="more-horizontal"
icon="export"
size="small"
iconSize={16}
title="More Actions"
aria-haspopup="menu"
aria-expanded={moreMenu}
onClick={() => setMoreMenu((open) => !open)}
title="Export Test Results…"
disabled={!canExport}
onClick={() => setExporting(true)}
/>
<Menu
open={moreMenu}
anchor={moreButton}
onClose={() => setMoreMenu(false)}
items={[
{
icon: "expand-all",
label: "Expand All",
disabled: !hasSuites,
run: () => void executeAction("run.expandAllTests"),
},
{
icon: "collapse-all",
label: "Collapse All",
disabled: !hasSuites,
run: () => void executeAction("run.collapseAllTests"),
},
{ kind: "separator" },
{
icon: "export",
label: "Export Test Results…",
disabled: !canExport,
run: () => setExporting(true),
},
]}
/>
</Toolbar>
</div>
{exporting && (
<ExportTestResultsDialog results={results} name={name} cwd={cwd} onClose={() => setExporting(false)} />
)}
@@ -441,9 +396,7 @@ export function TestTreeView({
return (
<span className={styles.testRow}>
<StatusIcon status={s} />
<span className={clsx(styles.testName, s === "skipped" && styles.skipped)} title={n.name}>
{n.name}
</span>
<span className={clsx(styles.testName, s === "skipped" && styles.skipped)}>{n.name}</span>
{d !== undefined && <span className={styles.testDuration}>{formatDuration(d)}</span>}
</span>
);