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
8 changes: 7 additions & 1 deletion packages/app/src/features/projects/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ProjectNav tab="jobs" actions={project.data&&<div className="flex flex-wrap items-center gap-3"><div role="group" aria-label="Project jobs view" className="flex gap-2"><Button aria-pressed={view === "list"} onClick={() => setView("list")}>List</Button><Button aria-pressed={view === "graph"} onClick={() => setView("graph")}>Graph</Button></div><Link to="/jobs/new" search={{ projectId }}><Button variant="primary">Create job</Button></Link></div>}>{view === "list" ? <JobsTable projectId={projectId} /> : <ProjectGraph projectId={projectId} />}</ProjectNav>;
return <ProjectNav tab="jobs">{project.data && <div className="mb-5 flex flex-wrap items-center justify-end gap-3">
<div role="group" aria-label="Project jobs view" className="inline-flex rounded-lg border border-stone-200 bg-white p-0.5 dark:border-slate-700 dark:bg-slate-900">
<Button className={`min-h-9 rounded-md border-0 px-3 py-1.5 ${view === "list" ? "bg-stone-100 text-slate-950 shadow-sm dark:bg-slate-800 dark:text-white" : "bg-transparent text-slate-600 hover:bg-stone-50 dark:text-slate-300 dark:hover:bg-slate-800"}`} aria-pressed={view === "list"} onClick={() => setView("list")}>List</Button>
<Button className={`min-h-9 rounded-md border-0 px-3 py-1.5 ${view === "graph" ? "bg-stone-100 text-slate-950 shadow-sm dark:bg-slate-800 dark:text-white" : "bg-transparent text-slate-600 hover:bg-stone-50 dark:text-slate-300 dark:hover:bg-slate-800"}`} aria-pressed={view === "graph"} onClick={() => setView("graph")}>Graph</Button>
</div>
<Link to="/jobs/new" search={{ projectId }}><Button variant="primary">Create job</Button></Link>
</div>}{view === "list" ? <JobsTable projectId={projectId} /> : <ProjectGraph projectId={projectId} />}</ProjectNav>;
}
34 changes: 21 additions & 13 deletions packages/app/src/features/projects/project-nav.tsx
Original file line number Diff line number Diff line change
@@ -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: <svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" className="size-[18px]"><rect x="3.5" y="7" width="17" height="13.5" rx="2"/><path strokeLinecap="round" strokeLinejoin="round" d="M8.5 7V5.5A1.5 1.5 0 0 1 10 4h4a1.5 1.5 0 0 1 1.5 1.5V7M3.5 12h17m-10 0v1.5h3V12"/></svg> },
{ id: "runs", label: "Runs", to: "/projects/$projectId/runs", icon: <svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" className="size-[18px]"><circle cx="12" cy="12" r="9"/><path fill="currentColor" stroke="none" d="m10 8 6 4-6 4z"/></svg> },
{ id: "settings", label: "Settings", to: "/projects/$projectId/settings", icon: <svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" className="size-[18px]"><path strokeLinecap="round" strokeLinejoin="round" d="M10 3.8h4l.6 2.1 1.6.9 2.1-.6 2 3.5-1.5 1.6v1.8l1.5 1.6-2 3.5-2.1-.6-1.6.9-.6 2.1h-4l-.6-2.1-1.6-.9-2.1.6-2-3.5 1.5-1.6v-1.8L3.7 9.7l2-3.5 2.1.6 1.6-.9z"/><circle cx="12" cy="12" r="3"/></svg> },
];

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 <Page className="max-w-6xl">
<Breadcrumb><Link to="/projects">Projects</Link></Breadcrumb>
<ResourceHeader type="Project" title={project.data?.name ?? "Project"} description={project.data?.description}>{actions}</ResourceHeader>
<nav aria-label="Project navigation" className="-mt-3 mb-5 flex gap-1 border-b border-stone-200 dark:border-slate-800">
<Link to="/projects/$projectId" params={{ projectId }} className={tabClass("jobs")} aria-current={tab === "jobs" ? "page" : undefined}>Jobs</Link>
<Link to="/projects/$projectId/runs" params={{ projectId }} className={tabClass("runs")} aria-current={tab === "runs" ? "page" : undefined}>Runs</Link>
<Link to="/projects/$projectId/settings" params={{ projectId }} className={tabClass("settings")} aria-current={tab === "settings" ? "page" : undefined}>Settings</Link>
return <>
<nav aria-label="Project navigation" className="border-y border-stone-200 bg-white dark:border-slate-800 dark:bg-slate-950">
<div className="mx-auto flex w-full max-w-6xl gap-1 overflow-x-auto px-4 sm:px-6 lg:px-8">
{tabs.map(item => <Link key={item.id} to={item.to} params={{ projectId }} className={`inline-flex min-h-12 shrink-0 items-center gap-2 border-b-2 px-3 text-sm font-semibold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-factorize-500 ${tab === item.id ? "border-factorize-500 text-factorize-700 dark:text-factorize-400" : "border-transparent text-slate-600 hover:border-stone-300 hover:text-slate-950 dark:text-slate-300 dark:hover:border-slate-600 dark:hover:text-white"}`} aria-current={tab === item.id ? "page" : undefined}>{item.icon}{item.label}</Link>)}
</div>
</nav>
{project.isPending && <p role="status">Loading project…</p>}{project.error && <p role="alert">{project.error.message}</p>}
{children}
</Page>;
<Page className="pt-6 sm:pt-8">
<h1 className="sr-only">{project.data?.name ?? "Project"} {tab === "jobs" ? "jobs" : tab === "runs" ? "runs" : "settings"}</h1>
{project.isPending && <p role="status">Loading project…</p>}{project.error && <p role="alert">{project.error.message}</p>}
{children}
</Page>
</>;
}
22 changes: 12 additions & 10 deletions packages/app/test/jobs.browser.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -281,18 +282,19 @@ 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: [] } }));
await page.goto(origin + "/projects");
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" });
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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\/[^/]+(?:\?|$)/);

Expand Down
11 changes: 6 additions & 5 deletions packages/app/test/runs.browser.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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 () => {
Expand Down Expand Up @@ -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 () => {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 25 additions & 1 deletion packages/app/test/visual/design.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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);
Expand Down
Loading
Loading