From 08362db3cabef3e3a2b4c2a34485c5256f30152e Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Sun, 22 Nov 2026 20:32:57 +0800 Subject: [PATCH] fix(run): keep the test summary together and clarify its status (#5186) Keep elapsed time beside the test counts in the Run window at the same text size. The summary keeps its Running label when the first test has started and no results have arrived yet. A thin line below the summary shows the current state alongside the icon and counts. --- e2e/run.spec.ts | 58 +++++++++++++++++++++++++++++++ src/features/run/Run.module.css | 23 ++++++++---- src/features/run/TestTreeView.tsx | 23 ++++++------ 3 files changed, 84 insertions(+), 20 deletions(-) diff --git a/e2e/run.spec.ts b/e2e/run.spec.ts index 80cfa15ba..5314a29c1 100644 --- a/e2e/run.spec.ts +++ b/e2e/run.spec.ts @@ -323,6 +323,64 @@ test("test results keep counts, actions and selected output visible as the pane await expect(output).toContainText(message); }); +test("test results keep elapsed time beside the counts", async ({ workbench: page }) => { + await page.setViewportSize({ width: 1060, height: 740 }); + const lines = [ + "test_tax (test_ledger.CheckoutTests.test_tax) ... ok", + "test_refund (test_ledger.CheckoutTests.test_refund) ... FAIL", + "test_callback (test_ledger.CheckoutTests.test_callback) ... skipped 'Requires a callback'", + "Ran 3 tests in 0.170s", + "FAILED (failures=1, skipped=1)", + ]; + await stubRun(page, [{ kind: "stderr", text: lines.join("\n") + "\n" }], 1, { + id: "django:checkout-tests", + name: "Checkout tests", + kind: "django-test", + command: "python", + args: ["manage.py", "test", "-v", "2"], + isTest: true, + }); + await page.keyboard.press("Control+r"); + const run = page.getByRole("region", { name: "Run", exact: true }); + const summary = run.getByRole("status").filter({ hasText: "1 failing" }); + const ignored = summary.getByText("1 ignored", { exact: true }); + const elapsed = summary.getByText("170 ms", { exact: true }); + await expect(elapsed).toBeVisible(); + for (const width of [1060, 540]) { + await page.setViewportSize({ width, height: 740 }); + await expect + .poll(async () => { + const [count, duration] = await Promise.all([ignored.boundingBox(), elapsed.boundingBox()]); + return count && duration && Math.abs(count.y - duration.y) <= 1 ? duration.x - count.x - count.width : Infinity; + }) + .toBeLessThanOrEqual(12); + } + await expect(summary).toHaveCSS("border-bottom-width", "2px"); +}); + +test("test results retain a running label after the first test starts", async ({ workbench: page }) => { + const name = "TestCheckoutTotals"; + await stubRun( + page, + [{ kind: "stdout", text: JSON.stringify({ Package: "example.com/checkout", Action: "run", Test: name }) + "\n" }], + null, + { + 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 }); + await expect(run.getByRole("treeitem", { name: new RegExp(name) })).toBeVisible(); + const summary = run.getByRole("status").filter({ hasText: "Running…" }); + await expect(summary).toBeVisible(); + await expect(summary).toHaveCSS("border-bottom-width", "2px"); +}); + test("test results group failure navigation and let users hide row durations", async ({ workbench: page }) => { await page.setViewportSize({ width: 540, height: 740 }); const first = "TestCheckoutTotalsWithTaxRoundingAndPendingRefunds"; diff --git a/src/features/run/Run.module.css b/src/features/run/Run.module.css index e46aae8b1..a203a1a58 100644 --- a/src/features/run/Run.module.css +++ b/src/features/run/Run.module.css @@ -258,12 +258,12 @@ .testStatusBar { flex: none; display: flex; - flex-wrap: wrap; align-items: center; min-height: 28px; border-bottom: 1px solid var(--border); } .testToolbar { + flex-wrap: wrap; gap: var(--space-1); padding: var(--space-0-5) var(--space-1); } @@ -275,27 +275,36 @@ border-inline-end: 1px solid var(--border); } .testStatusBar { - gap: var(--space-0-5) var(--space-2); + gap: var(--space-2); padding: var(--space-0-5) var(--space-2); + border-block-end-width: var(--space-0-5); font-size: var(--fs-ui); color: var(--fg-secondary); } +.testStatusBar[data-outcome="passed"] { + border-block-end-color: var(--success); +} +.testStatusBar[data-outcome="skipped"] { + border-block-end-color: var(--warning); +} +.testStatusBar[data-running] { + border-block-end-color: var(--accent); +} +.testStatusBar[data-outcome="failed"] { + border-block-end-color: var(--danger); +} .testCounts { - flex: 1 1 auto; display: flex; flex-wrap: wrap; gap: var(--space-0-5) var(--space-2); min-width: 0; white-space: nowrap; } -.testStatus, -.testTotalDuration { +.testStatus { flex: none; } .testTotalDuration { - margin-left: auto; color: var(--fg-subtle); - font-size: var(--fs-small); font-variant-numeric: tabular-nums; } .testTree { diff --git a/src/features/run/TestTreeView.tsx b/src/features/run/TestTreeView.tsx index 78872af51..74c50e2d4 100644 --- a/src/features/run/TestTreeView.tsx +++ b/src/features/run/TestTreeView.tsx @@ -112,27 +112,24 @@ export function TestStatusBar({ 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 outcome = counts.failed ? "failed" : counts.passed ? "passed" : counts.skipped ? "skipped" : null; const duration = results.summary.durationMs; return ( -
- +
+ {counts.failed > 0 && {tx`${counts.failed} failing`}} {counts.passed > 0 && {tx`${counts.passed} passed`}} {counts.skipped > 0 && {tx`${counts.skipped} ignored`}} - {counts.total === 0 && {running ? tx("Running…") : tx("No tests")}} + {!outcome && {running ? tx("Running…") : tx("No tests")}} + {duration !== undefined && {formatDuration(duration)}} - {duration !== undefined && {formatDuration(duration)}}
); }