-
-
Notifications
You must be signed in to change notification settings - Fork 271
Implement the detailed metrics dashboard page #1748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
arkid15r
merged 25 commits into
OWASP:main
from
ahmedxgouda:dashboard/metrics-details-frontend
Jul 21, 2025
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
a5ad675
Add more fields to the metrics node
ahmedxgouda b5ebc3b
Initial page setup
ahmedxgouda 271adee
Update page
ahmedxgouda 1988615
Update backend
ahmedxgouda 5a64432
Update backend
ahmedxgouda c06e6bf
Update frontend
ahmedxgouda 22ff74d
Merge branch 'main' into dashboard/metrics-details-frontend
ahmedxgouda 4f121cd
Add backend tests and last pull request days
ahmedxgouda 881ecaa
Add tooltip
ahmedxgouda 459e998
Add the option to display the valid colors if it is preffered that th…
ahmedxgouda 279df43
Improve styling
ahmedxgouda e8400c4
Update frontend tests mocking
ahmedxgouda 7831e9f
Add test mocking
ahmedxgouda a8e533c
Implement charts
ahmedxgouda a1e84a4
Add badges
ahmedxgouda 7a166c4
Update tests
ahmedxgouda 17fc95b
Add error message
ahmedxgouda ac69330
Merge branch 'main' into dashboard/metrics-details-frontend
ahmedxgouda 92688ee
Update tests
ahmedxgouda 55b33f4
Apply sonar suggestion
ahmedxgouda 7a9c7b2
Update tests
ahmedxgouda 373e16f
Update tests
ahmedxgouda e8e7375
Merge branch 'main' into dashboard/metrics-details-frontend
kasya ed476bc
Update badges styling
kasya 74bcd72
Merge branch 'main' into dashboard/metrics-details-frontend
kasya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
frontend/__tests__/e2e/pages/ProjectHealthDashboardMetricsDetails.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import { expect, test } from '@playwright/test' | ||
| import { mockProjectsDashboardMetricsDetailsData } from '@unit/data/mockProjectsDashboardMetricsDetailsData' | ||
|
|
||
| test.describe('Project Health Metrics Details Page', () => { | ||
| test.beforeEach(async ({ page }) => { | ||
| await page.route('**/graphql/', async (route) => { | ||
| await route.fulfill({ | ||
| status: 200, | ||
| json: { data: mockProjectsDashboardMetricsDetailsData }, | ||
| }) | ||
| }) | ||
| await page.context().addCookies([ | ||
| { | ||
| name: 'csrftoken', | ||
| value: 'abc123', | ||
| domain: 'localhost', | ||
| path: '/', | ||
| }, | ||
| ]) | ||
| await page.goto('/projects/dashboard/metrics/test-project') | ||
| }) | ||
|
|
||
| test('renders project health metrics details', async ({ page }) => { | ||
| const metricsLatest = mockProjectsDashboardMetricsDetailsData.project.healthMetricsLatest | ||
| const headers = [ | ||
| 'Days Metrics', | ||
| 'Issues', | ||
| 'Stars', | ||
| 'Forks', | ||
| 'Contributors', | ||
| 'Releases', | ||
| 'Open Pull Requests', | ||
| 'Health', | ||
| 'Score', | ||
| ] | ||
| await expect(page.getByText(metricsLatest.projectName)).toBeVisible() | ||
| await expect(page.getByText(metricsLatest.score.toString())).toBeVisible() | ||
| for (const header of headers) { | ||
| await expect(page.getByText(header, { exact: true })).toBeVisible() | ||
| } | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
frontend/__tests__/unit/data/mockProjectsDashboardMetricsDetailsData.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| export const mockProjectsDashboardMetricsDetailsData = { | ||
| project: { | ||
| healthMetricsLatest: { | ||
| ageDays: 200, | ||
| ageDaysRequirement: 100, | ||
| isFundingRequirementsCompliant: true, | ||
| isLeaderRequirementsCompliant: false, | ||
| lastCommitDays: 22, | ||
| lastCommitDaysRequirement: 30, | ||
| lastPullRequestDays: 55, | ||
| lastPullRequestDaysRequirement: 56, | ||
| lastReleaseDays: 57, | ||
| lastReleaseDaysRequirement: 58, | ||
| owaspPageLastUpdateDays: 52, | ||
| owaspPageLastUpdateDaysRequirement: 53, | ||
| projectName: 'Test', | ||
| score: 41, | ||
| }, | ||
| healthMetricsList: [ | ||
| { | ||
| contributorsCount: 50, | ||
| forksCount: 60, | ||
| openIssuesCount: 59, | ||
| openPullRequestsCount: 51, | ||
| recentReleasesCount: 75, | ||
| starsCount: 77, | ||
| totalIssuesCount: 78, | ||
| totalReleasesCount: 79, | ||
| unassignedIssuesCount: 85, | ||
| unansweredIssuesCount: 86, | ||
| }, | ||
| ], | ||
| }, | ||
| } |
93 changes: 93 additions & 0 deletions
93
frontend/__tests__/unit/pages/ProjectHealthDashboardMetricsDetails.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| import { useQuery } from '@apollo/client' | ||
| import { render, screen, waitFor } from '@testing-library/react' | ||
| import { mockProjectsDashboardMetricsDetailsData } from '@unit/data/mockProjectsDashboardMetricsDetailsData' | ||
| import ProjectHealthMetricsDetails from 'app/projects/dashboard/metrics/[projectKey]/page' | ||
|
|
||
| jest.mock('react-apexcharts', () => { | ||
| return { | ||
| __esModule: true, | ||
| default: () => { | ||
| return <div data-testid="mock-apexcharts">Mock ApexChart</div> | ||
| }, | ||
| } | ||
| }) | ||
| jest.mock('@apollo/client', () => ({ | ||
| ...jest.requireActual('@apollo/client'), | ||
| useQuery: jest.fn(), | ||
| })) | ||
| jest.mock('next/navigation', () => ({ | ||
| useParams: jest.fn(() => ({ | ||
| projectKey: 'test-project', | ||
| })), | ||
| })) | ||
|
|
||
| jest.mock('@fortawesome/react-fontawesome', () => ({ | ||
| FontAwesomeIcon: () => <span data-testid="mock-icon"></span>, | ||
| })) | ||
|
|
||
| const mockError = { | ||
| error: new Error('GraphQL error'), | ||
| } | ||
|
|
||
| describe('ProjectHealthMetricsDetails', () => { | ||
| beforeEach(() => { | ||
| ;(useQuery as jest.Mock).mockReturnValue({ | ||
| data: mockProjectsDashboardMetricsDetailsData, | ||
| loading: false, | ||
| error: null, | ||
| }) | ||
| }) | ||
|
|
||
| afterEach(() => { | ||
| jest.clearAllMocks() | ||
| }) | ||
|
|
||
| test('renders loading state', async () => { | ||
| ;(useQuery as jest.Mock).mockReturnValue({ | ||
| data: null, | ||
| loading: true, | ||
| error: null, | ||
| }) | ||
| render(<ProjectHealthMetricsDetails />) | ||
| const loadingSpinner = screen.getAllByAltText('Loading indicator') | ||
| await waitFor(() => { | ||
| expect(loadingSpinner.length).toBeGreaterThan(0) | ||
| }) | ||
| }) | ||
|
|
||
| test('renders error state', async () => { | ||
| ;(useQuery as jest.Mock).mockReturnValue({ | ||
| data: null, | ||
| loading: false, | ||
| error: mockError, | ||
| }) | ||
| render(<ProjectHealthMetricsDetails />) | ||
| const errorMessage = screen.getByText('No metrics data available for this project.') | ||
| await waitFor(() => { | ||
| expect(errorMessage).toBeInTheDocument() | ||
| }) | ||
| }) | ||
|
|
||
| test('renders project health metrics details', async () => { | ||
| const headers = [ | ||
| 'Days Metrics', | ||
| 'Issues', | ||
| 'Stars', | ||
| 'Forks', | ||
| 'Contributors', | ||
| 'Releases', | ||
| 'Open Pull Requests', | ||
| 'Health', | ||
| 'Score', | ||
| ] | ||
| const metrics = mockProjectsDashboardMetricsDetailsData.project.healthMetricsLatest | ||
| render(<ProjectHealthMetricsDetails />) | ||
| await waitFor(() => { | ||
| headers.forEach((header) => { | ||
| expect(screen.getByText(header)).toBeInTheDocument() | ||
| }) | ||
| expect(screen.getByText(metrics.projectName)).toBeInTheDocument() | ||
| expect(screen.getByText(metrics.score.toString())).toBeInTheDocument() | ||
| }) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Verify the expected return type for health_metrics_latest field.
The test uses
field.type.of_typewhich is typically used for list types, but the field namehealth_metrics_latestsuggests it should return a singleProjectHealthMetricsNodeobject, not a list.If
health_metrics_latestreturns a single object, the assertion should be:If it returns a list, then the current assertion is correct.
🏁 Script executed:
Length of output: 161
Incorrect assertion of health_metrics_latest return type
The health_metrics_latest field is defined to return a single ProjectHealthMetricsNode (or null), not a list. The test should assert the field’s type directly, not its element type.
File: backend/tests/apps/owasp/graphql/nodes/project_test.py (lines 47–50)
📝 Committable suggestion
🤖 Prompt for AI Agents