-
-
Notifications
You must be signed in to change notification settings - Fork 524
[Feature] : Community Overview page best for User experience #3919
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
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cf59175
community page feature
Isha-upadhyay de54be7
fix issue
Isha-upadhyay 75ea818
fixes
Isha-upadhyay 7dcbd00
coderabbit fixes
Isha-upadhyay 2fff6fb
fix
Isha-upadhyay 0640527
fix
Isha-upadhyay b4479f3
request change
Isha-upadhyay 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import { useQuery } from '@apollo/client/react' | ||
| import { mockCommunityGraphQLData } from '@mockData/mockCommunityData' | ||
| import { screen, waitFor } from '@testing-library/react' | ||
| import { axe } from 'jest-axe' | ||
| import { render } from 'wrappers/testUtil' | ||
| import CommunityPage from 'app/community/page' | ||
|
|
||
| jest.mock('@apollo/client/react', () => ({ | ||
| ...jest.requireActual('@apollo/client/react'), | ||
| useQuery: jest.fn(), | ||
| })) | ||
|
|
||
| jest.mock('@heroui/toast', () => ({ | ||
| addToast: jest.fn(), | ||
| })) | ||
|
|
||
| jest.mock('next/navigation', () => ({ | ||
| ...jest.requireActual('next/navigation'), | ||
| useRouter: jest.fn(() => ({ | ||
| push: jest.fn(), | ||
| })), | ||
| })) | ||
|
|
||
| describe('Community Page Accessibility', () => { | ||
| afterAll(() => { | ||
| jest.clearAllMocks() | ||
| }) | ||
|
|
||
| it('should have no accessibility violations', async () => { | ||
| ;(useQuery as unknown as jest.Mock).mockReturnValue({ | ||
| data: mockCommunityGraphQLData, | ||
| loading: false, | ||
| error: null, | ||
| }) | ||
|
|
||
| const { container } = render(<CommunityPage />) | ||
|
|
||
| await waitFor(() => { | ||
| expect(screen.getByText('OWASP Community')).toBeInTheDocument() | ||
| }) | ||
|
|
||
| const results = await axe(container) | ||
| expect(results).toHaveNoViolations() | ||
| }) | ||
| }) |
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,72 @@ | ||
| export const mockCommunityData = { | ||
| data: { | ||
| recentChapters: [ | ||
| { | ||
| id: '1', | ||
| createdAt: '2025-01-01T10:00:00Z', | ||
| key: 'chapter-1', | ||
| leaders: ['Leader 1', 'Leader 2'], | ||
| name: 'Chapter 1', | ||
| suggestedLocation: 'Pune, Maharashtra, India', | ||
| }, | ||
| { | ||
| id: '2', | ||
| createdAt: '2025-01-02T10:00:00Z', | ||
| key: 'chapter-2', | ||
| leaders: ['Leader 3'], | ||
| name: 'Chapter 2', | ||
| suggestedLocation: 'Location 2', | ||
| }, | ||
| ], | ||
| recentOrganizations: [ | ||
| { | ||
| id: 'org1', | ||
| avatarUrl: 'https://example.com/org1.png', | ||
| login: 'org1', | ||
| name: 'Organization 1', | ||
| }, | ||
| { | ||
| id: 'org2', | ||
| avatarUrl: 'https://example.com/org2.png', | ||
| login: 'org2', | ||
| name: 'Organization 2', | ||
| }, | ||
| ], | ||
| snapshots: [ | ||
| { | ||
| id: 'snap1', | ||
| key: 'snapshot-1', | ||
| title: 'Snapshot 1', | ||
| startAt: '2025-01-01', | ||
| endAt: '2025-01-31', | ||
| }, | ||
| { | ||
| id: 'snap2', | ||
| key: 'snapshot-2', | ||
| title: 'Snapshot 2', | ||
| startAt: '2025-02-01', | ||
| endAt: '2025-02-28', | ||
| }, | ||
| ], | ||
| topContributors: [ | ||
| { | ||
| id: 'user1', | ||
| avatarUrl: 'https://example.com/user1.png', | ||
| login: 'user1', | ||
| name: 'Contributor 1', | ||
| }, | ||
| { | ||
| id: 'user2', | ||
| avatarUrl: 'https://example.com/user2.png', | ||
| login: 'user2', | ||
| name: 'Contributor 2', | ||
| }, | ||
| ], | ||
| statsOverview: { | ||
| activeChaptersStats: 150, | ||
| activeProjectsStats: 50, | ||
| countriesStats: 100, | ||
| contributorsStats: 5000, | ||
| }, | ||
| }, | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| import { mockCommunityData } from '@e2e/data/mockCommunityData' | ||
| import { mockHomeData } from '@e2e/data/mockHomeData' | ||
| import { test, expect } from '@playwright/test' | ||
|
|
||
| test.describe('Community Page', () => { | ||
| test.beforeEach(async ({ page }) => { | ||
| await page.route('**/graphql/', async (route) => { | ||
| const combinedData = { | ||
| data: { | ||
| ...mockHomeData.data, | ||
| ...mockCommunityData.data, | ||
| }, | ||
| } | ||
| await route.fulfill({ | ||
| status: 200, | ||
| json: combinedData, | ||
| }) | ||
| }) | ||
| await page.context().addCookies([ | ||
| { | ||
| name: 'csrftoken', | ||
| value: 'abc123', | ||
| domain: 'localhost', | ||
| path: '/', | ||
| }, | ||
| ]) | ||
| await page.goto('/community') | ||
| }) | ||
|
|
||
| test('should have a heading and intro text', async ({ page }) => { | ||
| await expect(page.getByRole('heading', { name: 'OWASP Community' })).toBeVisible() | ||
| await expect( | ||
| page.getByText( | ||
| "Connect, collaborate, and contribute to the world's largest application security community." | ||
| ) | ||
| ).toBeVisible() | ||
| await expect(page.getByPlaceholder('Search the OWASP community')).toBeVisible() | ||
| }) | ||
|
|
||
| test('should have navigation cards', async ({ page }) => { | ||
| await expect(page.getByRole('link', { name: /Chapters/ })).toBeVisible() | ||
| await expect(page.getByRole('link', { name: /Members/ })).toBeVisible() | ||
| await expect(page.getByRole('link', { name: /Organizations/ })).toBeVisible() | ||
| await expect(page.getByRole('link', { name: /Snapshots/ })).toBeVisible() | ||
| }) | ||
|
|
||
| test('should have new chapters', async ({ page }) => { | ||
| await expect(page.getByText('New Chapters', { exact: true })).toBeVisible() | ||
| await expect(page.getByText('Chapter 1')).toBeVisible() | ||
| await expect(page.getByText('Pune, Maharashtra, India')).toBeVisible() | ||
| }) | ||
|
|
||
| test('should have new organizations', async ({ page }) => { | ||
| await expect(page.getByText('New Organizations', { exact: true })).toBeVisible() | ||
| await expect(page.getByText('Organization 1')).toBeVisible() | ||
| }) | ||
|
|
||
| test('should have snapshots', async ({ page }) => { | ||
| await expect(page.getByText('Snapshot 1')).toBeVisible() | ||
| await expect(page.getByText('Jan 1, 2025 - Jan 31, 2025')).toBeVisible() | ||
| }) | ||
|
|
||
| test('should have top contributors', async ({ page }) => { | ||
| await expect(page.getByText('Top Contributors', { exact: true })).toBeVisible() | ||
| await expect(page.getByText('Contributor 1')).toBeVisible() | ||
| }) | ||
|
|
||
| test('should have stats', async ({ page }) => { | ||
| await expect(page.getByText('Active Chapters')).toBeVisible() | ||
| await expect(page.getByText('150+', { exact: true })).toBeVisible() | ||
| await expect(page.getByText('Active Projects')).toBeVisible() | ||
| await expect(page.getByText('50+', { exact: true })).toBeVisible() | ||
| await expect(page.getByText(/5k\+/i)).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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| export const mockCommunityGraphQLData = { | ||
| recentChapters: [ | ||
| { | ||
| id: '1', | ||
| createdAt: '2025-01-01T10:00:00Z', | ||
| key: 'chapter-1', | ||
| leaders: ['Leader 1', 'Leader 2'], | ||
| name: 'OWASP Chapter 1', | ||
| suggestedLocation: 'Location 1', | ||
| }, | ||
| { | ||
| id: '2', | ||
| createdAt: '2025-01-02T10:00:00Z', | ||
| key: 'chapter-2', | ||
| leaders: ['Leader 3'], | ||
| name: 'OWASP Chapter 2', | ||
| suggestedLocation: 'Location 2', | ||
| }, | ||
| ], | ||
| recentOrganizations: [ | ||
| { | ||
| id: 'org1', | ||
| avatarUrl: 'https://example.com/org1.png', | ||
| login: 'org1', | ||
| name: 'Organization 1', | ||
| }, | ||
| { | ||
| id: 'org2', | ||
| avatarUrl: 'https://example.com/org2.png', | ||
| login: 'org2', | ||
| name: 'Organization 2', | ||
| }, | ||
| ], | ||
| snapshots: [ | ||
| { | ||
| id: 'snap1', | ||
| key: 'snapshot-1', | ||
| title: 'Snapshot 1', | ||
| startAt: '2025-01-01', | ||
| endAt: '2025-01-31', | ||
| }, | ||
| { | ||
| id: 'snap2', | ||
| key: 'snapshot-2', | ||
| title: 'Snapshot 2', | ||
| startAt: '2025-02-01', | ||
| endAt: '2025-02-28', | ||
| }, | ||
| ], | ||
| topContributors: [ | ||
| { | ||
| id: 'user1', | ||
| avatarUrl: 'https://example.com/user1.png', | ||
| login: 'user1', | ||
| name: 'User 1', | ||
| }, | ||
| { | ||
| id: 'user2', | ||
| avatarUrl: 'https://example.com/user2.png', | ||
| login: 'user2', | ||
| name: 'User 2', | ||
| }, | ||
| ], | ||
| statsOverview: { | ||
| activeChaptersStats: 150, | ||
| activeProjectsStats: 50, | ||
| countriesStats: 100, | ||
| contributorsStats: 5000, | ||
| }, | ||
| } | ||
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.
P2: Mock
recentChapters[].createdAtis an ISO date string, but the GraphQL schema andChapterCardcomponent expect anumber(Unix timestamp). The mock should use a numeric timestamp to match the actual response shape. Consider also adding a type annotation (e.g.,GetCommunityPageDataQuery) to prevent future mismatches.Prompt for AI agents