diff --git a/ui/e2e/group-run.spec.ts b/ui/e2e/group-run.spec.ts index f222a75b8d..f70a371fad 100644 --- a/ui/e2e/group-run.spec.ts +++ b/ui/e2e/group-run.spec.ts @@ -1,4 +1,4 @@ -import { expect, test, type Page } from '@playwright/test'; +import { expect, test, type Locator, type Page } from '@playwright/test'; import { FakeControl, type FakeGroupRun } from './support/fake-control'; // A group run's page: one tree of its jobs, folders and nodes beside the timeline, the 40/60 split above @@ -541,6 +541,39 @@ test("jobs ticked beside a group run's graph are drawn as those jobs, closed, an await expect(members).toHaveCount(3); }); +test("an opened job's folder cards count its waiting nodes beside those done, and its folder boxes close one level at a time while the job is selected", async ({ page }) => { + const { fake, run } = server(['load_orders', 'stage_orders', 'orders_mart'], 160); + const job = run.members.find((m) => m.jobKey === 'load_orders')!; + job.nodes['model:load_orders_0'] = 'success'; + job.nodes['model:load_orders_1'] = 'running'; + await fake.install(page); + await page.setViewportSize({ width: 1600, height: 1000 }); + await page.goto(`/runs/${run.id}`); + await page.getByRole('tablist', { name: 'View' }).getByRole('tab', { name: 'Graph' }).click({ timeout: 20_000 }); + // Clicking the job selects it and opens it in place. + await page.locator('.svelte-flow__node-member').filter({ hasText: 'load_orders' }).click({ timeout: 20_000 }); + const folders = page.locator('.svelte-flow__node-folder'); + const boxes = page.locator('.svelte-flow__node-folderBox'); + await expect(folders).toHaveCount(1); + await expect(folders.locator('.status span')).toHaveText(['1 running', '1 ok', '158 waiting']); + + await folders.first().click(); + await expect(boxes).toHaveCount(1); + await folders.first().click(); + await expect(boxes).toHaveCount(2); + // A person clicks the header by its chevron: there, not under the selected job's box, the inner box closes. + const heads = boxes.locator('.folder-head'); + const press = async (head: Locator) => { + const at = (await head.boundingBox())!; + await page.mouse.click(at.x + 20, at.y + at.height / 2); + }; + await press(heads.last()); + await expect(boxes).toHaveCount(1); + await press(heads.first()); + await expect(boxes).toHaveCount(0); + await expect(folders).toHaveCount(1); +}); + test('a folder that shares its directory with another job ticks its own nodes, and ticks fully again after a node came back', async ({ page }) => { // Two jobs of 60 models each, both in sql/models/shared/part_0 and part_1: 30 of each job per folder. const { fake, run } = server(['load_orders', 'stage_orders'], 60); diff --git a/ui/src/lib/components/graph/compact-title.ts b/ui/src/lib/components/graph/compact-title.ts index e880941090..2a8916a314 100644 --- a/ui/src/lib/components/graph/compact-title.ts +++ b/ui/src/lib/components/graph/compact-title.ts @@ -140,5 +140,8 @@ const cardFamily = pageFamily('--font-mono', 'monospace'); /** The cards' name and status line font, as the status line measures it. */ export const measureText: Measure = measureIn(cardFamily, 0.62); +/** The folder cards' status line font, as the page sets `--font-sans` (Inter). */ +export const measureSans: Measure = measureIn(pageFamily('--font-sans', 'sans-serif'), 0.56); + /** The pills' name font: whatever the page sets `--font-node-compact` to. */ export const measureCompact: Measure = measureIn(pageFamily('--font-node-compact', 'sans-serif'), 0.66); diff --git a/ui/src/lib/components/graph/graph-canvas.svelte b/ui/src/lib/components/graph/graph-canvas.svelte index 1eeaed1ffd..2afcf6d0e8 100644 --- a/ui/src/lib/components/graph/graph-canvas.svelte +++ b/ui/src/lib/components/graph/graph-canvas.svelte @@ -192,9 +192,10 @@ /* Edges, plain, highlighted or selected, are drawn beneath every card, so they never take a card's click. The library raises edges from inside an open box to the box's contents' level, above the cards outside it; cards are put above every edge (and selected nodes are raised by at most about - 1000 per level of boxes). Open boxes (`parent`) keep the library's order, beneath the edges inside - them. An edge is hit only on its stroke. */ - .graph-canvas :global(.svelte-flow__node:not(.parent)) { + 1000 per level of boxes). Open boxes keep the library's order, beneath the edges inside them; they are + known by type, since the library's `parent` class is fixed when a node mounts, and a job card that + opens in place would stay raised above the folder boxes inside it. An edge is hit only on its stroke. */ + .graph-canvas :global(.svelte-flow__node:not(:is(.svelte-flow__node-memberBox, .svelte-flow__node-folderBox, .svelte-flow__node-job))) { z-index: 100000 !important; } .graph-canvas :global(.svelte-flow__edges svg) { diff --git a/ui/src/lib/components/lineage/folder-node.svelte b/ui/src/lib/components/lineage/folder-node.svelte index 46070f9085..d891c31aa0 100644 --- a/ui/src/lib/components/lineage/folder-node.svelte +++ b/ui/src/lib/components/lineage/folder-node.svelte @@ -5,15 +5,32 @@ import { Handle, Position, type NodeProps } from '@xyflow/svelte'; import type { GroupCard } from '$lib/lineage/catalog-graph'; import CompactFace from '$lib/components/graph/compact-face.svelte'; + import { measureSans } from '$lib/components/graph/compact-title'; + import { fonts } from '$lib/components/graph/fonts.svelte'; let { id, data }: NodeProps = $props(); const d = $derived(data as GroupCard); // Zoomed out, the folder's colour: anything running, as the run tree's rows do, then any failure, then any stale node, then ok. + // The status line's counts, most pressing first. When they don't fit in words, each keeps its dot and + // number; the card's title still names them all. + const counts = $derived( + [ + { n: d.running, word: 'running', mark: 'running' }, + { n: d.ok, word: 'ok', color: 'var(--sb-success)' }, + { n: d.stale, word: 'stale', color: 'var(--sb-stale)' }, + { n: d.failed, word: 'failed', color: 'var(--sb-error)' }, + { n: d.skipped, word: 'skipped', mark: 'skipped' }, + { n: d.waiting, word: 'waiting', mark: 'waiting' } + ].filter((c): c is typeof c & { n: number } => !!c.n) + ); + const said = $derived(counts.map((c) => `${c.n} ${c.word}`).join(', ')); + /** The card's 236 px less its border and the status line's padding; each count is a 6 px dot and a 5 px gap, 10 px apart. Measured again once the font has loaded. */ + const words = $derived((void fonts.ready, void fonts.version, counts.reduce((w, c) => w + 11 + measureSans(`${c.n} ${c.word}`, 11, 400), 10 * (counts.length - 1)) <= 236 - 2 - 32 - 10)); const tone = $derived(d.running ? 'var(--sb-running)' : d.failed ? 'var(--sb-error)' : d.stale ? 'var(--sb-stale)' : d.ok ? 'var(--sb-success)' : 'var(--sb-text-faint)'); -
+
@@ -22,12 +39,8 @@
- {#if d.running}{d.running} running{/if} - {#if d.ok}{d.ok} ok{/if} - {#if d.stale}{d.stale} stale{/if} - {#if d.failed}{d.failed} failed{/if} - {#if d.skipped}{d.skipped} skipped{/if} - {#if !d.ok && !d.stale && !d.failed && !d.running && !d.skipped}{d.empty ?? 'No builds'}{/if} + {#each counts as c (c.word)}{c.n}{#if words} {c.word}{/if}{/each} + {#if !counts.length}{d.empty ?? 'No builds'}{/if}
diff --git a/ui/src/lib/lineage/catalog-graph.ts b/ui/src/lib/lineage/catalog-graph.ts index 37d825b719..8c689e6175 100644 --- a/ui/src/lib/lineage/catalog-graph.ts +++ b/ui/src/lib/lineage/catalog-graph.ts @@ -102,7 +102,7 @@ export const topFolder = (node: CatalogNode): string => folderOf(node).split('/' /** A closed folder's card; `label` is its path below the open folder around it, when there is one. */ /** `noun` names what the folder counts: nodes, or jobs on a group's graph. */ -export type GroupCard = { group: string; label?: string; count: number; ok: number; stale: number; failed: number; running?: number; skipped?: number; dimmed?: boolean; noun?: string; empty?: string }; +export type GroupCard = { group: string; label?: string; count: number; ok: number; stale: number; failed: number; running?: number; skipped?: number; waiting?: number; dimmed?: boolean; noun?: string; empty?: string }; /** * A folder's card: how many nodes it holds, and how many last built fine, are stale or failed. A node @@ -120,7 +120,8 @@ export function groupCard(group: string, members: CatalogNode[]): GroupCard { failed: built.filter((n) => n.status === 'failed').length + inRun('fail'), running: inRun('run'), skipped: inRun('skip'), - // A folder of a run's nodes that haven't started is waiting; one the run ended without running, not run. - ...(live.length === members.length ? { empty: live.some((n) => n.liveStatus === 'wait') ? 'Waiting' : 'Not run' } : {}) + waiting: inRun('wait'), + // A folder of a run's nodes the run ended without running. + ...(live.length === members.length ? { empty: 'Not run' } : {}) }; }