diff --git a/packages/app/src/features/projects/detail.tsx b/packages/app/src/features/projects/detail.tsx index f751af8e..22390902 100644 --- a/packages/app/src/features/projects/detail.tsx +++ b/packages/app/src/features/projects/detail.tsx @@ -11,5 +11,11 @@ export function ProjectDetail() { const { projectId } = useParams({ from: "/projects/$projectId" }); const project = useQuery(projectQuery(projectId)); const [view, setView] = useState<"list" | "graph">("list"); - return setView("list")}>List setView("graph")}>GraphCreate job}>{view === "list" ? : }; + return {project.data && + + setView("list")}>List + setView("graph")}>Graph + + Create job + }{view === "list" ? : }; } diff --git a/packages/app/src/features/projects/project-nav.tsx b/packages/app/src/features/projects/project-nav.tsx index 85953c9a..be9d5598 100644 --- a/packages/app/src/features/projects/project-nav.tsx +++ b/packages/app/src/features/projects/project-nav.tsx @@ -1,21 +1,29 @@ import { Link, useParams } from "@tanstack/react-router"; import { useQuery } from "@tanstack/react-query"; -import { Breadcrumb, Page, ResourceHeader } from "../../shared/ui"; +import { Page } from "../../shared/ui"; import { projectQuery } from "./queries"; -export function ProjectNav({ tab, children, actions }: { tab: "jobs" | "runs" | "settings"; children?: React.ReactNode; actions?: React.ReactNode }) { +type ProjectTab = "jobs" | "runs" | "settings"; + +const tabs: Array<{ id: ProjectTab; label: string; to: "/projects/$projectId" | "/projects/$projectId/runs" | "/projects/$projectId/settings"; icon: React.ReactNode }> = [ + { id: "jobs", label: "Jobs", to: "/projects/$projectId", icon: }, + { id: "runs", label: "Runs", to: "/projects/$projectId/runs", icon: }, + { id: "settings", label: "Settings", to: "/projects/$projectId/settings", icon: }, +]; + +export function ProjectNav({ tab, children }: { tab: ProjectTab; children?: React.ReactNode }) { const { projectId } = useParams({ strict: false }) as { projectId: string }; const project = useQuery(projectQuery(projectId)); - const tabClass = (name: typeof tab) => `inline-flex min-h-11 items-center border-b-2 px-3 text-sm font-semibold ${tab === name ? "border-factorize-500 text-factorize-700 dark:text-factorize-500" : "border-transparent text-slate-600 hover:border-stone-300 dark:text-slate-300 dark:hover:border-slate-600"}`; - return - Projects - {actions} - - Jobs - Runs - Settings + return <> + + + {tabs.map(item => {item.icon}{item.label})} + - {project.isPending && Loading project…}{project.error && {project.error.message}} - {children} - ; + + {project.data?.name ?? "Project"} {tab === "jobs" ? "jobs" : tab === "runs" ? "runs" : "settings"} + {project.isPending && Loading project…}{project.error && {project.error.message}} + {children} + + >; } diff --git a/packages/app/test/jobs.browser.test.mjs b/packages/app/test/jobs.browser.test.mjs index 6547adf5..8ee7772b 100644 --- a/packages/app/test/jobs.browser.test.mjs +++ b/packages/app/test/jobs.browser.test.mjs @@ -112,12 +112,13 @@ test("project settings can rename and describe a project", async () => { }); await page.route("**/api/v1/job-summaries?**", route => route.fulfill({ json: { items: [], nextCursor: null } })); await page.goto(origin + `/projects/${projectId}`); - await page.getByRole("heading", { name: "Release project", exact: true }).waitFor(); + await page.getByRole("heading", { name: "Release project jobs", exact: true }).waitFor(); await page.getByRole("link", { name: "Settings", exact: true }).click(); + assert.equal(await page.getByRole("navigation", { name: "Project navigation" }).getByRole("link", { name: "Settings", exact: true }).getAttribute("aria-current"), "page"); await page.getByLabel("Name", { exact: true }).fill("Renamed project"); await page.locator("form textarea").fill("Updated details"); await page.getByRole("button", { name: "Save changes", exact: true }).click(); - await page.getByRole("heading", { name: "Renamed project", exact: true }).waitFor(); + await page.getByRole("heading", { name: "Renamed project settings", exact: true }).waitFor(); assert.deepEqual(saved, [{ name: "Renamed project", description: "Updated details" }]); assert.match(await page.locator("main").textContent(), /Updated details/); await context.close(); @@ -281,7 +282,7 @@ test("project graph keeps opaque webhook resource IDs out of labels and availabl await page.getByText(`Linear · ${projectUuid}`, { exact: true }).waitFor(); await context.close(); }); -test("project and job detail pages use the appropriate breadcrumbs", async () => { +test("project tabs omit redundant headings while job detail keeps its project breadcrumb", async () => { const { page, context } = await contextFor({ viewport: { width: 1280, height: 844 } }); await page.route("**/api/v1/projects", route => route.fulfill({ json: [{ id: projectId, name: "Release project", description: "Project jobs", jobCount: 1 }] })); await page.route(`**/api/v1/jobs/${jobId}`, route => route.fulfill({ json: { ...summary, promptTemplate: "Template", executionConfigId: "local", triggers: [] } })); @@ -289,10 +290,11 @@ test("project and job detail pages use the appropriate breadcrumbs", async () => await page.getByRole("heading", { name: "Projects", exact: true }).waitFor(); assert.equal(await page.getByRole("navigation", { name: "Breadcrumb" }).count(), 1); await page.goto(origin + `/projects/${projectId}`); - await page.getByRole("heading", { name: "Release project", exact: true }).waitFor(); - const projectBreadcrumb = page.getByRole("navigation", { name: "Breadcrumb" }); - assert.deepEqual(await projectBreadcrumb.getByRole("link").allTextContents(), ["Projects"]); - assert.equal(await page.getByText("Project", { exact: true }).count(), 2); + await page.getByRole("heading", { name: "Release project jobs", exact: true }).waitFor(); + assert.equal(await page.getByRole("navigation", { name: "Breadcrumb" }).count(), 0); + assert.equal(await page.getByRole("heading", { name: "Release project", exact: true }).count(), 0); + const projectNavigation = page.getByRole("navigation", { name: "Project navigation" }); + assert.equal(await projectNavigation.getByRole("link", { name: "Jobs", exact: true }).getAttribute("aria-current"), "page"); await page.goto(origin + `/jobs/${jobId}`); await page.getByRole("heading", { name: "Review builds", exact: true }).waitFor(); const breadcrumb = page.getByRole("navigation", { name: "Breadcrumb" }); @@ -329,8 +331,9 @@ for (const width of [1280, 390, 320]) for (const theme of ["light", "dark"]) tes ); assert.equal(await page.getByLabel("Search jobs", { exact: true }).count(), 0); assert.equal(await page.getByText("Your software factory. Configure prompts, connect triggers, and follow every run.").count(), 0); - const heading = await page.getByRole("heading", { name: "Release project", exact: true }).boundingBox(), create = await page.getByRole("link", { name: "Create job", exact: true }).boundingBox(); - if (width >= 1280) assert.ok(create.x > heading.x + heading.width && Math.abs(create.y - heading.y) < 12); + const controls = await page.getByRole("group", { name: "Project jobs view" }).boundingBox(), create = await page.getByRole("link", { name: "Create job", exact: true }).boundingBox(), tableBox = await table.boundingBox(); + assert.ok(create.x > controls.x + controls.width && Math.abs(create.y - controls.y) < 12); + assert.ok(Math.abs((create.x + create.width) - (tableBox.x + tableBox.width)) < 2); const longLink = table.getByRole("link", { name: longTitle, exact: true }); assert.equal(await longLink.evaluate(el => el.scrollWidth > el.clientWidth && getComputedStyle(el).whiteSpace === "nowrap"), true); const first = table.locator("tbody tr").first(), idleColor = await first.evaluate(el => getComputedStyle(el).backgroundColor); @@ -360,7 +363,6 @@ test("mobile jobs list only navigates when a job title is tapped", async () => { const table = page.getByRole("table", { name: "Jobs", exact: true }); await table.getByRole("link", { name: "Security Checker Dispatcher", exact: true }).waitFor(); - await page.getByRole("heading", { name: "Release project", exact: true }).click(); await table.locator("tbody tr").nth(1).locator("td").first().click(); assert.match(page.url(), /\/projects\/[^/]+(?:\?|$)/); diff --git a/packages/app/test/runs.browser.test.mjs b/packages/app/test/runs.browser.test.mjs index 81901f77..85f14b6d 100644 --- a/packages/app/test/runs.browser.test.mjs +++ b/packages/app/test/runs.browser.test.mjs @@ -25,7 +25,7 @@ test("run page polling backs off when idle, discovers runs, and stays fast while await new Promise(resolve => setTimeout(resolve, 4100)); assert.equal(activeCount, 3, "active rows should make three requests in the same 4.1-second window"); await active.context.close(); }); -test("run page errors back off for ten seconds and recover to the idle interval", async () => { +test("run page errors back off for ten seconds and recover", async () => { const { context, page } = await setup(); let count = 0; await page.clock.install({ time: new Date(time) }); await page.route("**/api/v1/runs?**", route => { @@ -38,9 +38,10 @@ test("run page errors back off for ten seconds and recover to the idle interval" assert.equal(count, 3, "the idle refetch and its single retry should expose an error"); await page.clock.runFor(9000); assert.equal(count, 3, "errors should wait about ten seconds before another query"); const recoveredResponse = page.waitForResponse(response => response.url().includes("/api/v1/runs?") && response.status() === 200); - await page.clock.runFor(1100); await recoveredResponse; await page.getByRole("link", { name: "Polling run", exact: true }).waitFor(); assert.equal(count, 4, "the ten-second error interval should retry and recover"); - await page.clock.runFor(14999); assert.equal(count, 4, "a successful response should return to the 15-second idle interval"); - await page.clock.runFor(1); assert.equal(count, 5); + for (let elapsed = 0; count < 4 && elapsed < 2000; elapsed++) await page.clock.runFor(1); + await recoveredResponse; await page.getByRole("link", { name: "Polling run", exact: true }).waitFor(); await page.getByRole("alert").waitFor({ state: "detached" }); assert.equal(count, 4, "the ten-second error interval should retry and recover"); + await page.clock.runFor(12_000); assert.equal(count, 4, "a successful response should return to the 15-second idle interval"); + await page.clock.runFor(5_000); assert.equal(count, 5, "the idle interval should refresh after about 15 seconds"); await context.close(); }); test("all-jobs runs index uses a tenant-scoped page, navigation, refresh, and created time", async () => { @@ -106,7 +107,7 @@ test("all-runs status header supports multi-select filtering, independent sortin await page.getByRole("button", { name: /Status, 2 statuses selected/ }).click(); const requestCountBeforeClear = requests.length; await page.getByRole("dialog", { name: "Status filter and sort" }).getByRole("button", { name: "Clear filters and reset sort" }).click(); await page.waitForFunction(() => { const params = new URLSearchParams(location.search); return location.pathname === "/job-runs" && !params.has("state") && !params.has("states"); }); - assert.equal(await page.getByRole("link", { name: "Run", exact: true }).count(), 1); + await page.getByRole("link", { name: "Run", exact: true }).waitFor(); assert.ok(requests.slice(requestCountBeforeClear).every(url => !url.searchParams.has("state")), "clearing statuses must not issue a request with stale status filters"); await context.close(); }); test("all-runs combines independent project and job filters, preserves them through pagination, and toggles row filters", async () => { diff --git a/packages/app/test/visual/baselines/project-jobs-desktop.png b/packages/app/test/visual/baselines/project-jobs-desktop.png new file mode 100644 index 00000000..21add75c Binary files /dev/null and b/packages/app/test/visual/baselines/project-jobs-desktop.png differ diff --git a/packages/app/test/visual/baselines/project-jobs-mobile.png b/packages/app/test/visual/baselines/project-jobs-mobile.png new file mode 100644 index 00000000..6bcd1e10 Binary files /dev/null and b/packages/app/test/visual/baselines/project-jobs-mobile.png differ diff --git a/packages/app/test/visual/design.spec.mjs b/packages/app/test/visual/design.spec.mjs index daf11142..b7cae012 100644 --- a/packages/app/test/visual/design.spec.mjs +++ b/packages/app/test/visual/design.spec.mjs @@ -2,7 +2,7 @@ import AxeBuilder from "@axe-core/playwright"; import { test, expect } from "@playwright/test"; import { createServer } from "node:http"; import { readFile } from "node:fs/promises"; -import { mockApi, screens, jobId } from "./fixtures.mjs"; +import { mockApi, screens, jobId, projectId } from "./fixtures.mjs"; let server, origin; test.beforeAll(async () => { server = createServer(async (req, res) => { @@ -88,6 +88,30 @@ test("empty jobs", async ({ page }) => { await expect(page.getByRole("heading", { name: "No jobs found" })).toBeVisible(); await expect(page).toHaveScreenshot("jobs-empty.png"); }); +for (const [label, width, height] of [["desktop", 1721, 914], ["mobile", 390, 844]]) test(`project jobs layout ${label}`, async ({ page }) => { + await page.setViewportSize({ width, height }); await page.emulateMedia({ colorScheme: "light" }); + await mockApi(page); + await page.goto(origin + "/projects/" + projectId); + await expect(page.getByRole("heading", { name: "Release automation jobs", exact: true })).toBeVisible(); + const navigation = page.getByRole("navigation", { name: "Project navigation" }); + await expect(navigation.getByRole("link", { name: "Jobs", exact: true })).toHaveAttribute("aria-current", "page"); + await expect(navigation.getByRole("link", { name: "Runs", exact: true })).toBeVisible(); + await expect(navigation.getByRole("link", { name: "Settings", exact: true })).toBeVisible(); + await expect(page.getByRole("heading", { name: "Project" })).toHaveCount(0); + await expect(page.getByRole("button", { name: "List", exact: true })).toHaveAttribute("aria-pressed", "true"); + await expect(page.getByRole("button", { name: "Graph", exact: true })).toHaveAttribute("aria-pressed", "false"); + await expect(page.getByRole("link", { name: "Create job" })).toHaveAttribute("href", "/jobs/new?projectId=" + projectId); + await expect(page.getByRole("table", { name: "Jobs" })).toBeVisible(); + await page.getByRole("button", { name: "Graph", exact: true }).click(); + await expect(page.getByRole("button", { name: "Graph", exact: true })).toHaveAttribute("aria-pressed", "true"); + await page.getByRole("button", { name: "List", exact: true }).click(); + await expect(page.getByRole("button", { name: "List", exact: true })).toHaveAttribute("aria-pressed", "true"); + await expect(page.locator("header")).toBeVisible(); + await expect(page).toHaveScreenshot(`project-jobs-${label}.png`, { fullPage: true }); + expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true); + const accessibility = await new AxeBuilder({ page }).withTags(["wcag2a", "wcag2aa", "wcag21aa"]).analyze(); + expect(accessibility.violations).toEqual([]); +}); for (const theme of ["light", "dark"]) test(`additional routes and feedback ${theme}`, async ({ page }) => { await page.emulateMedia({ colorScheme: theme }); await page.setViewportSize({ width: 390, height: 844 }); await mockApi(page); diff --git a/packages/app/test/visual/fixtures.mjs b/packages/app/test/visual/fixtures.mjs index 6bcbb0f1..d84cd9b0 100644 --- a/packages/app/test/visual/fixtures.mjs +++ b/packages/app/test/visual/fixtures.mjs @@ -27,7 +27,7 @@ export const events = [ { id: "four", sequence: 4, type: "assistant_message", title: "Assistant", preview: "### Release ready\n\nThe interfaces remain compatible.\n\n- Contract checks passed\n- No regressions found\n\n```typescript\nconst release = { ready: true };\n```", display: {} }, ]; export const integrations = { linear: { organizationName: "Release workspace" }, clickup: null, github: { installations: [] }, exeConnections: [], ampConnections: [], cloudflareTail: { installations: [] } }; -export const project = { id: projectId, name: "Release projects", description: "Projects for release automation.", jobCount: 2 }; +export const project = { id: projectId, name: "Release automation", description: "Projects for release automation.", jobCount: 2 }; export const targets = [{ id: "vm", kind: "exe-vm", name: "Release VM", workspace: "ephemeral", cwd: "/workspace", agentKind: "codex", models: ["gpt-6"], efforts: ["high"], capabilities: ["stop"] }]; export async function mockApi(page, { legacy = false, authenticated = true, empty = false, state = "succeeded", long = false } = {}) { const configuredJob = { ...job, ...(long ? { name: "Long release review " + "abcdefghij".repeat(14), promptTemplate: "A long prompt " + "word ".repeat(500) } : {}) }; @@ -37,6 +37,7 @@ export async function mockApi(page, { legacy = false, authenticated = true, empt if (path === "/api/v1/session") json = authenticated ? { authenticated: true, user: { id: "owner", email: "owner@example.test" }, workspace: { id: "tenant", name: "Release" }, capabilities: [], expiresAt: "2026-10-10T00:00:00Z" } : { authenticated: false }; else if (path === "/api/v1/projects") json = [project]; else if (path === "/api/v1/projects/" + projectId) json = project; + else if (path === "/api/v1/projects/" + projectId + "/graph") json = { nodes: [{ id: jobId, type: "job", label: configuredJob.name, jobKind: "Code", enabled: true, runningCount: 1, concurrencyLimit: 2 }], edges: [] }; else if (path === "/api/v1/job-summaries") json = { items: empty ? [] : [configuredJob, { ...configuredJob, id: "disabled", name: "Archive release artifacts", enabled: false, runningCount: 0, lastRunState: "failed" }], nextCursor: null }; else if (path === "/api/v1/jobs") json = empty ? [] : [configuredJob, { ...configuredJob, id: "disabled", name: "Archive release artifacts", enabled: false, runningCount: 0, lastRunState: "failed" }]; else if (path === "/api/v1/jobs/" + jobId) json = configuredJob;
Loading project…
{project.error.message}