-
-
Notifications
You must be signed in to change notification settings - Fork 529
feat: implement community page #3873
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
5 commits
Select commit
Hold shift + click to select a range
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,79 @@ | ||
| export const mockCommunityData = { | ||
| data: { | ||
| recentChapters: [ | ||
| { | ||
| id: '1', | ||
| createdAt: '2025-03-18T01:03:09+00:00', | ||
| key: 'chapter_1', | ||
| leaders: ['Leader 1', 'Leader 3'], | ||
| name: 'Chapter 1', | ||
| suggestedLocation: 'Pune, Maharashtra, India', | ||
| }, | ||
| { | ||
| id: '2', | ||
| createdAt: '2025-03-13T00:01:01+00:00', | ||
| key: 'chapter_2', | ||
| leaders: ['Leader 1', 'Leader 2'], | ||
| name: 'Chapter 2', | ||
| suggestedLocation: 'Location 2', | ||
| }, | ||
| { | ||
| id: '3', | ||
| createdAt: '2025-02-25T02:04:57+00:00', | ||
| key: 'chapter_3', | ||
| leaders: ['Leader 1', 'Leader 2'], | ||
| name: 'Chapter 3', | ||
| suggestedLocation: 'Location 3', | ||
| }, | ||
| ], | ||
| recentOrganizations: [ | ||
| { | ||
| id: '1', | ||
| avatarUrl: 'https://avatars.githubusercontent.com/u/1?v=4', | ||
| login: 'org_1', | ||
| name: 'Organization 1', | ||
| }, | ||
| { | ||
| id: '2', | ||
| avatarUrl: 'https://avatars.githubusercontent.com/u/2?v=4', | ||
| login: 'org_2', | ||
| name: 'Organization 2', | ||
| }, | ||
| ], | ||
| snapshots: [ | ||
| { | ||
| id: '1', | ||
| key: 'snapshot_1', | ||
| title: 'Snapshot 1', | ||
| startAt: '2025-01-01', | ||
| endAt: '2025-01-31', | ||
| }, | ||
| { | ||
| id: '2', | ||
| key: 'snapshot_2', | ||
| title: 'Snapshot 2', | ||
| startAt: '2025-02-01', | ||
| endAt: '2025-02-28', | ||
| }, | ||
| ], | ||
| topContributors: [ | ||
| { | ||
| name: 'Contributor 1', | ||
| login: 'contributor_1', | ||
| avatarUrl: 'https://avatars.githubusercontent.com/u/3531020?v=4', | ||
| }, | ||
| { | ||
| name: 'Contributor 2', | ||
| login: 'contributor_2', | ||
| avatarUrl: 'https://avatars.githubusercontent.com/u/862914?v=4', | ||
| }, | ||
| ], | ||
| statsOverview: { | ||
| activeChaptersStats: 150, | ||
| activeProjectsStats: 50, | ||
| contributorsStats: 5000, | ||
| countriesStats: 100, | ||
| slackWorkspaceStats: 35000, | ||
| }, | ||
| }, | ||
| } |
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 }) => { | ||
| const navSection = page.locator('.grid.grid-cols-2').first() | ||
| await expect(navSection.getByRole('link', { name: 'Chapters' })).toBeVisible() | ||
| await expect(navSection.getByRole('link', { name: 'Members' })).toBeVisible() | ||
| await expect(navSection.getByRole('link', { name: 'Organizations' })).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,72 @@ | ||
| 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', | ||
| bio: 'Bio 1', | ||
| }, | ||
| { | ||
| id: 'user2', | ||
| avatarUrl: 'https://example.com/user2.png', | ||
| login: 'user2', | ||
| name: 'User 2', | ||
| bio: 'Bio 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.
Uh oh!
There was an error while loading. Please reload this page.