Skip to content
Closed
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
43 changes: 38 additions & 5 deletions e2e/dashboard-widgets.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ test.beforeEach(async ({ page }) => {
secure: false,
expires: Math.floor(Date.now() / 1000) + 60 * 60,
},
{
name: "playwright-dashboard-auth",
value: "1",
domain: "127.0.0.1",
path: "/",
httpOnly: true,
sameSite: "Lax",
secure: false,
expires: Math.floor(Date.now() / 1000) + 60 * 60,
},
]);

await page.route("**/api/auth/session", async (route) => {
Expand Down Expand Up @@ -102,6 +112,7 @@ test.beforeEach(async ({ page }) => {
"**/api/metrics/weekly-summary**",
"**/api/metrics/compare**",
"**/api/metrics/repo-health**",
"**/api/metrics/ci**",
"**/api/streak/freeze**",
"**/api/user/github-accounts**",
];
Expand All @@ -120,7 +131,7 @@ test("dashboard widgets render with mocked metrics", async ({ page }) => {
await page.goto("/dashboard");

await expect(page.getByRole("heading", { name: "Dashboard" })).toBeVisible();
await expect(page.getByRole("heading", { name: "Commit Activity" })).toBeVisible();
await expect(page.getByRole("heading", { name: "Your Commits" })).toBeVisible();
await expect(page.getByRole("heading", { name: "PR Analytics" })).toBeVisible();
await expect(page.getByRole("heading", { name: "Weekly Goals" })).toBeVisible();
await expect(page.getByText("Make 10 commits")).toBeVisible();
Expand Down Expand Up @@ -164,13 +175,26 @@ test("goal form posts a new goal", async ({ page }) => {

function mockMetricResponse(url) {
if (url.includes("/api/metrics/prs")) {
return { open: 2, merged: 8, avgReviewHours: 6, mergeRate: "80%" };
return {
open: 2,
merged: 8,
avgReviewHours: 6,
avgFirstReviewHours: 3,
mergeRate: "80%",
};
}
if (url.includes("/api/metrics/pr-breakdown")) {
return { merged: 8, open: 2, closed: 1 };
return { draft: 1, merged: 8, open: 2, closed: 1 };
}
if (url.includes("/api/metrics/issues")) {
return { opened: 4, closed: 3, open: 1 };
return {
opened: 4,
closed: 3,
currentlyOpen: 1,
avgCloseTimeDays: 2,
trend: 1,
mostActiveRepo: "demo/repo",
};
}
if (url.includes("/api/metrics/repos") || url.includes("/api/metrics/pinned-repos")) {
return { repos: [{ name: "demo/repo", commits: 12, url: "https://github.com/demo/repo" }] };
Expand All @@ -182,14 +206,23 @@ function mockMetricResponse(url) {
return { current: 3, longest: 9, lastCommitDate: "2026-05-18", totalActiveDays: 12 };
}
if (url.includes("/api/metrics/weekly-summary")) {
return { commits: 10, pullRequests: 3, mergedPullRequests: 2 };
return {
commits: { current: 10, previous: 7, delta: 3, trend: "up" },
prs: { opened: 3, merged: 2 },
activeDays: 5,
streak: 3,
topRepo: "demo/repo",
};
}
if (url.includes("/api/metrics/compare")) {
return { user: { commits: 10 }, friend: { commits: 8 } };
}
if (url.includes("/api/metrics/repo-health")) {
return { repositories: [] };
}
if (url.includes("/api/metrics/ci")) {
return { success: 6, failed: 1, cancelled: 0, skipped: 0 };
}
if (url.includes("/api/streak/freeze")) {
return { freezes: [] };
}
Expand Down
55 changes: 50 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"recharts": "^2.12.7"
},
"devDependencies": {
"@playwright/test": "1.49.1",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
Expand Down
1 change: 1 addition & 0 deletions playwright.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default defineConfig({
NEXT_PUBLIC_SUPABASE_URL: "https://placeholder.supabase.co",
NEXT_PUBLIC_SUPABASE_ANON_KEY: "placeholder-anon-key",
SUPABASE_SERVICE_ROLE_KEY: "placeholder-service-role-key",
PLAYWRIGHT_AUTH_BYPASS: "1",
},
},
projects: [
Expand Down
Loading