-
-
Notifications
You must be signed in to change notification settings - Fork 270
feat: Add archived badge for repositories (#2388) #2412
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
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
9d12e17
Add 'is_archived' field to RepositoryNode GraphQL type
mrkeshav-05 a563121
Add 'isArchived' field to GET_REPOSITORY_DATA query
mrkeshav-05 14186d9
Add 'isArchived' field to GET_ORGANIZATION_DATA query
mrkeshav-05 47ba07c
Add 'isArchived' field to GET_PROJECT_DATA query
mrkeshav-05 49cf7c0
Add 'isArchived' field to topContributedRepositories in GET_USER_DATA…
mrkeshav-05 d33519c
Add ArchivedBadge component to display archived status
mrkeshav-05 9ba83a9
Add ArchivedBadge to DetailsCard and RepositoriesCard for archived st…
mrkeshav-05 be4ea48
Add isArchived field to DetailsCardProps and RepositoryCardProps for …
mrkeshav-05 45bd3bb
feat: Add isArchived field to RepositoryNode and UserNode types in ge…
mrkeshav-05 2003add
feat: Pass isArchived prop to DetailsCard for repository archived status
mrkeshav-05 8661db5
fix: Remove extra whitespace in className for ArchivedBadge component
mrkeshav-05 afd27d4
fix: Remove extra whitespace and add aria-label for accessibility in …
mrkeshav-05 6bc4ab2
test: Add tests for is_archived field in RepositoryNode
mrkeshav-05 81503cf
test: Add tests for archived badge functionality in ArchiveBadge, Car…
mrkeshav-05 26dd61d
test: Refactor archived badge tests for consistency and clarity in Re…
mrkeshav-05 6d4237a
feat: ellipsis design for long repository names and add archived badge
mrkeshav-05 a455b7b
Apply suggestion from @coderabbitai[bot]
mrkeshav-05 cb09235
Apply suggestion from @coderabbitai[bot]
mrkeshav-05 6152c96
Apply suggestion from @coderabbitai[bot]
mrkeshav-05 13fbbf9
style: swap Inactive and MetricsScoreCircle; match Archived badge
mrkeshav-05 1119cba
style: remove unnecessary newline in test_is_archived_field_exists
mrkeshav-05 9783fae
fix: update GetLeaderDataDocument to include missing fields
mrkeshav-05 99e0b1d
test: add some changes in the files
mrkeshav-05 a7719eb
test: remove snapshot tests for ArchivedBadge component
mrkeshav-05 95a7c70
fix: remove company and location fields from GetLeaderDataQuery
mrkeshav-05 f0c2b8d
Merge branch 'main' into feature/archived-badge
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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ | |
| "created_at", | ||
| "description", | ||
| "forks_count", | ||
| "is_archived", | ||
| "key", | ||
| "license", | ||
| "name", | ||
|
|
||
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
205 changes: 205 additions & 0 deletions
205
frontend/__tests__/unit/components/ArchivedBadge.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,205 @@ | ||
| import { render, screen } from '@testing-library/react' | ||
| import ArchivedBadge from 'components/ArchivedBadge' | ||
|
|
||
| jest.mock('@fortawesome/react-fontawesome', () => ({ | ||
| FontAwesomeIcon: ({ className }: { className: string }) => ( | ||
| <i data-testid="archive-icon" className={className} /> | ||
| ), | ||
| })) | ||
|
|
||
| describe('ArchivedBadge', () => { | ||
| describe('Basic Rendering', () => { | ||
| it('renders successfully with default props', () => { | ||
| render(<ArchivedBadge />) | ||
|
|
||
| expect(screen.getByText('Archived')).toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('displays the archived text', () => { | ||
| render(<ArchivedBadge />) | ||
|
|
||
| const badge = screen.getByText('Archived') | ||
| expect(badge).toBeVisible() | ||
| }) | ||
|
|
||
| it('has the correct tooltip', () => { | ||
| render(<ArchivedBadge />) | ||
|
|
||
| const badge = screen.getByText('Archived') | ||
| expect(badge).toHaveAttribute('title', 'This repository has been archived and is read-only') | ||
| }) | ||
| }) | ||
|
|
||
| describe('Size Variants', () => { | ||
| it('renders with small size', () => { | ||
| render(<ArchivedBadge size="sm" />) | ||
|
|
||
| const badge = screen.getByText('Archived') | ||
| expect(badge).toHaveClass('px-2', 'py-1', 'text-xs') | ||
| }) | ||
|
|
||
| it('renders with medium size (default)', () => { | ||
| render(<ArchivedBadge size="md" />) | ||
|
|
||
| const badge = screen.getByText('Archived') | ||
| expect(badge).toHaveClass('px-3', 'py-1', 'text-sm') | ||
| }) | ||
|
|
||
| it('renders with large size', () => { | ||
| render(<ArchivedBadge size="lg" />) | ||
|
|
||
| const badge = screen.getByText('Archived') | ||
| expect(badge).toHaveClass('px-4', 'py-2', 'text-base') | ||
| }) | ||
|
|
||
| it('defaults to medium size when size prop is not provided', () => { | ||
| render(<ArchivedBadge />) | ||
|
|
||
| const badge = screen.getByText('Archived') | ||
| expect(badge).toHaveClass('px-3', 'py-1', 'text-sm') | ||
| }) | ||
| }) | ||
|
|
||
| describe('Icon Display', () => { | ||
| it('shows icon by default', () => { | ||
| render(<ArchivedBadge />) | ||
|
|
||
| const icon = screen.getByTestId('archive-icon') | ||
| expect(icon).toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('shows icon when showIcon is true', () => { | ||
| render(<ArchivedBadge showIcon={true} />) | ||
|
|
||
| const icon = screen.getByTestId('archive-icon') | ||
| expect(icon).toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('hides icon when showIcon is false', () => { | ||
| render(<ArchivedBadge showIcon={false} />) | ||
|
|
||
| const icon = screen.queryByTestId('archive-icon') | ||
| expect(icon).not.toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('applies correct icon class', () => { | ||
| render(<ArchivedBadge />) | ||
|
|
||
| const icon = screen.getByTestId('archive-icon') | ||
| expect(icon).toHaveClass('h-3', 'w-3') | ||
| }) | ||
| }) | ||
|
|
||
| describe('Styling', () => { | ||
| it('has correct base styling classes', () => { | ||
| render(<ArchivedBadge />) | ||
|
|
||
| const badge = screen.getByText('Archived') | ||
| expect(badge).toHaveClass('inline-flex', 'items-center', 'gap-1.5', 'rounded-full', 'border') | ||
| }) | ||
|
|
||
| it('has correct light mode color classes', () => { | ||
| render(<ArchivedBadge />) | ||
|
|
||
| const badge = screen.getByText('Archived') | ||
| expect(badge).toHaveClass('border-yellow-600', 'bg-yellow-50', 'text-yellow-800') | ||
| }) | ||
|
|
||
| it('has correct dark mode color classes', () => { | ||
| render(<ArchivedBadge />) | ||
|
|
||
| const badge = screen.getByText('Archived') | ||
| expect(badge).toHaveClass( | ||
| 'dark:border-yellow-500', | ||
| 'dark:bg-yellow-900/30', | ||
| 'dark:text-yellow-400' | ||
| ) | ||
| }) | ||
|
|
||
| it('has font-medium class', () => { | ||
| render(<ArchivedBadge />) | ||
|
|
||
| const badge = screen.getByText('Archived') | ||
| expect(badge).toHaveClass('font-medium') | ||
| }) | ||
| }) | ||
|
|
||
| describe('Custom ClassName', () => { | ||
| it('applies custom className', () => { | ||
| render(<ArchivedBadge className="custom-class" />) | ||
|
|
||
| const badge = screen.getByText('Archived') | ||
| expect(badge).toHaveClass('custom-class') | ||
| }) | ||
|
|
||
| it('preserves default classes with custom className', () => { | ||
| render(<ArchivedBadge className="ml-2" />) | ||
|
|
||
| const badge = screen.getByText('Archived') | ||
| expect(badge).toHaveClass('ml-2', 'inline-flex', 'rounded-full') | ||
| }) | ||
|
|
||
| it('handles empty custom className', () => { | ||
| render(<ArchivedBadge className="" />) | ||
|
|
||
| const badge = screen.getByText('Archived') | ||
| expect(badge).toBeInTheDocument() | ||
| }) | ||
| }) | ||
|
|
||
| describe('Accessibility', () => { | ||
| it('renders as a span element', () => { | ||
| render(<ArchivedBadge />) | ||
|
|
||
| const badge = screen.getByText('Archived') | ||
| expect(badge.tagName).toBe('SPAN') | ||
| }) | ||
|
|
||
| it('has descriptive tooltip for screen readers', () => { | ||
| render(<ArchivedBadge />) | ||
|
|
||
| const badge = screen.getByText('Archived') | ||
| const title = badge.getAttribute('title') | ||
| expect(title).toBeTruthy() | ||
| expect(title).toContain('archived') | ||
| expect(title).toContain('read-only') | ||
| }) | ||
|
|
||
| it('has appropriate semantic structure with icon', () => { | ||
| render(<ArchivedBadge />) | ||
|
|
||
| const badge = screen.getByText('Archived') | ||
| expect(badge).toContainHTML('i') | ||
| }) | ||
mrkeshav-05 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }) | ||
|
|
||
| describe('Edge Cases', () => { | ||
| it('handles all props together', () => { | ||
| render(<ArchivedBadge size="lg" showIcon={false} className="extra-margin" />) | ||
|
|
||
| const badge = screen.getByText('Archived') | ||
| expect(badge).toBeInTheDocument() | ||
| expect(badge).toHaveClass('px-4', 'py-2', 'text-base', 'extra-margin') | ||
| expect(screen.queryByTestId('archive-icon')).not.toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('renders consistently across multiple instances', () => { | ||
| const { rerender } = render(<ArchivedBadge />) | ||
|
|
||
| const firstRender = screen.getByText('Archived').className | ||
|
|
||
| rerender(<ArchivedBadge />) | ||
|
|
||
| const secondRender = screen.getByText('Archived').className | ||
| expect(firstRender).toBe(secondRender) | ||
| }) | ||
|
|
||
| it('does not render any interactive elements', () => { | ||
| const { container } = render(<ArchivedBadge />) | ||
|
|
||
| expect(container.querySelector('button')).not.toBeInTheDocument() | ||
| expect(container.querySelector('a')).not.toBeInTheDocument() | ||
| expect(container.querySelector('input')).not.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.
Uh oh!
There was an error while loading. Please reload this page.