Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/app/src/features/runs/history.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function RunHistory({ jobId }: { jobId: string }) {
const clearStatuses = () => void navigate({ to: "/jobs/$jobId", params: { jobId }, search: { ...search, states: undefined, sort: undefined, direction: undefined, cursor: undefined, previous: undefined } });
return <section aria-label="Runs" className="my-6 min-w-0">
{runs.isPending && <p role="status">Loading run history…</p>}{runs.error && <p role="alert">{runs.error.message} <Button onClick={() => void runs.refetch()}>Retry</Button></p>}
{runs.data && <><Table className="min-w-[40rem] table-fixed" shellProps={{ role: "region", "aria-label": "Runs table", tabIndex: 0 }}><caption className="sr-only">Job runs{search.sort ? "" : ", newest first"}</caption><colgroup><col className="w-16 sm:w-20" /><col className="w-[34%] sm:w-[38%]" /><col className="w-[22%] sm:w-[20%]" /><col className="w-[20%] sm:w-[18%]" /><col className="w-[20%] sm:w-[16%]" /></colgroup>
{runs.data && <><Table className="min-w-[40rem] table-fixed" shellProps={{ role: "region", "aria-label": "Runs table", tabIndex: 0 }}><caption className="sr-only">Job runs{search.sort ? "" : ", newest first"}</caption><colgroup><col className="w-20" /><col className="w-60" /><col className="w-44" /><col className="w-52" /><col className="w-32" /></colgroup>
<thead className={tableHeadClasses}><tr><StatusHeader selected={search.states ?? []} sortDirection={search.sort === "status" ? search.direction : undefined} onFilterChange={changeFilter} onSortChange={changeStatusSort} onClear={clearStatuses} />{columns.slice(1, 2).map(([column, label]) => <SortableHeader key={column} label={label} active={search.sort === column} direction={search.direction} ariaLabel={`${label}, ${sortLabel(column)}`} onSort={() => sortColumn(column)} />)}<th scope="col" className={tableCellClasses}>Estimated</th>{columns.slice(2).map(([column, label]) => <SortableHeader key={column} label={label} active={search.sort === column} direction={search.direction} ariaLabel={`${label}, ${sortLabel(column)}`} onSort={() => sortColumn(column)} />)}</tr></thead>
<tbody>{runs.data.items.map(run => <tr className={tableRowClasses} key={run.id}>
<td className={`whitespace-nowrap ${tableCellClasses}`}><RunStatusDot state={run.state} /></td>
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/features/runs/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function RunList({ jobId, limit = 30 }: { jobId?: string; limit?: number
</nav>;
return <section aria-label="Job runs" className="my-6 min-w-0">
{runs.isPending && <p role="status">Loading runs…</p>}{runs.error && <p role="alert">{runs.error.message} <Button onClick={() => void runs.refetch()}>Retry</Button></p>}
{runs.data && <><Table className="min-w-[58rem] table-fixed" shellProps={{ role: "region", "aria-label": "Job runs table", tabIndex: 0 }}><caption className="sr-only">Job runs{search.sort ? "" : ", newest first"}</caption><colgroup><col className="w-14 sm:w-16" /><col className="w-[20%] sm:w-[22%]" /><col className="w-[20%] sm:w-[22%]" /><col className="w-[24%] sm:w-[22%]" /><col className="w-[16%] sm:w-[14%]" /><col className="w-[20%] sm:w-[16%]" /></colgroup><thead className={tableHeadClasses}><tr>{statusHeader}<th scope="col" className={tableCellClasses}>Project name</th>{sortableHeader("job", "Job name")}{sortableHeader("run", "Run")}<th scope="col" className={tableCellClasses}>Estimated</th>{sortableHeader("created", "Created")}</tr></thead><tbody>{runs.data.items.map(run => <tr className={tableRowClasses} key={run.id}><td className={`whitespace-nowrap ${tableCellClasses}`}><RunStatusDot state={run.state} /></td><td className={tableCellClasses}>{run.project_id && run.project_name ? <Link to="/projects/$projectId" params={{ projectId: run.project_id }} title={run.project_name} className="block truncate font-semibold hover:text-factorize-700 dark:hover:text-factorize-500">{run.project_name}</Link> : <span className="text-slate-500">—</span>}</td><td className={tableCellClasses}><Link to="/jobs/$jobId" params={{ jobId: run.job_id }} title={run.job_name} className="block truncate font-semibold hover:text-factorize-700 dark:hover:text-factorize-500">{run.job_name}</Link></td><td className={tableCellClasses}><Link to="/job-runs/$runId" params={{ runId: run.id }} search={{ after: 0 }} title={run.run_name || "Run"} className="block truncate font-semibold hover:text-factorize-700 dark:hover:text-factorize-500">{run.run_name || "Run"}</Link></td><td className={`whitespace-nowrap ${tableCellClasses}`} title={run.estimated_time ? `Low ${formatEstimatedTime(run.estimated_time.low)}, median ${formatEstimatedTime(run.estimated_time.median)}, high ${formatEstimatedTime(run.estimated_time.high)}` : undefined}>{run.estimated_time ? `${formatEstimatedTime(run.estimated_time.low)}–${formatEstimatedTime(run.estimated_time.median)}–${formatEstimatedTime(run.estimated_time.high)}` : "—"}</td><td className={`whitespace-nowrap ${tableCellClasses}`}><time dateTime={run.created_at}>{new Date(run.created_at).toLocaleString()}</time></td></tr>)}{runs.data.items.length === 0 && <tr><td colSpan={6} className={`${tableCellClasses} py-6 text-center`}>{search.states?.length ? <><p>No runs match the selected statuses.</p><Button className="mt-3" onClick={() => void navigate({ search: { ...search, states: undefined, cursor: undefined, previous: undefined } })}>Clear status filters</Button></> : jobId ? "No runs found." : "No runs yet"}</td></tr>}</tbody></Table></>}
{runs.data && <><Table className="min-w-[58rem] table-fixed" shellProps={{ role: "region", "aria-label": "Job runs table", tabIndex: 0 }}><caption className="sr-only">Job runs{search.sort ? "" : ", newest first"}</caption><colgroup><col className="w-14" /><col className="w-44" /><col className="w-44" /><col className="w-52" /><col className="w-44" /><col className="w-52" /></colgroup><thead className={tableHeadClasses}><tr>{statusHeader}<th scope="col" className={tableCellClasses}>Project name</th>{sortableHeader("job", "Job name")}{sortableHeader("run", "Run")}<th scope="col" className={tableCellClasses}>Estimated</th>{sortableHeader("created", "Created")}</tr></thead><tbody>{runs.data.items.map(run => <tr className={tableRowClasses} key={run.id}><td className={`whitespace-nowrap ${tableCellClasses}`}><RunStatusDot state={run.state} /></td><td className={tableCellClasses}>{run.project_id && run.project_name ? <Link to="/projects/$projectId" params={{ projectId: run.project_id }} title={run.project_name} className="block truncate font-semibold hover:text-factorize-700 dark:hover:text-factorize-500">{run.project_name}</Link> : <span className="text-slate-500">—</span>}</td><td className={tableCellClasses}><Link to="/jobs/$jobId" params={{ jobId: run.job_id }} title={run.job_name} className="block truncate font-semibold hover:text-factorize-700 dark:hover:text-factorize-500">{run.job_name}</Link></td><td className={tableCellClasses}><Link to="/job-runs/$runId" params={{ runId: run.id }} search={{ after: 0 }} title={run.run_name || "Run"} className="block truncate font-semibold hover:text-factorize-700 dark:hover:text-factorize-500">{run.run_name || "Run"}</Link></td><td className={`whitespace-nowrap ${tableCellClasses}`} title={run.estimated_time ? `Low ${formatEstimatedTime(run.estimated_time.low)}, median ${formatEstimatedTime(run.estimated_time.median)}, high ${formatEstimatedTime(run.estimated_time.high)}` : undefined}>{run.estimated_time ? `${formatEstimatedTime(run.estimated_time.low)}–${formatEstimatedTime(run.estimated_time.median)}–${formatEstimatedTime(run.estimated_time.high)}` : "—"}</td><td className={`whitespace-nowrap ${tableCellClasses}`}><time dateTime={run.created_at}>{new Date(run.created_at).toLocaleString()}</time></td></tr>)}{runs.data.items.length === 0 && <tr><td colSpan={6} className={`${tableCellClasses} py-6 text-center`}>{search.states?.length ? <><p>No runs match the selected statuses.</p><Button className="mt-3" onClick={() => void navigate({ search: { ...search, states: undefined, cursor: undefined, previous: undefined } })}>Clear status filters</Button></> : jobId ? "No runs found." : "No runs yet"}</td></tr>}</tbody></Table></>}
{pagination}
</section>;
}
3 changes: 2 additions & 1 deletion packages/app/test/runs.browser.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ after(async () => { await browser?.close(); if (server) await new Promise(resolv
async function setup() { const context = await browser.newContext(), page = await context.newPage(); page.setDefaultTimeout(10000); await page.route("**/api/v1/session", route => route.fulfill({ json: { authenticated: true, user: { id: "owner", email: "owner@example.test" }, workspace: { id: "tenant", name: "Workspace" }, capabilities: [], expiresAt: "2026-10-10T00:00:00Z" } })); return { context, page }; }
test("all-jobs runs index uses a tenant-scoped page, navigation, refresh, and created time", async () => {
const { context, page } = await setup(); const requests = []; let refreshes = 0;
const runs = Array.from({ length: 21 }, (_, index) => ({ id: `00000000-0000-4000-8000-${String(index + 1).padStart(12, "0")}`, project_id: projectId, project_name: "Project Alpha", job_id: jobId, job_name: "Review builds", run_name: `Run ${index}`, state: index === 0 ? "running" : "succeeded", created_at: time, updated_at: time, started_at: index === 0 ? time : null, agent_kind: "codex" }));
const runs = Array.from({ length: 21 }, (_, index) => ({ id: `00000000-0000-4000-8000-${String(index + 1).padStart(12, "0")}`, project_id: projectId, project_name: "Project Alpha", job_id: jobId, job_name: "Review builds", run_name: `Run ${index}`, state: index === 0 ? "running" : "succeeded", created_at: time, updated_at: time, started_at: index === 0 ? time : null, agent_kind: "codex", estimated_time: { low: 60, median: 120, high: 180 } }));
await page.route("**/api/v1/runs?**", route => { const url = new URL(route.request().url()); requests.push(url); refreshes++; const second = url.searchParams.has("cursor"); return route.fulfill({ json: { items: second ? [runs[20]] : runs.slice(0, 20), nextCursor: second ? null : "page-2" } }); });
await page.goto(origin + "/job-runs"); await page.getByRole("heading", { name: "Job Runs", exact: true }).waitFor(); await page.getByRole("link", { name: "Run 0", exact: true }).waitFor();
assert.equal(await page.getByRole("link", { name: "Jobs", exact: true }).count(), 0); assert.equal(await page.getByRole("link", { name: "Runs", exact: true }).evaluate(el => el.className.includes("border-factorize-500")), true);
const table = page.getByRole("table"); assert.deepEqual(await table.locator("thead th").allTextContents(), ["Status", "Project name", "Job name", "Run", "Estimated", "Created"]); assert.equal(await page.getByText("Run 0", { exact: true }).count(), 1); assert.equal(await page.getByRole("link", { name: "Project Alpha", exact: true }).first().getAttribute("href"), `/projects/${projectId}`); assert.equal(await page.locator("td time").count(), 20); assert.equal(await page.locator("td time").first().getAttribute("datetime"), time);
const firstRowCells = await table.locator("tbody tr").first().locator("td").all(); const estimatedBox = await firstRowCells[4].boundingBox(); const createdBox = await firstRowCells[5].boundingBox(); assert.ok(estimatedBox && createdBox && estimatedBox.x + estimatedBox.width <= createdBox.x, "Estimated and Created columns must not overlap");
assert.ok(requests.every(url => url.searchParams.get("limit") === "20" && !url.searchParams.has("jobId")));
await page.getByRole("link", { name: "Next page" }).click(); await page.getByRole("link", { name: "Run 20", exact: true }).waitFor(); await page.reload(); await page.getByRole("link", { name: "Run 20", exact: true }).waitFor(); assert.ok(refreshes >= 2);
await context.close();
Expand Down
Loading