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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ This repository holds the dashboard, the docs site and the website. The agent, t

| Feature | What you get |
|---|---|
| [Tickets to pull requests](https://docs.coderhelm.com/getting-started/first-run) | Assign a [GitHub issue](https://docs.coderhelm.com/getting-started/github) or [Jira ticket](https://docs.coderhelm.com/getting-started/jira), add the `coderhelm` label or comment `/coderhelm`. A plan, the change, your tests, a self review and a pull request. |
| [Tickets to pull requests](https://docs.coderhelm.com/getting-started/first-run) | Assign a [GitHub issue](https://docs.coderhelm.com/getting-started/github) or [Jira ticket](https://docs.coderhelm.com/getting-started/atlassian), add the `coderhelm` label or comment `/coderhelm`. A plan, the change, your tests, a self review and a pull request. |
| [PR reviewer](https://docs.coderhelm.com/getting-started/reviewer) | Add the review label (`ch-review` by default) to any pull request. A real GitHub review with line comments, a risk level and a verdict: it requests changes only for a named correctness, security or data loss problem with its evidence, and everything else is a labeled note. |
| [CI and review comment fixes](https://docs.coderhelm.com/getting-started/review-fixes) | Fixes failing CI on its pull requests, answers review comments, resolves conflicts and, with auto merge on, merges only the exact commit it reviewed. |
| [Alerts to fixes](https://coderhelm.com/alerts) | Route CloudWatch alarms and EventBridge events through SNS. Matching alerts become analyzed pull requests that a person approves. |
Expand Down
130 changes: 130 additions & 0 deletions dashboard/e2e/atlassian-one.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
import { expect, test, type Page, type Route } from "@playwright/test";
import fs from "node:fs";
import path from "node:path";

// Settings → Integrations: Jira, Confluence and Atlassian's own server are one
// Atlassian row (services/gateway/src/routes/integrations.rs, atlassian_card).
// Each piece keeps its own card under `detail.parts`. Every API call is
// answered here; nothing reaches a real backend.

const SHOTS_DIR = process.env.E2E_SHOTS_DIR || path.join("test-results", "shots");

function card(id: string, section: string, name: string, status: string, action: string, over: Record<string, unknown> = {}) {
return { id, section, name, does: `${name} does things.`, status, reason: "", action, last_check: "", manage_href: "", detail: {}, ...over };
}

function plugin(id: string, name: string) {
return {
id, name, description: "Agent tools for Jira issues and Confluence pages.", category: "Project Management", tier: 2, icon: id,
credential_fields: [], docs_url: "https://example.com/docs", repo_url: "https://example.com/docs", default_prompt: "Read only.", recommended_permissions: "Read access",
npx_package: "", remote_url: "https://mcp.example.com/v2/mcp", remote_key: false,
};
}

interface Parts {
jira: string;
confluence: string;
tools: string;
reason?: string;
status?: string;
action?: string;
}

function atlassian(p: Parts) {
const jira = card("jira", "code", "Jira", p.jira, p.jira === "connected" ? "manage" : "connect", { manage_href: "/settings/integrations/jira", detail: { app: p.jira === "connected", app_update: null } });
const confluence = card("confluence", "docs", "Confluence", p.confluence, p.confluence === "connected" ? "manage" : "connect", { detail: { kind: "confluence", connected: false, knowledge: null } });
const tools = card("atlassian", "code", "Atlassian", p.tools, p.tools === "connected" ? "manage" : "connect", {
detail: { plugin: plugin("atlassian", "Atlassian"), enabled: false, has_credentials: false, custom_prompt: "", last_test_ok: null, last_test_message: "", remote: null, own_app: null, unused: [] },
});
return card("atlassian", "code", "Atlassian", p.status ?? "not_connected", p.action ?? "connect", {
reason: p.reason ?? "",
detail: {
app_update: null,
parts: [
{ id: "jira", name: "Jira", what: "Coderhelm's Jira app (Forge): tickets start work.", item: jira },
{ id: "confluence", name: "Confluence", what: "Agents read pages and Knowledge syncs them.", item: confluence },
{ id: "agent_tools", name: "Agent tools", what: "Atlassian's own server (Rovo MCP).", item: tools },
],
},
});
}

async function mockApi(page: Page, items: unknown[], connect: (r: Route) => Promise<void>) {
const json = (route: Route, body: unknown, status = 200) => route.fulfill({ status, contentType: "application/json", body: JSON.stringify(body) });
const context = page.context();
await context.route((url) => url.hostname !== "localhost", (route) => route.abort());
await context.route((url) => url.hostname === "localhost" && /^\/(api|auth)\//.test(url.pathname), async (r) => {
const p = new URL(r.request().url()).pathname;
if (p === "/api/me") return json(r, { user_id: "u_1", team_id: "t_1", github_login: null, email: "person@example.com", avatar_url: "", role: "admin", auth_provider: "email" });
if (p === "/api/usage") return json(r, { month: "2026-01", tokens_in: 0, tokens_out: 0, total_runs: 0, total_tokens: 0, max_tokens: 0 });
if (p === "/api/banners") return json(r, { banners: [] });
if (p === "/api/teams") return json(r, { teams: [{ team_id: "t_1", org: "your-team", status: "active", current: true }] });
if (p === "/api/integrations") return json(r, { can_edit: true, items, migrated: 0 });
if (p === "/api/reviewer/org-config") return json(r, { instructions: "", web_domains: [] });
if (p === "/api/knowledge/connectors/confluence/connect") return connect(r);
return json(r, { error: `not mocked: ${p}` }, 404);
});
}

async function shot(page: Page, name: string) {
fs.mkdirSync(SHOTS_DIR, { recursive: true });
await page.addStyleTag({ content: "nextjs-portal{display:none!important}" });
for (const width of [1280, 375]) {
await page.setViewportSize({ width, height: 900 });
await page.screenshot({ path: path.join(SHOTS_DIR, `${name}-${width === 1280 ? "desktop" : "phone"}.png`), fullPage: true });
}
await page.setViewportSize({ width: 1280, height: 800 });
}

const github = card("github", "code", "GitHub", "connected", "manage", { manage_href: "/settings/integrations/github" });

test("one Atlassian row covers Jira, Confluence and agent tools", async ({ page }) => {
await mockApi(page, [github, atlassian({ jira: "not_connected", confluence: "not_connected", tools: "not_connected" })], (r) =>
r.fulfill({ status: 200, contentType: "application/json", body: "{}" }),
);
await page.goto("/settings/integrations/");
const rows = page.locator('[data-testid^="integration-"][data-status]');
await expect(page.getByTestId("integration-atlassian")).toBeVisible();
// No separate Jira or Confluence row.
await expect(page.getByTestId("integration-jira")).toHaveCount(0);
await expect(page.getByTestId("integration-confluence")).toHaveCount(0);
expect(await rows.count()).toBe(2);

await page.getByTestId("integration-atlassian").getByRole("button", { name: /Atlassian/ }).click();
const panel = page.getByTestId("atlassian-panel");
await expect(panel.getByTestId("atlassian-part-jira")).toBeVisible();
await expect(panel.getByTestId("atlassian-part-confluence")).toBeVisible();
await expect(panel.getByTestId("atlassian-part-agent_tools")).toBeVisible();
await expect(panel.getByRole("link", { name: "Install the Jira app" })).toHaveAttribute("href", /\/settings\/integrations\/jira/);
// One Connect, for the next piece that takes a sign-in: Confluence first.
await expect(panel.getByTestId("atlassian-connect")).toHaveAttribute("data-next", "confluence");
await expect(panel.getByRole("button", { name: "Connect Atlassian" })).toBeVisible();
await shot(page, "atlassian-one");
});

test("old links to the Jira or Confluence row open the Atlassian row", async ({ page }) => {
await mockApi(page, [github, atlassian({ jira: "connected", confluence: "connected", tools: "not_connected", status: "connected", action: "manage", reason: "Jira and Confluence are connected. Agent tools isn't set up." })], (r) =>
r.fulfill({ status: 200, contentType: "application/json", body: "{}" }),
);
await page.goto("/settings/integrations/#integration-confluence");
const panel = page.getByTestId("atlassian-panel");
await expect(panel).toBeVisible();
await expect(panel.getByTestId("atlassian-summary")).toHaveText("Jira and Confluence are connected. Agent tools isn't set up.");
// Connected Jira and Confluence carry over: the next step is agent tools.
await expect(panel.getByTestId("atlassian-part-jira")).toHaveAttribute("data-status", "connected");
await expect(panel.getByTestId("atlassian-connect")).toHaveAttribute("data-next", "agent_tools");
await expect(panel.getByRole("link", { name: "Manage the Jira app" })).toBeVisible();
});

test("Atlassian's sign-in failing on its side is said in plain words", async ({ page }) => {
const words = "Confluence's sign-in page is failing on Confluence's side (HTTP 500), so Coderhelm didn't send you there. Nothing on your side needs changing. Try again in a few minutes.";
await mockApi(page, [github, atlassian({ jira: "not_connected", confluence: "not_connected", tools: "not_connected" })], (r) =>
r.fulfill({ status: 400, contentType: "application/json", body: JSON.stringify({ error: words }) }),
);
await page.goto("/settings/integrations/#integration-atlassian");
const panel = page.getByTestId("atlassian-panel");
await panel.getByRole("button", { name: "Connect Atlassian" }).click();
await expect(panel.getByText("failing on Confluence's side (HTTP 500)")).toBeVisible();
// Nobody was sent anywhere.
await expect(page).toHaveURL(/\/settings\/integrations\//);
});
55 changes: 54 additions & 1 deletion dashboard/e2e/connected-apps.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ interface Opts {
teamWide?: boolean;
signedIn?: boolean;
describeError?: string;
/** The gateway sends each scope in plain words, the bases it opens and the team lookups to choose. */
bases?: boolean;
reader?: boolean;
github?: boolean;
}

async function mockApi(page: Page, o: Opts = {}): Promise<Db> {
Expand Down Expand Up @@ -68,7 +72,7 @@ async function mockApi(page: Page, o: Opts = {}): Promise<Db> {
if (p === "/api/usage") return json(route, { month: "2026-01", total_tokens: 0, tokens_in: 0, tokens_out: 0, total_runs: 0, max_tokens: 0 });
if (p === "/api/banners") return json(route, { banners: [] });
if (p === "/api/teams") return json(route, { teams: [{ team_id: "t_1", org: "acme-labs", status: "active", current: true }] });
if (p === "/auth/methods") return json(route, { password: true, google: false, github: false });
if (p === "/auth/methods") return json(route, { password: true, google: false, github: o.github ?? false });
if (p === "/api/mcp/authorize/describe") {
if (o.describeError) return json(route, { error: o.describeError }, 400);
return json(route, {
Expand All @@ -86,6 +90,22 @@ async function mockApi(page: Page, o: Opts = {}): Promise<Db> {
team_id: "t_1",
can_act: o.canAct ?? true,
mcp_url: MCP_URL,
...(o.bases
? {
reader: o.reader ?? false,
scopes: [
{ key: "runs:read", label: "See your team's runs and reviews", requested: true, always: true, plain: "Runs", opens: [] },
{ key: "knowledge:read", label: "Search the knowledge bases you can read in Chat", requested: true, always: false, plain: "Knowledge", opens: ["Knowledge"] },
],
lookup_scopes: [
{ key: "code:read", label: "Read and search your team's code, as Chat does", requested: true, default: true, plain: "Code", opens: ["Code"] },
{ key: "work:read", label: "Find tickets, pull requests, runs, reviews and plans you can see", requested: true, default: true, plain: "Work", opens: ["Work"] },
{ key: "infra:read", label: "Read your team's AWS resources and where each is defined", requested: true, default: false, plain: "Infrastructure", opens: ["Infrastructure"] },
{ key: "logs:read", label: "Read log findings and alerts you can see", requested: false, default: false, plain: "Logs", opens: ["Logs"] },
{ key: "security:read", label: "Read security findings you can see", requested: false, default: false, plain: "Security", opens: ["Security"] },
],
}
: {}),
});
}
if (p === "/api/mcp/authorize" && method === "POST") {
Expand Down Expand Up @@ -241,3 +261,36 @@ test("knowledge stays off when the app didn't ask, or the person unticks it", as
await page.waitForURL(/code=chc_test_code/);
expect(db.calls.find((c) => c.path === "/api/mcp/authorize")?.body).toMatchObject({ allow_knowledge: false });
});

test("the consent page names each scope in plain words, the bases it opens, and the lookups to choose", async ({ page }) => {
const db = await mockApi(page, { bases: true, reader: true });
await page.goto(`/authorize/?request=${REQUEST}`);
const list = page.getByRole("list", { name: "What the app may do" });
await expect(list.getByText("Runs:", { exact: false })).toBeVisible();
const lookups = page.getByTestId("consent-lookup");
await expect(lookups).toHaveCount(5);
await expect(lookups.nth(0)).toContainText("Code:");
await expect(lookups.nth(0)).toContainText("Opens Code");
await expect(lookups.nth(2)).toContainText("Opens Infrastructure");
// Code and work ticked; infrastructure, logs and security only when the person ticks them.
await expect(lookups.nth(0).getByRole("checkbox")).toBeChecked();
await expect(lookups.nth(1).getByRole("checkbox")).toBeChecked();
await expect(lookups.nth(2).getByRole("checkbox")).not.toBeChecked();
await expect(lookups.nth(2)).toContainText("The app asked for this");
await expect(page.getByTestId("consent-reader")).toContainText("don't take a seat");
await lookups.nth(2).getByRole("checkbox").check();
await lookups.nth(1).getByRole("checkbox").uncheck();
await shot(page, "consent-bases-1280.png");
await page.getByRole("button", { name: "Allow", exact: true }).click();
await expect.poll(() => db.calls.find((c) => c.path === "/api/mcp/authorize")?.body).toMatchObject({ approve: true, allow_scopes: ["code:read", "infra:read"] });
});

test("signed out on the consent page, GitHub sign-in comes back to it and offers reader access", async ({ page }) => {
await mockApi(page, { signedIn: false, github: true });
await page.goto(`/authorize/?request=${REQUEST}`);
await expect(page.getByTestId("sign-in-reader")).toContainText("without a seat");
const gh = page.getByRole("link", { name: "Continue with GitHub" });
const href = await gh.getAttribute("href");
expect(href?.endsWith(`/auth/github?return_to=${encodeURIComponent(`/authorize/?request=${REQUEST}`)}`)).toBe(true);
await shot(page, "consent-signed-out-reader-1280.png");
});
56 changes: 56 additions & 0 deletions dashboard/e2e/infra-security.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ async function mockApi(page: Page, init: Partial<Db> = {}): Promise<Db> {
if (p === "/api/security/infrastructure/insights") return json(route, INFRA_INSIGHTS);
if (p === "/api/security/infrastructure/check") return json(route, { status: "queued" }, 202);
if (/^\/api\/security\/infrastructure\/findings\/[^/]+\/fix$/.test(p)) return json(route, { status: "started", reason: null });
if (/^\/api\/security\/infrastructure\/findings\/[^/]+\/apply$/.test(p)) return json(route, { status: "queued", when: (body as { when?: string } | null)?.when ?? "next-maintenance" });
if (p === "/api/infra/analysis" || p.startsWith("/api/infra")) return json(route, { analysis: null });
return json(route, { error: `Not mocked: ${method} ${p}` }, 404);
});
Expand All @@ -61,6 +62,61 @@ async function mockApi(page: Page, init: Partial<Db> = {}): Promise<Db> {
const call = (db: Db, c: string) => db.calls.filter((x) => x.call === c);

test.describe("Infrastructure vulnerabilities", () => {
test("fixed and removed rows leave the open list, an update in AWS is approved, and a stale read refreshes", async ({ page }) => {
const osUpdate = infraFinding({
id: "f_os",
kind: "rds_cluster",
name: "staging-orders-db",
title: "Aurora cluster staging-orders-db: operating system update (the cluster and its 1 instance) pending",
tier: "P2",
fix: {
kind: "apply",
summary: "CoderHelm applies the operating system update in AWS after your approval (`os-upgrade`)",
location: null,
from: "16.13",
to: "",
cli: [],
console: "",
apply_by: "",
reason: "New Operating System patch is available",
decision: "CoderHelm applies this in AWS after one approval.",
apply: { action: "os-upgrade", arns: ["arn:aws:rds:us-east-1:111122223333:cluster:staging-orders-db"], permission: "rds:ApplyPendingMaintenanceAction", default_opt_in: "next-maintenance", effect: "Each instance restarts." },
},
});
const fixed = infraFinding({ id: "f_fixed", title: "Aurora cluster prod-orders-db: engine version upgrade to 16.13 pending", status: "fixed", fixed_at: iso(-2), actionable: false });
const removed = infraFinding({
id: "f_removed",
kind: "rds_instance",
title: "RDS instance legacy-db-0002: operating system update pending",
status: "removed",
fixed_at: iso(-2),
removed_at: iso(-2),
actionable: false,
fix: { kind: "runbook", summary: "Apply it in AWS", location: null, from: "", to: "", cli: ["aws rds apply-pending-maintenance-action"], console: "", apply_by: "", reason: "" },
});
const merged = infraFinding({ id: "f_merged", title: "Merged duplicate", status: "merged" });
const stale = infraOverview({ findings: [osUpdate, fixed, removed, merged], read_at: iso(-30), oldest_read_at: iso(-30), refreshing: true });
const db = await mockApi(page, { overview: stale });
await page.goto("/security/infrastructure");
await expect(page.getByTestId("infra-refreshing")).toBeVisible();
const open = page.getByRole("list", { name: "Infrastructure findings" }).getByTestId("infra-row");
await expect(open).toHaveCount(1);
await expect(open.first()).toContainText("operating system update");
await expect(page.getByText("Merged duplicate")).toHaveCount(0);
// Approve: the default is the next maintenance window.
await open.first().getByTestId("infra-apply").click();
await expect.poll(() => call(db, "POST /api/security/infrastructure/findings/f_os/apply").length).toBe(1);
expect(call(db, "POST /api/security/infrastructure/findings/f_os/apply")[0].body).toEqual({ when: "next-maintenance" });
// The closed rows sit under their own filter, with nothing to click.
await page.getByRole("group", { name: "Show" }).getByRole("button", { name: /Fixed \/ Removed/ }).click();
const closed = page.getByRole("list", { name: "Fixed or removed findings" }).getByTestId("infra-row");
await expect(closed).toHaveCount(2);
await expect(closed.getByTestId("infra-fix")).toHaveCount(0);
await expect(closed.getByTestId("infra-apply")).toHaveCount(0);
await expect(closed.getByTestId("fix-chip")).toHaveCount(0);
await expect(closed.filter({ hasText: "legacy-db-0002" }).getByTestId("infra-closed")).toHaveAttribute("data-status", "removed");
});

test("the Infrastructure tab groups by fix: PRs, a runbook card and AWS-managed rows that never count", async ({ page }) => {
const db = await mockApi(page);
await page.goto("/security/infrastructure");
Expand Down
Loading
Loading