Skip to content
Open
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
40 changes: 40 additions & 0 deletions e2e/dashboard-widgets.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ test.beforeEach(async ({ page }) => {
accessToken: "test-token",
},
maxAge: 60 * 60,
cookieName: "next-auth.session-token",
});

await page.context().addCookies([
Expand Down Expand Up @@ -93,6 +94,45 @@ test.beforeEach(async ({ page }) => {
});
});

await page.route("**/api/goals/sync", async (route) => {
await route.fulfill({
contentType: "application/json",
body: JSON.stringify({ updated: 1, commitCount: 4 }),
});
});

await page.route("**/api/ai-insights**", async (route) => {
await route.fulfill({
contentType: "application/json",
body: JSON.stringify({
data: {
insights: [
{
id: "insight-1",
type: "productivity",
title: "High Consistency",
description: "You have coded 5 days this week!",
severity: "positive",
},
],
trend: { direction: "up", percentage: 15 },
aiSummary: "Great job shipping features this week. Keep up the high standard!",
generatedAt: "2026-05-18T12:00:00.000Z",
},
}),
});
});

await page.route("**/api/notifications**", async (route) => {
await route.fulfill({
contentType: "application/json",
body: JSON.stringify({
notifications: [],
unreadCount: 0,
}),
});
});

const metricRoutes = [
"**/api/metrics/prs**",
"**/api/metrics/pr-breakdown**",
Expand Down
12 changes: 12 additions & 0 deletions e2e/landing.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,15 @@ test("dashboard stays protected for unauthenticated users", async ({ page }) =>
await expect(page).toHaveURL(/\/$/);
await expect(page.getByRole("link", { name: "Sign in with GitHub" })).toBeVisible();
});

test("landing shows footer", async ({ page }) => {
await page.goto("/");

await expect(page.getByRole("contentinfo")).toBeVisible();
});

test("landing has dashboard link", async ({ page }) => {
await page.goto("/");

await expect(page.getByRole("link", { name: "Dashboard" })).toBeVisible();
});
13 changes: 9 additions & 4 deletions src/app/api/metrics/ci/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,15 @@ async function fetchCIAnalyticsForAccount(token: string, githubLogin: string): P
const repos = Array.from(repoMap.entries()).map(([name, commits]) => ({ name, commits })).sort((a, b) => b.commits - a.commits).slice(0, 5);

const runsByRepo = await Promise.all(repos.map(async (repo) => {
const res = await fetch(`${GITHUB_API}/repos/${repo.name}/actions/runs?per_page=100&created=>=${toIsoDate(30)}`, { headers: { Authorization: `Bearer ${token}`, Accept: "application/vnd.github+json" }, cache: "no-store" });
if (res.status === 404 || res.status === 403) return [];
if (!res.ok) throw new Error("API error");
const d = await res.json(); return d.workflow_runs ?? [];
try {
const res = await fetch(`${GITHUB_API}/repos/${repo.name}/actions/runs?per_page=100&created=>=${toIsoDate(30)}`, { headers: { Authorization: `Bearer ${token}`, Accept: "application/vnd.github+json" }, cache: "no-store" });
if (res.status === 404 || res.status === 403) return [];
if (!res.ok) throw new Error("API error");
const d = await res.json(); return d.workflow_runs ?? [];
} catch (err) {
console.error(`Failed to fetch signals for repo ${repo.name}:`, err);
return [];
}
}));

const runs = runsByRepo.flat().filter((r: WorkflowRun) => r.conclusion);
Expand Down
Loading