Skip to content
Merged
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
1 change: 1 addition & 0 deletions cspell/custom-dict.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ pygoat
pymdownx
pypoetry
pyyaml
quasis
relativedelta
repositorycontributor
requirepass
Expand Down
12 changes: 10 additions & 2 deletions frontend/__tests__/a11y/components/Card.a11y.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jest.mock('next/link', () => {
})

const baseProps = {
cardKey: 'test-card-1',
title: 'Test Project',
url: 'https://github.com/test/project',
summary: 'This is a test project summary',
Expand All @@ -52,7 +53,11 @@ describe('Card Accessibility', () => {

it('should not have any accessibility violations when level is provided', async () => {
const { container } = render(
<Card {...baseProps} level={{ level: 'Expert', color: '#9C27B0', icon: FaCrown }} />
<Card
{...baseProps}
cardKey="test-card-2"
level={{ level: 'Expert', color: '#9C27B0', icon: FaCrown }}
/>
)

const results = await axe(container)
Expand All @@ -61,7 +66,9 @@ describe('Card Accessibility', () => {
})

it('should not have any accessibility violations when project name is provided', async () => {
const { container } = render(<Card {...baseProps} projectName="Test Organization" />)
const { container } = render(
<Card {...baseProps} cardKey="test-card-3" projectName="Test Organization" />
)

const results = await axe(container)

Expand All @@ -72,6 +79,7 @@ describe('Card Accessibility', () => {
const { container } = render(
<Card
{...baseProps}
cardKey="test-card-4"
social={[{ title: 'GitHub', url: 'https://github.com/test', icon: FaCrown }]}
/>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ describe('CardDetailsPage a11y', () => {
endedAt: '2025-03-01',
mentors: [
{
id: 'mentor-mentor1',
login: 'mentor1',
avatarUrl: 'https://avatars.githubusercontent.com/u/12345',
name: 'Mentor One',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jest.mock('next/link', () => {
})

const mockGitHubContributor: Contributor = {
id: 'contributor-jane-doe',
login: 'jane-doe',
name: 'Jane Doe',
avatarUrl: 'https://avatars.githubusercontent.com/u/12345',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,21 @@ jest.mock('next/link', () => {

const mockSponsors: Sponsor[] = [
{
id: 'sponsor-1-a11y',
name: 'Test Sponsor 1',
imageUrl: 'https://example.com/logo1.png',
url: 'https://sponsor1.com',
sponsorType: 'Gold',
},
{
id: 'sponsor-2-a11y',
name: 'Test Sponsor 2',
imageUrl: 'https://example.com/logo2.png',
url: 'https://sponsor2.com',
sponsorType: 'Silver',
},
{
id: 'sponsor-3-a11y',
name: 'Test Sponsor 3',
imageUrl: '',
url: 'https://sponsor3.com',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ const mockModule: Module = {
experienceLevel: ExperienceLevelEnum.Intermediate,
mentors: [
{
id: 'mentor-user1-a11y',
name: 'user1',
login: 'user1',
avatarUrl: 'https://example.com/avatar1.jpg',
},
{
id: 'mentor-user2-a11y',
name: 'user2',
login: 'user2',
avatarUrl: 'https://example.com/avatar2.jpg',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,23 @@ jest.mock('next/link', () => {

const mockContributors: Contributor[] = [
{
id: 'contributor-developer1-a11y',
avatarUrl: 'https://github.com/developer1.avatar',
login: 'developer1',
name: 'Alex Developer',
projectKey: 'project1',
contributionsCount: 50,
},
{
id: 'contributor-contributor2-a11y',
avatarUrl: 'https://github.com/contributor2.avatar',
login: 'contributor2',
name: 'Jane Developer',
projectKey: 'project1',
contributionsCount: 30,
},
{
id: 'contributor-user3-a11y',
avatarUrl: 'https://github.com/user3.avatar',
login: 'user3',
name: '',
Expand Down
1 change: 1 addition & 0 deletions frontend/__tests__/mockData/mockChapterData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const mockChapterData = {
],
topContributors: [
{
id: 'contributor-isanori-sakanashi',
avatarUrl: 'https://avatars.githubusercontent.com/u/58754211?v=4',
login: 'Isanori-Sakanashi',
name: 'Isanori Sakanashi',
Expand Down
19 changes: 16 additions & 3 deletions frontend/__tests__/unit/components/Card.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ interface MockMarkdownProps {
}

interface MockLabelListProps {
entityKey?: string
labels: string[]
maxVisible?: number
className?: string
Expand Down Expand Up @@ -185,14 +186,19 @@ jest.mock('components/MarkdownWrapper', () => {

jest.mock('components/LabelList', () => {
return {
LabelList: ({ labels, maxVisible = 5, className }: MockLabelListProps) => {
LabelList: ({
labels,
entityKey: _entityKey,
maxVisible = 5,
className,
}: MockLabelListProps) => {
if (!labels || labels.length === 0) return null
const visibleLabels = labels.slice(0, maxVisible)
const remainingCount = labels.length - maxVisible
return (
<div data-testid="label-list" className={className}>
{visibleLabels.map((label, index) => (
<span key={`${label}-${index}`} data-testid="label">
{visibleLabels.map((label) => (
<span key={`${_entityKey}-${label}`} data-testid="label">
{label}
</span>
))}
Expand Down Expand Up @@ -237,6 +243,7 @@ jest.mock('utils/data', () => ({

describe('Card', () => {
const baseProps: CardProps = {
cardKey: 'test-project',
title: 'Test Project',
url: 'https://github.com/test/project',
summary: 'This is a test project summary',
Expand Down Expand Up @@ -369,12 +376,14 @@ describe('Card', () => {
...baseProps,
topContributors: [
{
id: 'contributor-user1',
login: 'user1',
name: 'User One',
avatarUrl: 'https://github.com/user1.png',
projectKey: 'project1',
},
{
id: 'contributor-user2',
login: 'user2',
name: 'User Two',
avatarUrl: 'https://github.com/user2.png',
Expand Down Expand Up @@ -415,12 +424,14 @@ describe('Card', () => {
...baseProps,
topContributors: [
{
id: 'contributor-anonymous',
login: '',
name: 'Anonymous',
avatarUrl: 'https://github.com/user1.png',
projectKey: 'project-key-1',
},
{
id: 'contributor-user2-partial',
login: 'user2',
name: 'User Two',
avatarUrl: 'https://github.com/user2.png',
Expand All @@ -447,6 +458,7 @@ describe('Card', () => {
...baseProps,
topContributors: [
{
id: 'contributor-singleuser',
login: 'singleuser',
name: 'Single User',
avatarUrl: 'https://github.com/single.png',
Expand Down Expand Up @@ -567,6 +579,7 @@ describe('Card', () => {
social: [{ title: 'GitHub', url: 'https://github.com/full', icon: MockIcon as IconType }],
topContributors: [
{
id: 'contributor-expert',
login: 'expert',
avatarUrl: 'https://github.com/expert.png',
name: 'John Doe',
Expand Down
16 changes: 15 additions & 1 deletion frontend/__tests__/unit/components/CardDetailsPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,15 @@ jest.mock('components/InfoBlock', () => ({

jest.mock('components/LeadersList', () => ({
__esModule: true,
default: ({ leaders, ...props }: { leaders: string; [key: string]: unknown }) => (
default: ({
leaders,
entityKey: _entityKey,
...props
}: {
leaders: string
entityKey: string
[key: string]: unknown
}) => (
<span data-testid="leaders-list" {...props}>
{leaders}
</span>
Expand Down Expand Up @@ -336,11 +344,13 @@ jest.mock('components/ToggleableList', () => ({
items,
icon: _icon,
label,
entityKey: _entityKey,
...props
}: {
items: string[]
_icon: unknown
label: React.ReactNode
entityKey: string
[key: string]: unknown
}) => (
<div data-testid="toggleable-list" {...props}>
Expand Down Expand Up @@ -454,13 +464,15 @@ describe('CardDetailsPage', () => {

const mockContributors = [
{
id: 'contributor-1',
avatarUrl: 'https://example.com/avatar1.jpg',
login: 'john_doe',
name: 'John Doe',
projectKey: 'test-project',
contributionsCount: 50,
},
{
id: 'contributor-2',
avatarUrl: 'https://example.com/avatar2.jpg',
login: 'jane_smith',
name: 'Jane Smith',
Expand Down Expand Up @@ -552,6 +564,7 @@ describe('CardDetailsPage', () => {

const mockRecentReleases = [
{
id: 'release-1',
author: mockUser,
isPreRelease: false,
name: 'v1.0.0',
Expand Down Expand Up @@ -1669,6 +1682,7 @@ describe('CardDetailsPage', () => {
contributionStats,
topContributors: [
{
id: 'contributor-user1',
login: 'user1',
name: 'User One',
avatarUrl: 'https://example.com/avatar1.png',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jest.mock('next/image', () => {
})

const mockAlgoliaContributor: Contributor = {
id: 'contributor-johndoe',
login: 'johndoe',
name: 'John Doe',
avatarUrl: 'https://github.com/johndoe.png',
Expand All @@ -72,6 +73,7 @@ const mockAlgoliaContributor: Contributor = {
}

const mockGitHubContributor: Contributor = {
id: 'contributor-jane-doe',
login: 'jane-doe',
name: 'Jane Doe',
avatarUrl: 'https://avatars.githubusercontent.com/u/12345',
Expand Down Expand Up @@ -130,6 +132,7 @@ describe('ContributorAvatar', () => {

it('shows only name when no contributions count', () => {
const contributorWithoutContributions = {
id: 'contributor-newbie',
login: 'newbie',
name: 'New Contributor',
avatarUrl: 'https://github.com/newbie.png',
Expand All @@ -147,6 +150,7 @@ describe('ContributorAvatar', () => {

it('handles contributor with zero contributions', () => {
const contributorWithZeroContributions: Contributor = {
id: 'contributor-newcomer',
login: 'newcomer',
name: 'Brand New User',
avatarUrl: 'https://github.com/newcomer.png',
Expand All @@ -165,6 +169,7 @@ describe('ContributorAvatar', () => {

it('handles empty string values gracefully', () => {
const contributorWithEmptyStrings: Contributor = {
id: 'contributor-empty-strings',
login: '',
name: '',
avatarUrl: 'https://github.com/default.png',
Expand All @@ -182,6 +187,7 @@ describe('ContributorAvatar', () => {

it('handles very long names and contributions', () => {
const contributorWithLongData: Contributor = {
id: 'contributor-long-data',
login: 'very-long-username-that-might-break-layouts',
name: 'Someone With A Really Really Long Name That Might Cause Issues',
avatarUrl: 'https://github.com/very-long-username-that-might-break-layouts.png',
Expand Down
1 change: 1 addition & 0 deletions frontend/__tests__/unit/components/ItemCardList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ const mockPullRequest: PullRequest = {
}

const mockRelease: Release = {
id: 'release-item-card',
author: {
...mockUser,
login: 'author4',
Expand Down
Loading
Loading