diff --git a/.dependency-cruiser.mjs b/.dependency-cruiser.mjs index 01098dcd7..578c79475 100644 --- a/.dependency-cruiser.mjs +++ b/.dependency-cruiser.mjs @@ -15,7 +15,7 @@ const escape = (path) => path.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); const testFile = "(\\.test\\.tsx?|/test-[^/]+\\.tsx?)$"; const linkTestFile = "(\\.test\\.tsx?|/test-[^/]+\\.tsx?|/testing\\.ts)$"; // why: the console layers below the screens are plain TypeScript, so a test drives them without a browser. -const uiLibrary = "(^|node_modules/)(react|react-dom|recharts|@tanstack/[^/]+)(/|$)"; +const uiLibrary = "(^|node_modules/)(react|react-dom|recharts|@base-ui/react|@tanstack/[^/]+)(/|$)"; const fsOrProcess = "^(node:)?(fs|fs/promises|child_process)$"; // why: e2e imports the compiled package from dist/, which mirrors src/, so each component's rule covers its compiled copy too. @@ -252,6 +252,12 @@ export default { "^ui/src/screens/", { path: "^ui/src/(app|data|model)/" }, ), + direction( + "ui-base-ui-in-ds-only", + "only the console's design system imports Base UI; everything else uses its wrapped parts", + "^ui/src/(?!ds/)", + { path: "(^|node_modules/)@base-ui/react(/|$)" }, + ), direction( "cli-router-imports-no-component-values", "the CLI's router answers --help and a usage error before any component loads: these files reach another component only for types, by dynamic import, or statically for agent-identity alone, so the fast paths load no component code", diff --git a/.fallowrc.json b/.fallowrc.json index f281cd64e..6c0776880 100644 --- a/.fallowrc.json +++ b/.fallowrc.json @@ -48,6 +48,7 @@ "@fontsource-variable/geist", "@fontsource-variable/geist-mono", "recharts", + "@base-ui/react", "@tanstack/react-table", "@tanstack/react-virtual", // Recharts' peer dependency: installed for it, never imported by the console itself. diff --git a/docs/internal/DESIGN.md b/docs/internal/DESIGN.md index 7bfa7a3ec..b78f0b099 100644 --- a/docs/internal/DESIGN.md +++ b/docs/internal/DESIGN.md @@ -133,7 +133,8 @@ put together from them and draws nothing of its own that one of them already dra - **Sidebar.** The console's navigation, on the left of every signed-in page: the "SIMLOCK" wordmark (`--on-accent` on an `--accent` block), one link per page in a fixed order (Overview, - Workers, Leases, Waiting, Attention, Events, Usage), then at the bottom the connection as a status, + Attention, then the **Operate** group: Fleet, Leases, Queue; then the **Observe** group: + Activity, Usage; each group under its small label, hidden when collapsed), then at the bottom the connection as a status, "Signed in as " (hidden when collapsed, where the Sign out tooltip reads "Sign out ()"), **Sign out** (absent for a proxy person with no sign-out address) and the collapse button. A link is an icon and its label in `--text-muted`; the current one is `--text` on `--field` with a 2px `--accent` bar on its left and @@ -146,15 +147,21 @@ put together from them and draws nothing of its own that one of them already dra opens the links and the bottom block under it. - **Page.** A page that is not a list, as the overview: its title (`h1`) and its actions on the right, then its content. No subtitle: the title and what is under it say what the page is. -- **List and inspector.** Every page of things (workers, leases, waiting requests, attention - items, events) is a list on the left, 260–360px wide (wider for events), and the chosen thing in +- **List and inspector.** Fleet, Queue, Attention and Activity (workers, waiting requests, + attention items, events) are each a list on the left, 260–360px wide (wider for events), and the chosen thing in an inspector filling the rest. The list has a header (the page's title as `h1`, a short count in mono beside it, then its filters), its rows, and the pager under them. A row is one or two short lines: a status square, a title, one figure on the right, and at most one muted line or bar under them; the chosen row is `--surface` with a 2px `--accent` bar on its left and - `aria-current="page"`. The address names the chosen thing (`/workers/`). The inspector + `aria-current="page"`. The address names the chosen thing (`/fleet/`). The inspector has a breadcrumb, the thing's title (`h2`), one muted line under it, actions on the right, and then cards, facts, tabs and panels. +- **Table and drawer.** Leases is a toolbar (the filter chips on the left, a search box on the + right, at the page title's padding) over a table. Choosing a row opens a **drawer**: a 480px + panel (full width under 768px) at the right edge over the page, with a dim layer over everything + else, the sidebar included. It has a title (the holder), a 40px square close button (`IconButton`) + and tabs. Escape, the close button and the dim layer close it. It slides in once, when it opens, + and switching its tabs does not replay that. It uses no status colour of its own. - **Stat tiles.** A row of tiles: a label, a big number (`--text-xl`), and a short unit in mono beside it ("of 48", "last hour"). A tile that leads somewhere is a link as a whole. A tile shows only numbers its page already has; it never makes a request of its own. @@ -252,7 +259,7 @@ put together from them and draws nothing of its own that one of them already dra Short, and only where it says where something came from. Colour changes on hover take 120ms (`--duration`). Moves take 220ms (`--duration-move`) on one easing (`--ease`): the sidebar widens and narrows; a page rises 10px as it opens; a list slides in from the left and an -inspector from the right, again each time another thing is chosen; the chosen row's bar and a +inspector from the right, again each time another thing is chosen; a drawer from the right, once, when it opens; the chosen row's bar and a meter or share bar slide to their new place. Nothing loops, nothing moves on its own, and charts never animate. With `prefers-reduced-motion: reduce`, there are no transitions and no animations at all. diff --git a/e2e/console/attention.spec.ts b/e2e/console/attention.spec.ts index 559178763..9ea9fd69a 100644 --- a/e2e/console/attention.spec.ts +++ b/e2e/console/attention.spec.ts @@ -190,13 +190,13 @@ test.describe("the attention view", () => { await expect(page.getByRole("heading", { level: 2, name: "worker-b" })).toBeVisible(); await expect(page.getByRole("link", { name: "Open worker" })).toHaveAttribute( "href", - `/workers/${encodeURIComponent(b?.id ?? "")}`, + `/fleet/${encodeURIComponent(b?.id ?? "")}`, ); await expect(facts(page)).toContainText("Leases still held"); const recent = page.getByRole("region", { name: "Recent events" }); await expect(recent.getByRole("link", { name: /worker\.drain-started/ })).toHaveAttribute( "href", - /^\/events\/.+/, + /^\/activity\/.+/, ); } finally { await disposeFleet(fleet); @@ -485,7 +485,7 @@ test.describe("the attention view", () => { await expect(page.getByRole("heading", { level: 2, name: "old-worker" })).toBeVisible(); await follow(page.getByRole("link", { name: "Open worker" })); - await expect(page).toHaveURL(/\/workers\/wrk_old$/); + await expect(page).toHaveURL(/\/fleet\/wrk_old$/); } finally { hangUp(); await gateway.dispose(); diff --git a/e2e/console/events.spec.ts b/e2e/console/events.spec.ts index c1f2ad4ee..752402d19 100644 --- a/e2e/console/events.spec.ts +++ b/e2e/console/events.spec.ts @@ -47,10 +47,10 @@ async function cliEvents(daemon: RunningDaemon): Promise { .map((line) => JSON.parse(line) as Envelope); } -async function openEvents(page: Page, daemon: RunningDaemon, path = "/events"): Promise { +async function openEvents(page: Page, daemon: RunningDaemon, path = "/activity"): Promise { await page.goto(new URL(path, daemon.url).href); await signIn(page, daemon.tokens.operator); - await expect(page.getByRole("heading", { level: 1, name: "Events" })).toBeVisible(); + await expect(page.getByRole("heading", { level: 1, name: "Activity" })).toBeVisible(); } function feed(page: Page): Locator { @@ -80,7 +80,7 @@ async function shownEvents(page: Page): Promise { [ item.querySelector("time")?.getAttribute("datetime") ?? "", name?.textContent ?? "", - link?.getAttribute("href")?.replace("/events/", "") ?? "", + link?.getAttribute("href")?.replace("/activity/", "") ?? "", ].join(" "), ); } @@ -97,7 +97,7 @@ function asShown(event: Envelope): string { } async function openEvent(page: Page, id: string): Promise { - const link = feed(page).locator(`a[href="/events/${encodeURIComponent(id)}"]`); + const link = feed(page).locator(`a[href="/activity/${encodeURIComponent(id)}"]`); await feed(page).evaluate((box) => box.scrollTo({ top: 0 })); for (let step = 0; step < 200 && (await link.count()) === 0; step += 1) { await feed(page).evaluate((box) => box.scrollBy({ top: box.clientHeight / 2 })); @@ -129,7 +129,7 @@ test.describe("the events page", () => { await expect(granted).toHaveCount(1, { timeout: 1_000 }); await granted.click(); await expect(title(page)).toHaveText("lease.granted"); - await expect(page).toHaveURL(/\/events\/[^/]+$/); + await expect(page).toHaveURL(/\/activity\/[^/]+$/); await expect(page.getByText("leaseId", { exact: true })).toBeVisible(); await expect(page.locator("dd", { hasText: new RegExp(`^${id}$`) })).toBeVisible(); @@ -176,7 +176,7 @@ test.describe("the events page", () => { await openEvent(page, (started as Envelope).id); - await expect(page).toHaveURL(new RegExp(`/events/${(started as Envelope).id}$`)); + await expect(page).toHaveURL(new RegExp(`/activity/${(started as Envelope).id}$`)); await expect(title(page)).toHaveText("daemon.started"); await expect(page.getByRole("heading", { level: 2, name: "Payload" })).toBeVisible(); await page.reload(); @@ -189,11 +189,11 @@ test.describe("the events page", () => { test("an event the feed does not hold says so and links back", async ({ page }) => { const host = await startDaemon("worker", { driverScript: { ios: IOS } }); try { - await openEvents(page, host, "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/events/evt_not_there"); + await openEvents(page, host, "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/activity/evt_not_there"); await expect(page.getByText("Event not in the last hour.")).toBeVisible(); - await page.getByRole("link", { name: "Back to events" }).click(); - await expect(page).toHaveURL(/\/events$/); + await page.getByRole("link", { name: "Back to Activity" }).click(); + await expect(page).toHaveURL(/\/activity$/); } finally { await host.dispose(); } @@ -330,13 +330,13 @@ async function keyboardOnly(page: Page, host: RunningDaemon, tab: string): Promi await page.keyboard.press("Enter"); await expect(page.getByRole("navigation").first()).toBeVisible(); - const nav = page.getByRole("link", { name: "Events", exact: true }); + const nav = page.getByRole("link", { name: "Activity", exact: true }); for (let step = 0; step < 30 && !(await isFocused(nav)); step += 1) { await page.keyboard.press(tab); } await expect(nav).toBeFocused(); await page.keyboard.press("Enter"); - await expect(page.getByRole("heading", { level: 1, name: "Events" })).toBeVisible(); + await expect(page.getByRole("heading", { level: 1, name: "Activity" })).toBeVisible(); await expect(rows(page).filter({ hasText: "lease.granted" })).not.toHaveCount(0); const all = page.getByRole("radio", { name: "All" }); @@ -358,7 +358,7 @@ async function keyboardOnly(page: Page, host: RunningDaemon, tab: string): Promi await expect(feed(page)).toBeFocused(); await page.keyboard.press(tab); await page.keyboard.press("Enter"); - await expect(page).toHaveURL(/\/events\/[^/?]+\?subject=lease$/); + await expect(page).toHaveURL(/\/activity\/[^/?]+\?subject=lease$/); } async function isFocused(locator: Locator): Promise { diff --git a/e2e/console/fixtures.ts b/e2e/console/fixtures.ts index 357aa9cb1..7c8c2a1e6 100644 --- a/e2e/console/fixtures.ts +++ b/e2e/console/fixtures.ts @@ -503,14 +503,19 @@ export async function signIn(page: Page, token: string): Promise { export const NAV = [ { label: "Overview", path: "/" }, - { label: "Workers", path: "/workers" }, - { label: "Leases", path: "/leases" }, - { label: "Waiting", path: "/waiting" }, { label: "Attention", path: "/attention" }, - { label: "Events", path: "/events" }, + { label: "Fleet", path: "/fleet" }, + { label: "Leases", path: "/leases" }, + { label: "Queue", path: "/queue" }, + { label: "Activity", path: "/activity" }, { label: "Usage", path: "/usage" }, ] as const; +export const NAV_GROUPS = [ + { label: "Operate", links: ["Fleet", "Leases", "Queue"] }, + { label: "Observe", links: ["Activity", "Usage"] }, +] as const; + export const NAV_LABELS = NAV.map((entry) => entry.label); // why: pages slide and fade in; an audit or a measurement taken mid-way reads a half-faded colour. diff --git a/e2e/console/leases.spec.ts b/e2e/console/leases.spec.ts index 0eb3f2d51..09d2eb117 100644 --- a/e2e/console/leases.spec.ts +++ b/e2e/console/leases.spec.ts @@ -117,13 +117,20 @@ async function untilTheDaemonSays( async function openLeases(page: Page, daemon: RunningDaemon, path = "/leases"): Promise { await page.goto(new URL(path, daemon.url).toString()); await signIn(page, daemon.tokens.operator); - await expect(page.getByRole("heading", { level: 1, name: "Leases" })).toBeVisible(); + // why: the drawer hides the page behind it from assistive technology, so a direct load finds the heading by hidden role too. + await expect( + page.getByRole("heading", { includeHidden: true, level: 1, name: "Leases" }), + ).toBeVisible(); } function leaseRow(page: Page, id: string): Locator { return page - .getByRole("list", { name: "Leases" }) - .locator(`a[href="/leases/${encodeURIComponent(id)}/"]`); + .locator("main tbody tr") + .filter({ has: page.locator(`a[href^="/leases/${encodeURIComponent(id)}/"]`) }); +} + +function rowLink(page: Page, id: string): Locator { + return leaseRow(page, id).locator("a").first(); } function inspectorTitle(page: Page, name: string | RegExp): Locator { @@ -146,6 +153,12 @@ async function hasHorizontalScroll(page: Page): Promise { ); } +async function boxOf(locator: Locator): Promise<{ x: number; width: number }> { + const box = await locator.boundingBox(); + if (box === null) throw new Error("the element has no box"); + return box; +} + test.describe("the leases page", () => { test("every lease in simlock list --leases appears in the fleet list", async ({ page }) => { const fleet = await startFleet([ @@ -171,9 +184,7 @@ test.describe("the leases page", () => { await openLeases(page, fleet.gateway); - await expect(page.getByRole("list", { name: "Leases" }).getByRole("listitem")).toHaveCount( - listed.length, - ); + await expect(page.locator("main tbody tr")).toHaveCount(listed.length); await expect(page.getByText(`${listed.length} held`)).toBeVisible(); for (const lease of listed) { const row = leaseRow(page, lease.id); @@ -208,7 +219,7 @@ test.describe("the leases page", () => { } }); - test("with no lease named in the address the first lease shows in the inspector, and the address stays", async ({ + test("a lease row opens a dialog named after its holder at the lease's address, on its Details tab, over the table, and nothing opens by itself", async ({ page, }) => { const host = await startDaemon("worker", { driverScript: { ios: IOS } }); @@ -219,9 +230,227 @@ test.describe("the leases page", () => { await openLeases(page, host); - await expect(inspectorTitle(page, /agent-first/)).toBeVisible(); - await expect(leaseRow(page, first?.id ?? "")).toHaveAttribute("aria-current", "page"); + await expect(page.getByRole("dialog")).toHaveCount(0); + expect(new URL(page.url()).pathname).toBe("/leases"); + + await leaseRow(page, first?.id ?? "").click(); + + const drawer = page.getByRole("dialog", { name: /agent-first/ }); + await expect(drawer).toBeVisible(); + expect(new URL(page.url()).pathname).toBe(`/leases/${encodeURIComponent(first?.id ?? "")}/`); + await expect(drawer.getByRole("tab", { name: "Details" })).toHaveAttribute( + "aria-selected", + "true", + ); + await expect(fact(page, "Device", "UDID")).not.toHaveText("—"); + await expect(page.locator("main table")).toBeVisible(); + } finally { + await host.dispose(); + } + }); + + test("loading /leases/ directly opens the drawer over the table", async ({ page }) => { + const host = await startDaemon("worker", { driverScript: { ios: IOS } }); + try { + await leaseOverSocket(host, "agent-direct"); + const [lease] = (await listLeases(host)) as [ListedLease]; + + await openLeases(page, host, `/leases/${encodeURIComponent(lease.id)}/`); + + await expect(page.getByRole("dialog", { name: /agent-direct/ })).toBeVisible(); + await expect(leaseRow(page, lease.id)).toBeVisible(); + } finally { + await host.dispose(); + } + }); + + test("loaded directly at a lease's address, closing the drawer replaces the address with /leases and focus goes to the heading", async ({ + page, + }) => { + const host = await startDaemon("worker", { driverScript: { ios: IOS } }); + try { + await leaseOverSocket(host, "agent-direct"); + const [lease] = (await listLeases(host)) as [ListedLease]; + await openLeases(page, host, `/leases/${encodeURIComponent(lease.id)}/`); + const drawer = page.getByRole("dialog", { name: /agent-direct/ }); + await expect(drawer).toBeVisible(); + const entries = await page.evaluate(() => window.history.length); + + await page.keyboard.press("Escape"); + + await expect(drawer).toHaveCount(0); expect(new URL(page.url()).pathname).toBe("/leases"); + expect(await page.evaluate(() => window.history.length)).toBe(entries); + await expect(page.getByRole("heading", { level: 1, name: "Leases" })).toBeFocused(); + } finally { + await host.dispose(); + } + }); + + test("the dim layer covers the sidebar: its links cannot be clicked while the drawer is open", async ({ + page, + }) => { + const host = await startDaemon("worker", { driverScript: { ios: IOS } }); + try { + await leaseOverSocket(host, "agent-dim"); + const [lease] = (await listLeases(host)) as [ListedLease]; + await openLeases(page, host); + await leaseRow(page, lease.id).click(); + await expect(page.getByRole("dialog")).toBeVisible(); + + const covered = await page.evaluate(() => { + const link = document.querySelector(".sidebar-nav a"); + const box = link?.getBoundingClientRect(); + if (box === undefined) return undefined; + const top = document.elementFromPoint(box.x + box.width / 2, box.y + box.height / 2); + return top?.classList.contains("drawer-dim"); + }); + + expect(covered).toBe(true); + } finally { + await host.dispose(); + } + }); + + test("the drawer animates once: switching its tabs does not restart the animation", async ({ + page, + }) => { + const host = await startDaemon("worker", { driverScript: { ios: IOS } }); + try { + await leaseOverSocket(host, "agent-motion"); + const [lease] = (await listLeases(host)) as [ListedLease]; + await openLeases(page, host); + await page.evaluate(() => { + const counted = window as unknown as { drawerStarts: number }; + counted.drawerStarts = 0; + document.addEventListener( + "animationstart", + (event) => { + if ((event.target as Element).classList.contains("drawer")) counted.drawerStarts += 1; + }, + true, + ); + }); + + await leaseRow(page, lease.id).click(); + await expect(page.getByRole("dialog")).toBeVisible(); + for (const name of ["Screen", "Details", "Screen", "Details"]) { + await page.getByRole("tab", { name }).click(); + } + await page.waitForTimeout(400); + + expect( + await page.evaluate(() => (window as unknown as { drawerStarts: number }).drawerStarts), + ).toBe(1); + } finally { + await host.dispose(); + } + }); + + test("at 360px wide the drawer fills the width and the page has no sideways scroll", async ({ + page, + }) => { + const host = await startDaemon("worker", { driverScript: { ios: IOS } }); + try { + await leaseOverSocket(host, "agent-narrow"); + const [lease] = (await listLeases(host)) as [ListedLease]; + await page.setViewportSize({ height: 740, width: 360 }); + await openLeases(page, host, `/leases/${encodeURIComponent(lease.id)}/`); + + const drawer = page.getByRole("dialog"); + await expect(drawer).toBeVisible(); + expect((await drawer.boundingBox())?.width).toBeCloseTo(360, 0); + expect(await hasHorizontalScroll(page)).toBe(false); + } finally { + await host.dispose(); + } + }); + + test("the drawer's close button is 40px tall with the button border", async ({ page }) => { + const host = await startDaemon("worker", { driverScript: { ios: IOS } }); + try { + await leaseOverSocket(host, "agent-icon"); + const [lease] = (await listLeases(host)) as [ListedLease]; + await openLeases(page, host, `/leases/${encodeURIComponent(lease.id)}/`); + + const shape = await page + .getByRole("dialog") + .getByRole("button", { name: "Close" }) + .evaluate((element) => { + const style = getComputedStyle(element); + return { border: style.borderTopWidth, height: element.getBoundingClientRect().height }; + }); + + expect(shape).toEqual({ border: "1px", height: 40 }); + } finally { + await host.dispose(); + } + }); + + test("the Events tab lists the events that name the lease", async ({ page }) => { + const host = await startDaemon("worker", { driverScript: { ios: IOS } }); + try { + await leaseOverSocket(host, "agent-events"); + await leaseOverSocket(host, "agent-other"); + const [lease] = (await listLeases(host)) as [ListedLease, ListedLease]; + await openLeases(page, host); + await leaseRow(page, lease.id).click(); + + await page.getByRole("tab", { name: "Events" }).click(); + + const events = page.getByRole("dialog").getByRole("tabpanel"); + await expect(events.getByText("lease.granted")).toHaveCount(1); + } finally { + await host.dispose(); + } + }); + + test("the search sets ?q= without adding history entries, a lease opened from it keeps ?q=, and closing returns to the filtered table", async ({ + page, + }) => { + const host = await startDaemon("worker", { driverScript: { ios: IOS } }); + try { + await leaseOverSocket(host, "agent-needle"); + await leaseOverSocket(host, "agent-hay"); + const found = (await listLeases(host)).find((lease) => lease.requesterId === "agent-needle"); + await openLeases(page, host, "/leases?page=2"); + const entries = await page.evaluate(() => window.history.length); + + await page.getByRole("searchbox", { name: "Search leases" }).pressSequentially("NEEDLE"); + + await expect(page.locator("main tbody tr")).toHaveCount(1); + expect(new URL(page.url()).search).toBe("?q=NEEDLE"); + expect(await page.evaluate(() => window.history.length)).toBe(entries); + + await leaseRow(page, found?.id ?? "").click(); + await expect(page.getByRole("dialog")).toBeVisible(); + expect(new URL(page.url()).search).toBe("?q=NEEDLE"); + + await page.keyboard.press("Escape"); + await expect(page.getByRole("dialog")).toHaveCount(0); + expect(new URL(page.url()).search).toBe("?q=NEEDLE"); + await expect(page.locator("main tbody tr")).toHaveCount(1); + } finally { + await host.dispose(); + } + }); + + test("the toolbar puts the filter chips on the left and the search box on the right, at the page title's padding", async ({ + page, + }) => { + const host = await startDaemon("worker", { driverScript: { ios: IOS } }); + try { + await leaseOverSocket(host, "agent-bar"); + await openLeases(page, host); + + const title = await boxOf(page.getByRole("heading", { level: 1, name: "Leases" })); + const chips = await boxOf(page.getByRole("group", { name: "Filter leases" })); + const search = await boxOf(page.getByRole("searchbox", { name: "Search leases" })); + const table = await boxOf(page.locator("main table")); + + expect(chips.x).toBeCloseTo(title.x, 0); + expect(search.x).toBeGreaterThan(chips.x + chips.width); + expect(search.x + search.width).toBeCloseTo(table.x + table.width, 0); } finally { await host.dispose(); } @@ -248,9 +477,6 @@ test.describe("the leases page", () => { await leaseRow(page, granted.id).click(); await expect(inspectorTitle(page, /ci-runner-3/)).toBeVisible(); - await expect( - page.getByRole("navigation", { name: "Breadcrumb" }).getByText(granted.id), - ).toBeVisible(); await expect(fact(page, "Lease", "Holder")).toHaveText(`ci-runner-3 ${ci.id}`); await expect(fact(page, "Device", "Worker")).toHaveText("worker-a"); await expect(fact(page, "Device", "Model")).toHaveText(granted.device); @@ -265,6 +491,7 @@ test.describe("the leases page", () => { await expect(fact(page, "Device", "UDID")).toHaveText(granted.udid); // A worker's own lease, which the gateway did not issue, opens too. + await page.keyboard.press("Escape"); await leaseRow(page, local?.id ?? "").click(); await expect(inspectorTitle(page, /local-agent/)).toBeVisible(); await expect(fact(page, "Device", "Worker")).toHaveText("worker-b"); @@ -320,7 +547,7 @@ test.describe("the leases page", () => { await expect(leaseRow(page, later.id)).toBeVisible(); await page.getByRole("radio", { name: "Android" }).check(); - await expect(page.getByText("No leases match this filter.")).toBeVisible(); + await expect(page.getByText("No leases match this filter or search.")).toBeVisible(); } finally { await host.dispose(); } @@ -333,7 +560,7 @@ test.describe("the leases page", () => { await leaseOverSocket(host, "agent-2"); const [released, kept] = (await listLeases(host)) as [ListedLease, ListedLease]; await openLeases(page, host); - await expect(page.getByRole("list", { name: "Leases" }).getByRole("listitem")).toHaveCount(2); + await expect(page.locator("main tbody tr")).toHaveCount(2); expect((await host.cli(["release", released.id])).code).toBe(0); await untilTheDaemonSays(host, (leases) => leases.every((lease) => lease.id !== released.id)); @@ -345,7 +572,7 @@ test.describe("the leases page", () => { } }); - test("a lease's page says it is not found once the lease is released, with a way back", async ({ + test('a lease that ends while its drawer is open, and an address naming a lease never held, show "This lease is not held."', async ({ page, }) => { const host = await startDaemon("worker", { driverScript: { ios: IOS } }); @@ -358,22 +585,14 @@ test.describe("the leases page", () => { expect((await host.cli(["release", released.id])).code).toBe(0); - await expect(page.getByText("Lease not found.")).toBeVisible(); + const drawer = page.getByRole("dialog"); + await expect(drawer.getByText("This lease is not held.")).toBeVisible(); await expect(fact(page, "Device", "UDID")).toHaveCount(0); - await page.getByRole("link", { name: "All leases" }).click(); - expect(new URL(page.url()).pathname).toBe("/leases"); - } finally { - await host.dispose(); - } - }); - - test("an address naming no lease says it is not found", async ({ page }) => { - const host = await startDaemon("worker", { driverScript: { ios: IOS } }); - try { - await openLeases(page, host, "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/leases/lse_nobody/"); + await expect(drawer.getByRole("button", { name: "Close" })).toBeVisible(); - await expect(page.getByText("Lease not found.")).toBeVisible(); - await expect(page.getByRole("link", { name: "All leases" })).toBeVisible(); + await page.goto(new URL("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/leases/lse_nobody/", host.url).toString()); + await expect(page.getByRole("dialog").getByText("This lease is not held.")).toBeVisible(); + await expect(page.locator("main")).toContainText("No leases."); } finally { await host.dispose(); } @@ -423,6 +642,7 @@ test.describe("the leases page", () => { await leaseRow(page, granted.id).click(); await expect(inspectorTitle(page, /ci-runner-3/)).toBeVisible(); await expect(fact(page, "Device", "UDID")).toHaveText(granted.udid); + await page.getByRole("tab", { name: "Screen" }).click(); await expect(page.getByRole("button", { name: "Show screen" })).toBeVisible(); expect(await hasHorizontalScroll(page)).toBe(false); } finally { @@ -456,13 +676,10 @@ test.describe("the leases page", () => { page.getByRole("navigation", { name: "Console" }).getByRole("link", { name: "Leases" }), ); await expect(page.getByRole("heading", { level: 1, name: "Leases" })).toBeVisible(); - await follow(leaseRow(page, granted.id)); + await follow(rowLink(page, granted.id)); await expect(inspectorTitle(page, /ci-runner-3/)).toBeVisible(); - await expect(page.getByRole("navigation", { name: "Breadcrumb" })).toContainText(granted.id); - await follow( - page.getByRole("navigation", { name: "Breadcrumb" }).getByRole("link", { name: "Leases" }), - ); - expect(new URL(page.url()).pathname).toBe("/leases"); + await page.keyboard.press("Escape"); + await expect.poll(() => new URL(page.url()).pathname).toBe("/leases"); } finally { await host.dispose(); } diff --git a/e2e/console/long-lists.spec.ts b/e2e/console/long-lists.spec.ts index 6688107cb..1c92ac24a 100644 --- a/e2e/console/long-lists.spec.ts +++ b/e2e/console/long-lists.spec.ts @@ -162,7 +162,7 @@ function rowIds(list: Locator, section: string): Promise { } function leaseRows(page: Page): Locator { - return pane(page, "Leases").getByRole("list", { name: "Leases" }); + return page.locator("main tbody"); } function ids(from: number, to: number, prefix = "lse"): string[] { @@ -287,9 +287,9 @@ test.describe("long lists page", () => { return { leases: listed }; }); await open(page, daemon, "/leases?page=2"); - const row = leaseRows(page).getByRole("listitem").nth(2); + const row = leaseRows(page).locator("tr").nth(2); const link = row.getByRole("link"); - const expires = row.locator(".list-aside"); + const expires = row.locator("td").last(); await expect(link).toHaveAttribute("href", "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/leases/lse_0028/?page=2"); await link.focus(); await expect(link).toBeFocused(); @@ -313,17 +313,52 @@ test.describe("long lists page", () => { expect(await rowIds(leaseRows(page), "/leases")).toEqual(ids(26, 50)); await page.keyboard.press("Enter"); await expect(page).toHaveURL(/\/leases\/lse_0028\/\?page=2$/); - await expect(leaseRows(page).locator('a[href^="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/leases/lse_0028/"]')).toHaveAttribute( - "aria-current", - "page", - ); + await expect(page.getByRole("dialog")).toBeVisible(); + }); + + for (const how of ["Escape", "the close button", "the dim layer"] as const) { + test(`${how} closes a lease's drawer and returns to /leases keeping ?page=2&size=25, with focus on the row that opened it and Back not reopening it`, async ({ + daemon, + page, + }) => { + await answer(page, "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/v1/leases", () => ({ leases: leases(60) })); + await open(page, daemon, "/leases?page=2&size=25"); + const row = leaseRows(page).locator('a[href^="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/leases/lse_0028/"]'); + await row.click(); + const drawer = page.getByRole("dialog"); + await expect(drawer).toBeVisible(); + await expect(page).toHaveURL(/\/leases\/lse_0028\/\?page=2&size=25$/); + + if (how === "Escape") await page.keyboard.press("Escape"); + else if (how === "the close button") + await drawer.getByRole("button", { name: "Close" }).click(); + else await page.locator(".drawer-dim").click({ position: { x: 10, y: 10 } }); + + await expect(drawer).toHaveCount(0); + await expect(page).toHaveURL(/\/leases\?page=2&size=25$/); + await expect(row).toBeFocused(); + await page.goBack(); + await expect(page.getByRole("dialog")).toHaveCount(0); + expect(new URL(page.url()).pathname).not.toMatch(/^\/leases\/./); + }); + } + + test("changing the leases search goes back to page 1", async ({ daemon, page }) => { + await answer(page, "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/v1/leases", () => ({ leases: leases(60) })); + await open(page, daemon, "/leases?page=2"); + await expect(pager(page, "Leases").locator(".pager-range")).toHaveText("26–50 of 60"); + + await page.getByRole("searchbox", { name: "Search leases" }).fill("lse_00"); + + await expect(pager(page, "Leases").locator(".pager-range")).toHaveText("1–25 of 60"); + await expect(page).toHaveURL(/\/leases\?q=lse_00$/); }); test("the pager is hidden when every row fits on one page", async ({ daemon, page }) => { let count = 25; await answer(page, "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/v1/leases", () => ({ leases: leases(count) })); await open(page, daemon, "/leases"); - await expect(leaseRows(page).getByRole("listitem")).toHaveCount(25); + await expect(leaseRows(page).locator("tr")).toHaveCount(25); await expect(pager(page, "Leases")).toHaveCount(0); // One row more and the list needs a second page: the pager shows. @@ -350,7 +385,7 @@ test.describe("long lists page", () => { label: `worker-${pad(index + 1)}`, })); await answer(page, "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/v1/workers", () => ({ workers })); - await open(page, daemon, "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/workers/wrk_0001"); + await open(page, daemon, "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/fleet/wrk_0001"); const devicesTable = page.getByRole("region", { name: "Devices" }).locator("table"); const deviceIds = async () => (await devicesTable.locator("tbody tr td:first-child").allTextContents()).map( @@ -364,7 +399,7 @@ test.describe("long lists page", () => { await expect(pager(page, "Devices").locator(".pager-range")).toHaveText("51–60 of 60"); expect(await deviceIds()).toEqual(ids(51, 60, "dev")); - expect(await rowIds(pane(page, "Workers"), "/workers")).toEqual(ids(26, 30, "wrk")); + expect(await rowIds(pane(page, "Fleet"), "/fleet")).toEqual(ids(26, 30, "wrk")); expect(Object.fromEntries(new URL(page.url()).searchParams)).toEqual({ "devices-page": "3", page: "2", @@ -388,23 +423,23 @@ test.describe("long lists page", () => { label: `worker-${pad(index + 1)}`, })); await answer(page, "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/v1/workers", () => ({ workers })); - await open(page, daemon, "/workers"); - const rows = pane(page, "Workers").getByRole("list", { name: "Workers" }); + await open(page, daemon, "/fleet"); + const rows = pane(page, "Fleet").getByRole("list", { name: "Workers" }); const range = pager(page, "Workers").locator(".pager-range"); - expect(await rowIds(rows, "/workers")).toEqual(ids(1, 25, "wrk")); + expect(await rowIds(rows, "/fleet")).toEqual(ids(1, 25, "wrk")); await expect(range).toHaveText("1–25 of 30"); await pager(page, "Workers").getByRole("button", { name: "Next" }).click(); await expect(range).toHaveText("26–30 of 30"); - expect(await rowIds(rows, "/workers")).toEqual(ids(26, 30, "wrk")); + expect(await rowIds(rows, "/fleet")).toEqual(ids(26, 30, "wrk")); await expect(pager(page, "Workers").getByLabel("Per page").locator("option")).toHaveText([ "25", "50", "100", ]); await pager(page, "Workers").getByLabel("Per page").selectOption("50"); - await expect(page).toHaveURL(/\/workers\?size=50$/); - expect(await rowIds(rows, "/workers")).toEqual(ids(1, 30, "wrk")); + await expect(page).toHaveURL(/\/fleet\?size=50$/); + expect(await rowIds(rows, "/fleet")).toEqual(ids(1, 30, "wrk")); await expect(pager(page, "Workers")).toHaveCount(0); }); }); @@ -482,7 +517,7 @@ test.describe("the events feed", () => { }) => { const replay = events(10_000); await answer(page, "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/v1/events", () => ({ events: replay })); - await open(page, daemon, "/events"); + await open(page, daemon, "/activity"); await expect.poll(() => eventsHeld(page)).toBe(10_000); const rows = feed(page).getByRole("listitem"); @@ -511,7 +546,7 @@ test.describe("the events feed", () => { }); const replay = events(1_000); await answer(page, "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/v1/events", () => ({ events: replay })); - await open(page, host, "/events"); + await open(page, host, "/activity"); await expect.poll(() => eventsHeld(page)).toBe(1_000); await scrollDown(page); @@ -544,7 +579,7 @@ test.describe("the events feed", () => { }); const replay = events(1_000); await answer(page, "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/v1/events", () => ({ events: replay })); - await open(page, host, "/events"); + await open(page, host, "/activity"); await expect.poll(() => eventsHeld(page)).toBe(1_000); await scrollDown(page); await client.renewLease({ leaseId: grant.lease.id }); @@ -583,7 +618,7 @@ test.describe("the events feed", () => { test("choosing another filter starts the feed again at the top", async ({ daemon, page }) => { const replay = events(1_000); await answer(page, "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/v1/events", () => ({ events: replay })); - await open(page, daemon, "/events"); + await open(page, daemon, "/activity"); await expect.poll(() => eventsHeld(page)).toBe(1_000); await scrollDown(page); @@ -706,7 +741,7 @@ test.describe("a single host with 300 leases and 5,000 events", () => { seeded, }) => { const { host } = seeded; - await open(page, host, "/events"); + await open(page, host, "/activity"); await expect.poll(() => eventsHeld(page)).toBeGreaterThanOrEqual(EVENTS); const held = await eventsHeld(page); @@ -748,7 +783,7 @@ test.describe("a single host with 300 leases and 5,000 events", () => { const oldest = (await recentEvents(host)).reduce((a, b) => b.timestamp < a.timestamp || (b.timestamp === a.timestamp && b.seq < a.seq) ? b : a, ); - expect(run.lastHref).toBe(`/events/${encodeURIComponent(oldest.id)}`); + expect(run.lastHref).toBe(`/activity/${encodeURIComponent(oldest.id)}`); expect(run.blank).toBe(0); expect(run.most).toBeLessThan(100); expect(run.p95).toBeLessThan(50); @@ -779,19 +814,25 @@ test.describe("a single host with 300 leases and 5,000 events", () => { for (const path of [ ...NAV.map((entry) => entry.path), "/leases?page=12", - `/workers/${encodeURIComponent(seeded.worker)}?devices-page=2`, + `/fleet/${encodeURIComponent(seeded.worker)}?devices-page=2`, `/leases/${encodeURIComponent(lease)}/`, ]) { await page.goto(new URL(path, seeded.host.url).href); - await expect(page.locator("#main").getByRole("heading").first()).toBeVisible(); + await expect( + page + .locator("#main") + .getByRole("heading", { includeHidden: path.startsWith("/leases/") }) + .first(), + ).toBeVisible(); await expect(page.locator("#main")).not.toContainText("Loading…"); - if (path === "/events") { + if (path.startsWith("/leases/")) await expect(page.getByRole("dialog")).toBeVisible(); + if (path === "/activity") { await expect.poll(() => eventsHeld(page)).toBeGreaterThanOrEqual(EVENTS); await feed(page).evaluate((box) => { box.scrollTop = box.scrollHeight / 3; }); } - if (path.startsWith("/leases?") || path.startsWith("/workers/")) { + if (path.startsWith("/leases?") || path.startsWith("/fleet/")) { await expect(page.locator(".pager").first()).toBeVisible(); } await settled(page); diff --git a/e2e/console/overview.spec.ts b/e2e/console/overview.spec.ts index 6ddd8e237..ffd3bccc3 100644 --- a/e2e/console/overview.spec.ts +++ b/e2e/console/overview.spec.ts @@ -225,16 +225,43 @@ test.describe("the Overview's figures", () => { } }); - test("the Waiting page's Wait p95 equals GET /v1/stats?since=1h totals.wait.p95, also when opened as /waiting?range=7d", async ({ + test("Overview's tiles and links land on /queue, /fleet and /activity, not Not found", async ({ + page, + }) => { + const host = await startDaemon("worker", { driverScript: { ios: IOS } }); + try { + const links = [ + { follow: () => tile(page, "Waiting").getByRole("link").click(), path: "/queue" }, + { follow: () => tile(page, "Workers").getByRole("link").click(), path: "/fleet" }, + { follow: () => page.getByRole("link", { name: /^All \d+$/ }).click(), path: "/fleet" }, + { follow: () => page.getByRole("link", { name: "All events" }).click(), path: "/activity" }, + ]; + await openOverview(page, host); + for (const { follow, path } of links) { + await page.goto(new URL("/", host.url).toString()); + await expect(page.getByRole("heading", { level: 1, name: "Overview" })).toBeVisible(); + await follow(); + await expect(page, path).toHaveURL(new RegExp(`${path}$`)); + await expect(page.getByRole("heading", { level: 1, name: "Page not found" })).toHaveCount( + 0, + ); + await expect(page.getByRole("heading", { level: 1 })).toBeVisible(); + } + } finally { + await host.dispose(); + } + }); + + test("the Queue page's Wait p95 equals GET /v1/stats?since=1h totals.wait.p95, also when opened as /queue?range=7d", async ({ page, }) => { const host = await startDaemon("worker", { config: ONE_DEVICE, driverScript: { ios: IOS } }); try { await scriptedRun(host); const stats = await statsOf(host, "1h"); - await page.goto(new URL("/waiting?range=7d", host.url).toString()); + await page.goto(new URL("/queue?range=7d", host.url).toString()); await signIn(page, host.tokens.operator); - await expect(page.getByRole("heading", { level: 1, name: "Waiting" })).toBeVisible(); + await expect(page.getByRole("heading", { level: 1, name: "Queue" })).toBeVisible(); await expect(page.getByRole("radio")).toHaveCount(0); await expect(page.locator("#main")).toContainText( diff --git a/e2e/console/screen.spec.ts b/e2e/console/screen.spec.ts index db672635b..746514f0b 100644 --- a/e2e/console/screen.spec.ts +++ b/e2e/console/screen.spec.ts @@ -56,6 +56,7 @@ async function cleanup(started: StreamingHost): Promise { async function openLeasePage(page: Page, host: RunningDaemon, lease: string): Promise { await page.goto(new URL(`/leases/${encodeURIComponent(lease)}`, host.url).toString()); await signIn(page, host.tokens.operator); + await page.getByRole("tab", { name: "Screen" }).click(); await expect(page.getByRole("heading", { level: 3, name: "Screen" })).toBeVisible(); } @@ -191,6 +192,7 @@ test.describe("the Screen pane", () => { await page.goto( new URL(`/leases/${encodeURIComponent(started.lease)}`, started.host.url).toString(), ); + await page.getByRole("tab", { name: "Screen" }).click(); await expect(showButton(page)).toHaveText("Show screen"); expect(await captureLogLines(started.dir, "opened")).toBe(2); } finally { @@ -198,6 +200,39 @@ test.describe("the Screen pane", () => { } }); + test("switching from Screen to Details keeps the capture running, and closing the drawer stops it", async ({ + page, + }) => { + const started = await streamingHost(); + try { + const ended: string[] = []; + const track = (request: { url(): string }) => { + if (request.url().includes("/v1/stream/leases/")) ended.push(request.url()); + }; + page.on("requestfinished", track); + page.on("requestfailed", track); + await openLeasePage(page, started.host, started.lease); + await showButton(page).click(); + await logReached(started.dir, "opened", 1); + await expect.poll(async () => (await frames(page)) > 0, { timeout: 10_000 }).toBe(true); + + await page.getByRole("tab", { name: "Details" }).click(); + await expect(page.getByRole("tab", { name: "Details" })).toHaveAttribute( + "aria-selected", + "true", + ); + await page.waitForTimeout(500); + expect(ended).toEqual([]); + expect(await captureLogLines(started.dir, "closed")).toBe(0); + + await page.keyboard.press("Escape"); + await logReached(started.dir, "closed", 1); + await expect.poll(() => ended.length).toBe(1); + } finally { + await cleanup(started); + } + }); + test("a worker with streaming off disables Show screen and says why before any click", async ({ page, }) => { @@ -237,7 +272,7 @@ test.describe("the Screen pane", () => { // still connected is not observable from a browser -- it is pinned in // `src/stream/captures.test.ts`, where a capture can be held open past the lease. await logReached(started.dir, "closed", 1); - await expect(page.getByText("Lease not found.")).toBeVisible(); + await expect(page.getByText("This lease is not held.")).toBeVisible(); expect(await captureLogLines(started.dir, "opened")).toBe(1); } finally { await cleanup(started); diff --git a/e2e/console/shell.spec.ts b/e2e/console/shell.spec.ts index 50519c808..26f925ef2 100644 --- a/e2e/console/shell.spec.ts +++ b/e2e/console/shell.spec.ts @@ -1,7 +1,16 @@ import { AxeBuilder } from "@axe-core/playwright"; import type { Page } from "@playwright/test"; -import { expect, NAV, NAV_LABELS, openFromNav, settled, signIn, test } from "./fixtures.js"; +import { + expect, + NAV, + NAV_GROUPS, + NAV_LABELS, + openFromNav, + settled, + signIn, + test, +} from "./fixtures.js"; async function hasHorizontalScroll(page: Page): Promise { return page.evaluate( @@ -22,11 +31,11 @@ test.describe("the shell", () => { await signIn(page, daemon.tokens.operator); const nav = page.getByRole("navigation", { name: "Console" }); - await expect(nav.getByRole("link", { name: "Workers" })).toBeHidden(); + await expect(nav.getByRole("link", { name: "Fleet" })).toBeHidden(); for (const label of NAV_LABELS) { await openFromNav(page, label); await expect(page.getByRole("heading", { level: 1, name: label })).toBeVisible(); - await expect(nav.getByRole("link", { name: "Workers" })).toBeHidden(); + await expect(nav.getByRole("link", { name: "Fleet" })).toBeHidden(); expect(await hasHorizontalScroll(page)).toBe(false); } await page.goto("/no-such-page"); @@ -100,6 +109,57 @@ test.describe("the shell", () => { await expect(page.getByLabel("Operator token")).toBeVisible(); }); + test("the sidebar shows Overview and Attention, then the Operate group, then the Observe group, each with its label", async ({ + daemon, + page, + }) => { + await page.setViewportSize({ height: 900, width: 1440 }); + await page.goto("/"); + await signIn(page, daemon.tokens.operator); + const nav = page.getByRole("navigation", { name: "Console" }); + await expect(nav.getByRole("link")).toHaveText([...NAV_LABELS]); + expect(NAV.map((entry) => `${entry.label} ${entry.path}`)).toEqual([ + "Overview /", + "Attention /attention", + "Fleet /fleet", + "Leases /leases", + "Queue /queue", + "Activity /activity", + "Usage /usage", + ]); + + await expect(nav.getByRole("group")).toHaveCount(NAV_GROUPS.length); + for (const group of NAV_GROUPS) { + const section = nav.getByRole("group", { name: group.label }); + await expect(nav.getByText(group.label, { exact: true })).toBeVisible(); + await expect(section.getByRole("link")).toHaveText([...group.links]); + } + await expect(nav.getByRole("link", { name: "Overview" })).toHaveCount(1); + await expect(nav.getByRole("group").getByRole("link", { name: "Attention" })).toHaveCount(0); + }); + + test("/fleet, /queue and /activity open the pages titled Fleet, Queue and Activity; /workers, /waiting and /events show Not found", async ({ + daemon, + page, + }) => { + const heading = page.getByRole("heading", { level: 1 }); + await page.goto("/"); + await signIn(page, daemon.tokens.operator); + await expect(heading).toHaveText("Overview"); + for (const [path, title] of [ + ["/fleet", "Fleet"], + ["/queue", "Queue"], + ["/activity", "Activity"], + ] as const) { + await page.goto(path); + await expect(heading).toHaveText(title); + } + for (const path of ["/workers", "/waiting", "/events"]) { + await page.goto(path); + await expect(heading).toHaveText("Page not found"); + } + }); + test("the sidebar collapses to icons on request, keeps every link's name, and stays collapsed on every page and after a reload", async ({ daemon, page, @@ -108,12 +168,12 @@ test.describe("the shell", () => { await page.goto("/"); await signIn(page, daemon.tokens.operator); const nav = page.getByRole("navigation", { name: "Console" }); - const label = nav.getByText("Workers", { exact: true }); + const label = nav.getByText("Fleet", { exact: true }); await expect(label).toBeVisible(); await nav.getByRole("button", { name: "Collapse sidebar" }).click(); await expect(label).toBeHidden(); - await expect(nav.getByRole("link", { name: "Workers" })).toBeVisible(); + await expect(nav.getByRole("link", { name: "Fleet" })).toBeVisible(); await expect(nav.getByRole("button", { name: "Expand sidebar" })).toHaveAttribute( "aria-expanded", "false", diff --git a/e2e/console/sign-in.spec.ts b/e2e/console/sign-in.spec.ts index 6b0ad3508..f8bab7803 100644 --- a/e2e/console/sign-in.spec.ts +++ b/e2e/console/sign-in.spec.ts @@ -44,17 +44,17 @@ test.describe("sign-in", () => { await expect(nav.locator("[aria-current='page']")).toHaveText("Overview"); await expect(page).toHaveTitle("Overview · Simlock"); - await nav.getByRole("link", { name: "Events" }).click(); + await nav.getByRole("link", { name: "Activity" }).click(); - await expect(nav.locator("[aria-current='page']")).toHaveText("Events"); - await expect(page).toHaveTitle("Events · Simlock"); + await expect(nav.locator("[aria-current='page']")).toHaveText("Activity"); + await expect(page).toHaveTitle("Activity · Simlock"); // The browser's back and forward move between the console's pages too. await page.goBack(); await expect(page.getByRole("heading", { level: 1, name: "Overview" })).toBeVisible(); await expect(nav.locator("[aria-current='page']")).toHaveText("Overview"); await page.goForward(); - await expect(page.getByRole("heading", { level: 1, name: "Events" })).toBeVisible(); + await expect(page.getByRole("heading", { level: 1, name: "Activity" })).toBeVisible(); }); test("signing in with an empty field asks the daemon nothing", async ({ page }) => { @@ -142,7 +142,7 @@ test.describe("sign-in", () => { await expect(page.getByRole("button", { name: "Sign out" })).toBeVisible(); const tab = await context.newPage(); - await tab.goto("/workers"); + await tab.goto("/fleet"); await expect(tab.getByLabel("Operator token")).toBeVisible(); await expect(tab.getByRole("button", { name: "Sign out" })).toHaveCount(0); diff --git a/e2e/console/views.spec.ts b/e2e/console/views.spec.ts index a07e61fb1..3ec8a9431 100644 --- a/e2e/console/views.spec.ts +++ b/e2e/console/views.spec.ts @@ -37,7 +37,7 @@ async function hostWithLease(): Promise<{ readonly host: RunningDaemon; readonly pages: { lease: `/leases/${encodeURIComponent(lease)}/`, views: NAV.map((entry) => ({ label: entry.label, path: entry.path })), - worker: `/workers/${encodeURIComponent(worker?.id ?? "")}`, + worker: `/fleet/${encodeURIComponent(worker?.id ?? "")}`, }, }; } @@ -54,7 +54,13 @@ async function openSignedIn(page: Page, host: RunningDaemon): Promise { async function visit(page: Page, host: RunningDaemon, path: string): Promise { await page.goto(new URL(path, host.url).toString()); - await expect(page.locator("#main").getByRole("heading").first()).toBeVisible(); + // why: an open drawer hides the page behind it from assistive technology, so there the heading is found by hidden role too. + await expect( + page + .locator("#main") + .getByRole("heading", { includeHidden: /^\/leases\/./.test(path) }) + .first(), + ).toBeVisible(); await expect(page.locator("#main")).not.toContainText("Loading…"); await settled(page); } @@ -90,7 +96,8 @@ test.describe("every view", () => { const { host, pages } = await hostWithLease(); try { await openSignedIn(page, host); - for (const path of every(pages)) { + // why: a drawer traps the keyboard inside itself, so the lease page is left out of this order. + for (const path of every(pages).filter((candidate) => candidate !== pages.lease)) { await visit(page, host, path); // why: a radio group is one stop, at its checked radio, and nothing inside a closed // disclosure is a stop, so those are left out of the order Tab should follow; neither is @@ -133,16 +140,12 @@ test.describe("every view", () => { await page.locator("#main summary").first().focus(); await page.keyboard.press("Enter"); await expect(page.getByRole("columnheader", { name: "Leases held" })).toBeVisible(); - await visit(page, host, "/events"); + await visit(page, host, "/activity"); await page.getByRole("radio", { name: "All" }).focus(); await page.keyboard.press("ArrowRight"); await expect(page.getByRole("radio", { name: "Leases" })).toBeChecked(); await visit(page, host, pages.lease); - await page - .getByRole("navigation", { name: "Breadcrumb" }) - .getByRole("link", { name: "Leases" }) - .focus(); - await page.keyboard.press("Enter"); + await page.keyboard.press("Escape"); await expect(page).toHaveURL(/\/leases$/); } finally { await host.dispose(); @@ -159,7 +162,7 @@ test.describe("every view", () => { ["/", "Leases held, last hour", 0], ["/", "Requests in the queue, last hour", 1], ["/", "Device slots in use, last hour", 2], - ["/events", "Events", 0], + ["/activity", "Activity", 0], ] as const) { await visit(page, host, path); if (path === "/") await expect(page.locator("#main .chart")).toHaveCount(3); @@ -240,6 +243,7 @@ test.describe("every view", () => { for (const path of every(pages)) { await visit(page, host, path); + if (path === pages.lease) await expect(page.getByRole("dialog")).toBeVisible(); const chart = page.locator(".chart svg").first(); if ((await chart.count()) > 0) { await chart.hover(); @@ -326,7 +330,7 @@ test.describe("every view", () => { for (const width of [1280, 1024, 768, 360]) { await page.setViewportSize({ height: 800, width }); await visit(page, host, pages.lease); - const shown = page.locator("#main .id", { hasText: id }); + const shown = page.locator(".drawer .id", { hasText: id }); await expect(shown).toHaveAttribute("title", id); const shape = await shown.evaluate((element) => ({ lines: Math.round( diff --git a/e2e/console/waiting.spec.ts b/e2e/console/waiting.spec.ts index 83d5e4ef1..7a91b9af5 100644 --- a/e2e/console/waiting.spec.ts +++ b/e2e/console/waiting.spec.ts @@ -47,10 +47,10 @@ async function untilTheDaemonSays( }); } -async function openWaiting(page: Page, daemon: RunningDaemon, path = "/waiting"): Promise { +async function openWaiting(page: Page, daemon: RunningDaemon, path = "/queue"): Promise { await page.goto(new URL(path, daemon.url).toString()); await signIn(page, daemon.tokens.operator); - await expect(page.getByRole("heading", { level: 1, name: "Waiting" })).toBeVisible(); + await expect(page.getByRole("heading", { level: 1, name: "Queue" })).toBeVisible(); } function row(page: Page, requester: string): Locator { @@ -94,11 +94,11 @@ test.describe("the Waiting page", () => { // why: With no request named, the first row is the one shown, and the URL stays as it was. await expect(page.getByRole("heading", { level: 2, name: "agent-b" })).toBeVisible(); - expect(new URL(page.url()).pathname).toBe("/waiting"); + expect(new URL(page.url()).pathname).toBe("/queue"); await row(page, "agent-c").click(); await expect(page.getByRole("heading", { level: 2, name: "agent-c" })).toBeVisible(); - expect(new URL(page.url()).pathname).toMatch(/^\/waiting\/.+/); + expect(new URL(page.url()).pathname).toMatch(/^\/queue\/.+/); const inspector = inspectorOf(page, "agent-c"); await expect(inspector).toContainText("wants iOS iPhone 16, runtime 18.4, mode slim"); await expect(inspector).toContainText("2 of 2"); @@ -183,8 +183,8 @@ test.describe("the Waiting page", () => { await expect(page.getByText("No requests are waiting.")).toBeVisible(); await expect(page.getByText("Request not waiting.")).toBeVisible(); - await page.getByRole("link", { name: "Back to waiting" }).click(); - expect(new URL(page.url()).pathname).toBe("/waiting"); + await page.getByRole("link", { name: "Back to Queue" }).click(); + expect(new URL(page.url()).pathname).toBe("/queue"); await expect(page.getByText("Request not waiting.")).toHaveCount(0); await expect(page.getByRole("heading", { level: 2 })).toHaveCount(0); } finally { @@ -195,10 +195,10 @@ test.describe("the Waiting page", () => { test("a request id that was never waiting says it is not waiting", async ({ page }) => { const host = await startDaemon("worker", { config: ONE_DEVICE, driverScript: { ios: IOS } }); try { - await openWaiting(page, host, "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/waiting/req_none"); + await openWaiting(page, host, "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/queue/req_none"); await expect(page.getByText("Request not waiting.")).toBeVisible(); - await expect(page.getByRole("link", { name: "Back to waiting" })).toBeVisible(); + await expect(page.getByRole("link", { name: "Back to Queue" })).toBeVisible(); } finally { await host.dispose(); } @@ -249,19 +249,19 @@ test.describe("the Waiting page", () => { await expect(link).toBeFocused(); await page.keyboard.press("Enter"); }; - await page.goto(new URL("/waiting", host.url).toString()); + await page.goto(new URL("/queue", host.url).toString()); await page.keyboard.press(tab); await page.keyboard.type(host.tokens.operator); await page.keyboard.press("Enter"); - await expect(page.getByRole("heading", { level: 1, name: "Waiting" })).toBeVisible(); + await expect(page.getByRole("heading", { level: 1, name: "Queue" })).toBeVisible(); await follow(row(page, "agent-b")); await expect(page.getByRole("heading", { level: 2, name: "agent-b" })).toBeVisible(); - expect(new URL(page.url()).pathname).toMatch(/^\/waiting\/.+/); + expect(new URL(page.url()).pathname).toMatch(/^\/queue\/.+/); // The request's worker opens that worker's page. await follow(inspectorOf(page, "agent-b").getByRole("link").last()); - expect(new URL(page.url()).pathname).toMatch(/^\/workers\/.+/); + expect(new URL(page.url()).pathname).toMatch(/^\/fleet\/.+/); } finally { await host.dispose(); } diff --git a/e2e/console/workers-gateway-stops-mid-fetch.spec.ts b/e2e/console/workers-gateway-stops-mid-fetch.spec.ts index 33c884d73..8fee69c4d 100644 --- a/e2e/console/workers-gateway-stops-mid-fetch.spec.ts +++ b/e2e/console/workers-gateway-stops-mid-fetch.spec.ts @@ -22,8 +22,8 @@ const IOS = { availableOsVersions: ["18.4"], knownModels: ["iPhone 16"] }; async function openConsole(page: Page, daemon: RunningDaemon): Promise { await page.goto(daemon.url); await signIn(page, daemon.tokens.operator); - await page.getByRole("link", { name: "Workers", exact: true }).click(); - await expect(page.getByRole("heading", { level: 1, name: "Workers" })).toBeVisible(); + await page.getByRole("link", { name: "Fleet", exact: true }).click(); + await expect(page.getByRole("heading", { level: 1, name: "Fleet" })).toBeVisible(); } function workerRows(page: Page): Locator { @@ -106,7 +106,7 @@ test.describe("the workers page response helper against a gateway whose listener // why: once the helper drops the re-read the page's own promise settles (0 when aborted); // a rejection escaping the helper fails the test at its `route.fetch()` line instead. await asked; - await expect(page.getByRole("heading", { level: 1, name: "Workers" })).toBeVisible(); + await expect(page.getByRole("heading", { level: 1, name: "Fleet" })).toBeVisible(); } finally { await disposeFleet(fleet).catch(() => undefined); } diff --git a/e2e/console/workers.spec.ts b/e2e/console/workers.spec.ts index 3a819fc8a..3e750fc5e 100644 --- a/e2e/console/workers.spec.ts +++ b/e2e/console/workers.spec.ts @@ -111,8 +111,8 @@ async function untilTheGatewaySays( async function openConsole(page: Page, daemon: RunningDaemon): Promise { await page.goto(daemon.url); await signIn(page, daemon.tokens.operator); - await page.getByRole("link", { name: "Workers", exact: true }).click(); - await expect(page.getByRole("heading", { level: 1, name: "Workers" })).toBeVisible(); + await page.getByRole("link", { name: "Fleet", exact: true }).click(); + await expect(page.getByRole("heading", { level: 1, name: "Fleet" })).toBeVisible(); } function row(page: Page, name: string): Locator { @@ -310,7 +310,7 @@ test.describe("the workers page", () => { listed.find((view) => view.label === "worker-a"), "worker-a", ); - await expect(page).toHaveURL(new RegExp(`/workers/${a.id}$`)); + await expect(page).toHaveURL(new RegExp(`/fleet/${a.id}$`)); await expect(title(page, "worker-a")).toBeVisible(); await expect(fact(page.locator("#main"), "Leases").or(figure(page, "Leases"))).toContainText( "1", @@ -361,11 +361,11 @@ test.describe("the workers page", () => { await expect( page.getByRole("list", { name: "Workers", exact: true }).getByRole("listitem"), ).toHaveCount(1); - await expect(page).toHaveURL(/\/workers$/); + await expect(page).toHaveURL(/\/fleet$/); await expect(title(page, host.id)).toBeVisible(); await expect(page.getByRole("navigation", { name: "Breadcrumb" })).toContainText(host.id); await row(page, host.id).getByRole("link").click(); - await expect(page).toHaveURL(new RegExp(`/workers/${encodeURIComponent(host.id)}$`)); + await expect(page).toHaveURL(new RegExp(`/fleet/${encodeURIComponent(host.id)}$`)); await expect(page.locator(".inspector-line")).toContainText(host.version ?? ""); await expect(page.locator(".inspector-line")).toContainText("connected"); }); @@ -373,11 +373,11 @@ test.describe("the workers page", () => { test("a worker that no list has says so and links back to the list", async ({ daemon, page }) => { await openConsole(page, daemon); - await page.goto(new URL("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/workers/wrk_nope", daemon.url).href); + await page.goto(new URL("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/fleet/wrk_nope", daemon.url).href); await expect(page.getByText("Worker not found.")).toBeVisible(); - await page.getByRole("link", { name: "All workers" }).click(); - await expect(page).toHaveURL(/\/workers$/); + await page.getByRole("link", { name: "Back to Fleet" }).click(); + await expect(page).toHaveURL(/\/fleet$/); await expect(page.getByRole("list", { name: "Workers", exact: true })).toBeVisible(); }); @@ -829,7 +829,7 @@ test.describe("the workers page", () => { try { await lease(host, "console-e2e"); await page.setViewportSize({ height: 740, width: 360 }); - await page.goto(new URL("/workers", host.url).href); + await page.goto(new URL("/fleet", host.url).href); await signIn(page, host.tokens.operator); const [view] = await workerList(host); await expect(page.getByRole("list", { name: "Workers", exact: true })).toBeVisible(); @@ -873,11 +873,11 @@ test.describe("the workers page", () => { await page.keyboard.press(tab); await page.keyboard.type(daemon.tokens.operator); await page.keyboard.press("Enter"); - await follow(page.getByRole("link", { name: "Workers", exact: true })); - await expect(page.getByRole("heading", { level: 1, name: "Workers" })).toBeVisible(); + await follow(page.getByRole("link", { name: "Fleet", exact: true })); + await expect(page.getByRole("heading", { level: 1, name: "Fleet" })).toBeVisible(); await follow(row(page, name).getByRole("link")); - await expect(page).toHaveURL(new RegExp(`/workers/${encodeURIComponent(name)}$`)); + await expect(page).toHaveURL(new RegExp(`/fleet/${encodeURIComponent(name)}$`)); await expect(title(page, name)).toBeVisible(); const host_tab = page.getByRole("tab", { name: "Host" }); @@ -890,9 +890,9 @@ test.describe("the workers page", () => { await expect(host_tab).toHaveAttribute("aria-selected", "true"); await follow( - page.getByRole("navigation", { name: "Breadcrumb" }).getByRole("link", { name: "Workers" }), + page.getByRole("navigation", { name: "Breadcrumb" }).getByRole("link", { name: "Fleet" }), "backward", ); - await expect(page).toHaveURL(/\/workers$/); + await expect(page).toHaveURL(/\/fleet$/); }); }); diff --git a/e2e/real-proxy/real-proxy.spec.ts b/e2e/real-proxy/real-proxy.spec.ts index bc603720a..bdc0bc8fb 100644 --- a/e2e/real-proxy/real-proxy.spec.ts +++ b/e2e/real-proxy/real-proxy.spec.ts @@ -51,7 +51,7 @@ test.describe("behind a real sign-in proxy", () => { expect(body["role"]).toBe("admin"); }); - test("a worker with gateway.url ws://127.0.0.1:4180 joins through /v1/uplink and appears on the console's Workers page", async ({ + test("a worker with gateway.url ws://127.0.0.1:4180 joins through /v1/uplink and appears on the console's Fleet page", async ({ page, }) => { const minted = await gateway.cli(["token", "create", "--role", "worker"]); @@ -60,7 +60,7 @@ test.describe("behind a real sign-in proxy", () => { const worker = await startWorker({ gatewayUrl: "ws://127.0.0.1:4180", token }); try { await logInAsAlice(page); - await page.getByRole("link", { name: "Workers", exact: true }).click(); + await page.getByRole("link", { name: "Fleet", exact: true }).click(); await expect( page.getByRole("list", { name: "Workers", exact: true }).getByRole("listitem"), diff --git a/package.json b/package.json index 88ed3171a..1a61ab331 100644 --- a/package.json +++ b/package.json @@ -79,6 +79,7 @@ }, "devDependencies": { "@axe-core/playwright": "^4.13.0", + "@base-ui/react": "1.9.0", "@fontsource-variable/geist": "^5.3.0", "@fontsource-variable/geist-mono": "^5.3.0", "@playwright/test": "^1.63.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 509e2fbc3..93f430ece 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -241,6 +241,9 @@ importers: '@axe-core/playwright': specifier: ^4.13.0 version: 4.13.0(playwright-core@1.63.0) + '@base-ui/react': + specifier: 1.9.0 + version: 1.9.0(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0) '@fontsource-variable/geist': specifier: ^5.3.0 version: 5.3.0 @@ -504,6 +507,9 @@ packages: peerDependencies: '@babel/core': ^8.0.0 + '@babel/runtime@8.0.7': + resolution: {integrity: sha512-k0hagDDq/6w4v+0Sp4wFvIz/yswH5O7Va6aRTnD7N62Tnborp4X+YB+H3XUcWVSR4aE47WPEXiIIZchBs0GmYg==} + '@babel/template@8.0.0': resolution: {integrity: sha512-eAD0QW/AlbamBbw0FeGiwasbCVPq5ncW0HNVyLP3B9czqLyh4gvw+5JTSNt6le9+ziAU7mqDZsKTHf3jTb4chQ==} engines: {node: ^22.18.0 || >=24.11.0} @@ -516,6 +522,33 @@ packages: resolution: {integrity: sha512-c+xgSWboV2pdwXP67BUWDVRHi2BO5Q3KwxyFVs7taVTY+fsK47/L51ZXQoV9rozHJDNHvJ4v4WEsI/IlxV2l2A==} engines: {node: ^22.18.0 || >=24.11.0} + '@base-ui/react@1.9.0': + resolution: {integrity: sha512-S8CSYosASBKtpL8SWUfS78rFElfLijiCgA7oHOK22jCJ95FULsYyKwBNFOgudt0RA+/7yNc7F81bOvQnRgbBiQ==} + engines: {node: '>=14.0.0'} + peerDependencies: + '@date-fns/tz': ^1.2.0 + '@types/react': ^17 || ^18 || ^19 + date-fns: ^4.0.0 + react: ^17 || ^18 || ^19 + react-dom: ^17 || ^18 || ^19 + peerDependenciesMeta: + '@date-fns/tz': + optional: true + '@types/react': + optional: true + date-fns: + optional: true + + '@base-ui/utils@0.5.0': + resolution: {integrity: sha512-dYGGcEttjkYiMoa5nHm8vLaJ2UcuTWxo3BFAwOYXeRg/q7UVVvA6cacEIXEs3FgBfK1CGtW1ptElqs7wsx+t9A==} + peerDependencies: + '@types/react': ^17 || ^18 || ^19 + react: ^17 || ^18 || ^19 + react-dom: ^17 || ^18 || ^19 + peerDependenciesMeta: + '@types/react': + optional: true + '@conventional-changelog/git-client@2.7.0': resolution: {integrity: sha512-j7A8/LBEQ+3rugMzPXoKYzyUPpw/0CBQCyvtTR7Lmu4olG4yRC/Tfkq79Mr3yuPs0SUitlO2HwGP3gitMJnRFw==} engines: {node: '>=18'} @@ -568,6 +601,21 @@ packages: cpu: [x64] os: [win32] + '@floating-ui/core@1.8.0': + resolution: {integrity: sha512-0CIZ5itps/8x7BG8dEIhs53BvCUH2PCoogtakwRTut+Arm58sJooJ0AuZhLw2HJYIR5cMLNPBSS728sPho2khQ==} + + '@floating-ui/dom@1.8.0': + resolution: {integrity: sha512-yXSrzeHZBTZadLOlfyhCkJHNeLJnHRnRInwdZ40L7ZiaAtrBwoYlsDrX3v5zB1Utk7CLfzcOVnVVWoXEky7Ceg==} + + '@floating-ui/react-dom@2.1.9': + resolution: {integrity: sha512-JDjEFGCpImxDCA7JJKviA0M9+RtmJdj0m/NVU5IMgBK+AmZouAQQ7/+2GLH0GXXY0YMw9oXPB8hKdbPYg5QLYg==} + peerDependencies: + react: '>=16.8.0' + react-dom: '>=16.8.0' + + '@floating-ui/utils@0.2.12': + resolution: {integrity: sha512-HpCo8tmWzLVad5s2d19EhAz5zqrrQ6s69qd6moPMQvkOuSwDT1YgRfWSVuc4ennqrgv3OHppiOGMQ7oC13yIww==} + '@fontsource-variable/geist-mono@5.3.0': resolution: {integrity: sha512-vBbuwDEo9AkrqADMXOrlAR3DFcJi4/JxeuU43FoiQERnNwsfXNnvxvReZG02cQKmyk4DZkZdBZX3oTDvy2zBAw==} @@ -2787,6 +2835,9 @@ packages: reselect@5.2.0: resolution: {integrity: sha512-AgZ3UOZm3YndfrJ4OYjgrT7bmCm/1iqkjvEfH/oYjzh6PD2qw4QuT3jjnXIrpdt4MTpMXclMT3lXbmRY+XRakw==} + reselect@5.3.0: + resolution: {integrity: sha512-XGoLeRAVzUTcJ1qkxPQhDJyIZ5d6zzZD9nT7AEZOaaU9UbWclhycElmhO+VD5bFeLuzhPBaOV2oXC8uG35ZSpg==} + resolve@1.22.13: resolution: {integrity: sha512-Dj/cW9zBV2aRj6XzCxuGIs3ESZKv02jixne3q6jFZYZ3/Tg09gHHviSMDL4kObh9pqSahdRHEnDoaP2gn8YLhA==} engines: {node: '>= 0.4'} @@ -3466,6 +3517,8 @@ snapshots: '@babel/plugin-transform-modules-commonjs': 8.0.1(@babel/core@8.0.6) '@babel/plugin-transform-typescript': 8.0.6(@babel/core@8.0.6) + '@babel/runtime@8.0.7': {} + '@babel/template@8.0.0': dependencies: '@babel/code-frame': 8.0.6 @@ -3487,6 +3540,29 @@ snapshots: '@babel/helper-string-parser': 8.0.6 '@babel/helper-validator-identifier': 8.0.6 + '@base-ui/react@1.9.0(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)': + dependencies: + '@babel/runtime': 8.0.7 + '@base-ui/utils': 0.5.0(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0) + '@floating-ui/react-dom': 2.1.9(react-dom@19.3.0(react@19.3.0))(react@19.3.0) + '@floating-ui/utils': 0.2.12 + react: 19.3.0 + react-dom: 19.3.0(react@19.3.0) + use-sync-external-store: 1.7.0(react@19.3.0) + optionalDependencies: + '@types/react': 19.3.0 + + '@base-ui/utils@0.5.0(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)': + dependencies: + '@babel/runtime': 8.0.7 + '@floating-ui/utils': 0.2.12 + react: 19.3.0 + react-dom: 19.3.0(react@19.3.0) + reselect: 5.3.0 + use-sync-external-store: 1.7.0(react@19.3.0) + optionalDependencies: + '@types/react': 19.3.0 + '@conventional-changelog/git-client@2.7.0(conventional-commits-filter@5.0.0)(conventional-commits-parser@6.4.0)': dependencies: '@simple-libs/child-process-utils': 1.0.2 @@ -3520,6 +3596,23 @@ snapshots: '@fallow-cli/win32-x64-msvc@3.6.0': optional: true + '@floating-ui/core@1.8.0': + dependencies: + '@floating-ui/utils': 0.2.12 + + '@floating-ui/dom@1.8.0': + dependencies: + '@floating-ui/core': 1.8.0 + '@floating-ui/utils': 0.2.12 + + '@floating-ui/react-dom@2.1.9(react-dom@19.3.0(react@19.3.0))(react@19.3.0)': + dependencies: + '@floating-ui/dom': 1.8.0 + react: 19.3.0 + react-dom: 19.3.0(react@19.3.0) + + '@floating-ui/utils@0.2.12': {} + '@fontsource-variable/geist-mono@5.3.0': {} '@fontsource-variable/geist@5.3.0': {} @@ -5487,6 +5580,8 @@ snapshots: reselect@5.2.0: {} + reselect@5.3.0: {} + resolve@1.22.13: dependencies: es-errors: 1.3.0 diff --git a/src/lint-rules.test.ts b/src/lint-rules.test.ts index b3fa11029..66df24d9a 100644 --- a/src/lint-rules.test.ts +++ b/src/lint-rules.test.ts @@ -728,6 +728,30 @@ describe("the console's layers", () => { ]); }); + it("fires ui-base-ui-in-ds-only for an import of Base UI from the screens, and not from the design system", () => { + const found = layerViolations({ + ...layers, + "ui/src/ds/b.ts": + 'import "@base-ui/react/dialog";\nexport type Props = number;\nexport const b = 1;\n', + "ui/src/screens/s.ts": 'import "@base-ui/react/dialog";\nimport "../ds/b.js";\nexport {};\n', + }); + + expect(found.filter((line) => line.startsWith("ui-base-ui-in-ds-only"))).toEqual([ + "ui-base-ui-in-ds-only ui/src/screens/s.ts -> @base-ui/react/dialog", + ]); + }); + + it("fires ui-base-ui-in-ds-only for an import of Base UI from a file directly under ui/src", () => { + const found = layerViolations({ + ...layers, + "ui/src/main.ts": 'import "@base-ui/react";\nexport {};\n', + }); + + expect(found.filter((line) => line.startsWith("ui-base-ui-in-ds-only"))).toEqual([ + "ui-base-ui-in-ds-only ui/src/main.ts -> @base-ui/react", + ]); + }); + it("lets a test reach across layers, as a test drives its subject through what it needs", () => { expect( layerViolations({ diff --git a/ui/AGENTS.md b/ui/AGENTS.md index 9fb961786..f3221b785 100644 --- a/ui/AGENTS.md +++ b/ui/AGENTS.md @@ -50,30 +50,36 @@ ends. `model/proxy-refusal.ts` words a refusal. ## Pages -| Path | Screen | Layout | -| ------------------- | --------- | ------------------------------------------------------------------------------------ | -| `/` | Overview | stat tiles, range picker, three charts, capacity, workers table, attention, activity | -| `/workers[/]` | Workers | list + inspector (`MasterDetail`) | -| `/leases[/]` | Leases | list + inspector; the inspector holds the live screen | -| `/waiting[/]` | Waiting | Wait p95 tile, list + inspector | -| `/attention[/]` | Attention | list + inspector | -| `/events[/]` | Events | list + inspector with the payload | -| `/usage` | Usage | range picker, stat tiles, panels of tables (workers, requesters page in the URL) | +| Path | Screen | Layout | +| ------------------- | --------- | ------------------------------------------------------------------------------------------ | +| `/` | Overview | stat tiles, range picker, three charts, capacity, workers table, attention, activity | +| `/fleet[/]` | Fleet | list + inspector (`MasterDetail`) | +| `/leases[/]` | Leases | toolbar (filters, search) + table; the lease opens in a `Drawer` (Details, Screen, Events) | +| `/queue[/]` | Queue | Wait p95 tile, list + inspector | +| `/attention[/]` | Attention | list + inspector | +| `/activity[/]` | Activity | list + inspector with the payload | +| `/usage` | Usage | range picker, stat tiles, panels of tables (workers, requesters page in the URL) | + +The sidebar groups the pages: Overview and Attention, then Operate (Fleet, Leases, Queue), then +Observe (Activity, Usage); a route's `group` in `routes.ts` puts it in one. On a list page the URL names the chosen item; with none, the first item shows on a wide screen -and the list alone on a phone. Lists page in the URL (`state/paging.ts`, `model/paging.ts`). +and the list alone on a phone (Leases shows the list alone, and a lease opens in a drawer over it). +Lists page in the URL (`state/paging.ts`, `model/paging.ts`). ## Design system `src/ds/index.ts` exports every component. Tokens and base elements: `foundation.css`. - Frame: `AppFrame`, `Sidebar` (collapsible; width kept per browser by `data/preferences.ts`), - `Page`, `MasterDetail`, `ListPane`, `List`, `ListRow`, `Inspector`. + `Page`, `MasterDetail`, `ListPane`, `List`, `ListRow`, `Inspector`, `Drawer`, `DrawerTabs` + (a modal panel over the page, closed by an `IconButton` from `button.tsx`; Base UI), `Toolbar` (filters left, search right), `DesignProvider` + (Base UI's `CSPProvider`, so no `