From ce4863207ed279f4dc4d49fe0ba36c424f9d5fdb Mon Sep 17 00:00:00 2001 From: Piyushrathoree Date: Sat, 2 Aug 2025 09:23:48 +0530 Subject: [PATCH 1/9] Add test : RecentRelease component unit test --- .../unit/components/RecentRelease.test.tsx | 388 ++++++++++++++++++ 1 file changed, 388 insertions(+) create mode 100644 frontend/__tests__/unit/components/RecentRelease.test.tsx diff --git a/frontend/__tests__/unit/components/RecentRelease.test.tsx b/frontend/__tests__/unit/components/RecentRelease.test.tsx new file mode 100644 index 0000000000..ee596abcf3 --- /dev/null +++ b/frontend/__tests__/unit/components/RecentRelease.test.tsx @@ -0,0 +1,388 @@ +import { render, screen, fireEvent, act } from '@testing-library/react' +import type { ReactElement, ReactNode } from 'react' +import type { Release } from 'types/release' +import RecentReleases from 'components/RecentReleases' + +// Define proper types for mock components +interface MockComponentProps { + children?: ReactNode + [key: string]: unknown +} + +interface MockImageProps { + alt?: string + src?: string + [key: string]: unknown +} + +// Mock framer-motion to prevent LazyMotion issues +jest.mock('framer-motion', () => ({ + motion: { + div: ({ children, ...props }: MockComponentProps): ReactElement => ( +
{children}
+ ), + span: ({ children, ...props }: MockComponentProps): ReactElement => ( + {children} + ), + }, + AnimatePresence: ({ children }: { children: ReactNode }): ReactNode => children, + useAnimation: () => ({ + start: jest.fn(), + set: jest.fn(), + }), + LazyMotion: ({ children }: { children: ReactNode }): ReactNode => children, + domAnimation: jest.fn(), +})) + +// Mock HeroUI components +jest.mock('@heroui/tooltip', () => ({ + Tooltip: ({ + children, + closeDelay: _closeDelay, + delay: _delay, + placement: _placement, + showArrow: _showArrow, + id: _id, + content: _content, + ...props + }: MockComponentProps): ReactElement =>
{children}
, +})) + +const mockRouterPush = jest.fn() + +jest.mock('next/navigation', () => ({ + useRouter: () => ({ + push: mockRouterPush, + }), +})) + +jest.mock('next/image', () => ({ + __esModule: true, + default: (props: MockImageProps): ReactElement => { + // eslint-disable-next-line @next/next/no-img-element + return {props.alt + }, +})) + +const mockReleases: Release[] = [ + { + name: 'v1.0 The First Release', + url: 'https://example.com/release/v1', + publishedAt: 1733040000000, // 2025-07-31T10:00:00Z as timestamp + repositoryName: 'our-awesome-project', + organizationName: 'our-org', + tagName: 'v1.0', + isPreRelease: false, + author: { + login: 'testuser', + name: 'Test User', + avatarUrl: 'https://example.com/avatar.png', + key: 'testuser', + contributionsCount: 0, + createdAt: 0, + followersCount: 0, + followingCount: 0, + publicRepositoriesCount: 0, + url: 'https://example.com/user/testuser', + }, + }, + { + name: 'v2.0 The Second Release', + url: 'https://example.com/release/v2', + publishedAt: 1732953600000, // 2025-07-30T12:00:00Z as timestamp + repositoryName: 'another-cool-project', + organizationName: 'our-org', + tagName: 'v2.0', + isPreRelease: false, + author: { + login: 'jane-doe', + name: 'Jane Doe', + avatarUrl: 'https://example.com/avatar2.png', + key: 'jane-doe', + contributionsCount: 0, + createdAt: 0, + followersCount: 0, + followingCount: 0, + publicRepositoriesCount: 0, + url: 'https://example.com/user/jane-doe', + }, + }, +] + +describe('RecentReleases Component', () => { + beforeEach(() => { + mockRouterPush.mockClear() + }) + + it('should display a message when there is no data', () => { + act(() => { + render() + }) + expect(screen.getByText('No recent releases.')).toBeInTheDocument() + }) + + it('should render release details and links correctly with data', () => { + act(() => { + render() + }) + + const releaseLink = screen.getByRole('link', { name: /v1.0 The First Release/i }) + const repoNameElement = screen.getByText(/another-cool-project/i) + const authorLink = screen.getByRole('link', { name: /Test User/i }) + + expect(releaseLink).toBeInTheDocument() + expect(repoNameElement).toBeInTheDocument() + expect(authorLink).toBeInTheDocument() + + expect(releaseLink).toHaveAttribute('href', 'https://example.com/release/v1') + expect(releaseLink).toHaveAttribute('target', '_blank') + expect(authorLink).toHaveAttribute('href', '/members/testuser') + }) + + it('should navigate when the repository name is clicked', () => { + act(() => { + render() + }) + + const repoNameElement = screen.getByText(/our-awesome-project/i) + act(() => { + fireEvent.click(repoNameElement) + }) + + expect(mockRouterPush).toHaveBeenCalledTimes(1) + expect(mockRouterPush).toHaveBeenCalledWith( + '/organizations/our-org/repositories/our-awesome-project' + ) + }) + + it('should not render avatars if showAvatar is false', () => { + act(() => { + render() + }) + expect(screen.queryByRole('link', { name: /Test User/i })).not.toBeInTheDocument() + expect(screen.queryByRole('link', { name: /Jane Doe/i })).not.toBeInTheDocument() + }) + + it('should apply single-column class when showSingleColumn is true', () => { + let container: HTMLElement + act(() => { + const result = render() + container = result.container + }) + const gridContainer = container.querySelector('.grid') + + expect(gridContainer).toHaveClass('grid-cols-1') + expect(gridContainer).not.toHaveClass('md:grid-cols-2') + }) + + it('should apply multi-column classes by default', () => { + let container: HTMLElement + act(() => { + const result = render() + container = result.container + }) + const gridContainer = container.querySelector('.grid') + + expect(gridContainer).not.toHaveClass('grid-cols-1') + expect(gridContainer).toHaveClass('md:grid-cols-2', 'lg:grid-cols-3') + }) + + // New test cases for comprehensive coverage + + it('should handle releases with missing author information', () => { + const releasesWithMissingAuthor = [ + { + ...mockReleases[0], + author: { + ...mockReleases[0].author, + name: undefined, + login: undefined, + }, + }, + ] + + act(() => { + render() + }) + + // Should still render the release name + expect(screen.getByText('v1.0 The First Release')).toBeInTheDocument() + // Should handle missing author gracefully + expect(screen.getByAltText('author')).toBeInTheDocument() + }) + + it('should handle releases with missing repository information', () => { + const releasesWithMissingRepo = [ + { + ...mockReleases[0], + repositoryName: undefined, + organizationName: undefined, + }, + ] + + act(() => { + render() + }) + + // Should still render the release name + expect(screen.getByText('v1.0 The First Release')).toBeInTheDocument() + // Should handle missing repo info gracefully - check for button element + const repoButton = screen.getByRole('button') + expect(repoButton).toBeInTheDocument() + }) + + it('should handle releases with missing URLs', () => { + const releasesWithMissingUrls = [ + { + ...mockReleases[0], + url: undefined, + }, + ] + + act(() => { + render() + }) + + const releaseLink = screen.getByRole('link', { name: /v1.0 The First Release/i }) + expect(releaseLink).toHaveAttribute('href', '/') + }) + + it('should render with default props when not provided', () => { + act(() => { + render() + }) + + // Should show avatars by default + expect(screen.getByRole('link', { name: /Test User/i })).toBeInTheDocument() + + // Should use multi-column layout by default + let container: HTMLElement + act(() => { + const result = render() + container = result.container + }) + const gridContainer = container.querySelector('.grid') + expect(gridContainer).toHaveClass('md:grid-cols-2', 'lg:grid-cols-3') + }) + + it('should handle null/undefined data gracefully', () => { + const { unmount } = render() + expect(screen.getByText('No recent releases.')).toBeInTheDocument() + unmount() + + render() + expect(screen.getByText('No recent releases.')).toBeInTheDocument() + }) + + it('should have proper accessibility attributes', () => { + act(() => { + render() + }) + + // Check for proper alt text on images + const authorImage = screen.getByAltText('Test User') + expect(authorImage).toBeInTheDocument() + + // Check for proper link roles + const releaseLink = screen.getByRole('link', { name: /v1.0 The First Release/i }) + expect(releaseLink).toBeInTheDocument() + + // Check for proper button roles + const repoButton = screen.getByText(/our-awesome-project/i) + expect(repoButton).toBeInTheDocument() + }) + + it('should handle multiple releases correctly', () => { + act(() => { + render() + }) + + // Should render both releases + expect(screen.getByText('v1.0 The First Release')).toBeInTheDocument() + expect(screen.getByText('v2.0 The Second Release')).toBeInTheDocument() + + // Should render both repository names + expect(screen.getByText('our-awesome-project')).toBeInTheDocument() + expect(screen.getByText('another-cool-project')).toBeInTheDocument() + }) + + it('should handle repository click with missing organization name', () => { + const releasesWithMissingOrg = [ + { + ...mockReleases[0], + organizationName: undefined, + }, + ] + + act(() => { + render() + }) + + const repoNameElement = screen.getByText(/our-awesome-project/i) + act(() => { + fireEvent.click(repoNameElement) + }) + + expect(mockRouterPush).toHaveBeenCalledWith( + '/organizations/undefined/repositories/our-awesome-project' + ) + }) + + it('should handle repository click with missing repository name', () => { + const releasesWithMissingRepoName = [ + { + ...mockReleases[0], + repositoryName: undefined, + }, + ] + + act(() => { + render() + }) + + const repoButton = screen.getByRole('button') + act(() => { + fireEvent.click(repoButton) + }) + + expect(mockRouterPush).toHaveBeenCalledWith('/organizations/our-org/repositories/') + }) + + it('should render with proper CSS classes for styling', () => { + let container: HTMLElement + act(() => { + const result = render() + container = result.container + }) + + // Check for main card structure - look for the card wrapper + const cardElement = container.querySelector( + '.mb-4.w-full.rounded-lg.bg-gray-200.p-4.dark\\:bg-gray-700' + ) + expect(cardElement).toBeInTheDocument() + + // Check for proper grid layout + const gridElement = container.querySelector('.grid') + expect(gridElement).toBeInTheDocument() + + // Check for proper text styling - look for the title + const titleElement = container.querySelector('.text-2xl.font-semibold') + expect(titleElement).toBeInTheDocument() + }) + + it('should handle releases with very long names gracefully', () => { + const releasesWithLongNames = [ + { + ...mockReleases[0], + name: 'This is a very long release name that should be truncated properly in the UI to prevent layout issues and maintain consistent styling across different screen sizes', + }, + ] + + act(() => { + render() + }) + + // Should still render the long name + expect(screen.getByText(/This is a very long release name/)).toBeInTheDocument() + }) +}) From 77f9b1cec21cd5145729ac8ec1b6c0f378395479 Mon Sep 17 00:00:00 2001 From: Piyushrathoree Date: Mon, 4 Aug 2025 02:31:08 +0530 Subject: [PATCH 2/9] fix:update recentRelease test for latest recentrelease component --- .../__tests__/unit/components/RecentRelease.test.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/frontend/__tests__/unit/components/RecentRelease.test.tsx b/frontend/__tests__/unit/components/RecentRelease.test.tsx index ee596abcf3..1601ffbad5 100644 --- a/frontend/__tests__/unit/components/RecentRelease.test.tsx +++ b/frontend/__tests__/unit/components/RecentRelease.test.tsx @@ -134,7 +134,10 @@ describe('RecentReleases Component', () => { expect(repoNameElement).toBeInTheDocument() expect(authorLink).toBeInTheDocument() - expect(releaseLink).toHaveAttribute('href', 'https://example.com/release/v1') + expect(releaseLink).toHaveAttribute( + 'href', + 'https://github.com/our-org/our-awesome-project/releases/tag/v1.0' + ) expect(releaseLink).toHaveAttribute('target', '_blank') expect(authorLink).toHaveAttribute('href', '/members/testuser') }) @@ -208,7 +211,7 @@ describe('RecentReleases Component', () => { // Should still render the release name expect(screen.getByText('v1.0 The First Release')).toBeInTheDocument() // Should handle missing author gracefully - expect(screen.getByAltText('author')).toBeInTheDocument() + expect(screen.queryByRole('img')).not.toBeInTheDocument() }) it('should handle releases with missing repository information', () => { @@ -244,7 +247,10 @@ describe('RecentReleases Component', () => { }) const releaseLink = screen.getByRole('link', { name: /v1.0 The First Release/i }) - expect(releaseLink).toHaveAttribute('href', '/') + expect(releaseLink).toHaveAttribute( + 'href', + 'https://github.com/our-org/our-awesome-project/releases/tag/v1.0' + ) }) it('should render with default props when not provided', () => { From 81222cc94212e21494eaf3d07e372461da12338e Mon Sep 17 00:00:00 2001 From: Piyushrathoree Date: Mon, 4 Aug 2025 03:48:55 +0530 Subject: [PATCH 3/9] updated the timestamp harcoding issue --- frontend/__tests__/unit/components/RecentRelease.test.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/__tests__/unit/components/RecentRelease.test.tsx b/frontend/__tests__/unit/components/RecentRelease.test.tsx index 1601ffbad5..bd516a5d14 100644 --- a/frontend/__tests__/unit/components/RecentRelease.test.tsx +++ b/frontend/__tests__/unit/components/RecentRelease.test.tsx @@ -64,11 +64,12 @@ jest.mock('next/image', () => ({ }, })) +const now = Date.now() const mockReleases: Release[] = [ { name: 'v1.0 The First Release', url: 'https://example.com/release/v1', - publishedAt: 1733040000000, // 2025-07-31T10:00:00Z as timestamp + publishedAt: now, repositoryName: 'our-awesome-project', organizationName: 'our-org', tagName: 'v1.0', @@ -89,7 +90,7 @@ const mockReleases: Release[] = [ { name: 'v2.0 The Second Release', url: 'https://example.com/release/v2', - publishedAt: 1732953600000, // 2025-07-30T12:00:00Z as timestamp + publishedAt: now, repositoryName: 'another-cool-project', organizationName: 'our-org', tagName: 'v2.0', From 5c72506723a0b565ad09e6f07529fa389d48894a Mon Sep 17 00:00:00 2001 From: PIYUSH RATHORE <163632958+Piyushrathoree@users.noreply.github.com> Date: Tue, 5 Aug 2025 00:40:26 +0530 Subject: [PATCH 4/9] Update RecentRelease.test.tsx --- .../__tests__/unit/components/RecentRelease.test.tsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/frontend/__tests__/unit/components/RecentRelease.test.tsx b/frontend/__tests__/unit/components/RecentRelease.test.tsx index bd516a5d14..b1d7e6dc17 100644 --- a/frontend/__tests__/unit/components/RecentRelease.test.tsx +++ b/frontend/__tests__/unit/components/RecentRelease.test.tsx @@ -255,19 +255,17 @@ describe('RecentReleases Component', () => { }) it('should render with default props when not provided', () => { + let container : HTMLElement act(() => { render() + const result = render() + container = result.container }) // Should show avatars by default expect(screen.getByRole('link', { name: /Test User/i })).toBeInTheDocument() - // Should use multi-column layout by default - let container: HTMLElement - act(() => { - const result = render() - container = result.container - }) + const gridContainer = container.querySelector('.grid') expect(gridContainer).toHaveClass('md:grid-cols-2', 'lg:grid-cols-3') }) From 138d447939f0ce7bf35b27eb2ad989b9b7f50246 Mon Sep 17 00:00:00 2001 From: PIYUSH RATHORE <163632958+Piyushrathoree@users.noreply.github.com> Date: Tue, 5 Aug 2025 13:58:32 +0530 Subject: [PATCH 5/9] Update RecentRelease.test.tsx --- frontend/__tests__/unit/components/RecentRelease.test.tsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/frontend/__tests__/unit/components/RecentRelease.test.tsx b/frontend/__tests__/unit/components/RecentRelease.test.tsx index b1d7e6dc17..8b4f434317 100644 --- a/frontend/__tests__/unit/components/RecentRelease.test.tsx +++ b/frontend/__tests__/unit/components/RecentRelease.test.tsx @@ -257,15 +257,11 @@ describe('RecentReleases Component', () => { it('should render with default props when not provided', () => { let container : HTMLElement act(() => { - render() const result = render() container = result.container }) - // Should show avatars by default expect(screen.getByRole('link', { name: /Test User/i })).toBeInTheDocument() - - const gridContainer = container.querySelector('.grid') expect(gridContainer).toHaveClass('md:grid-cols-2', 'lg:grid-cols-3') }) From 04de5228c11f421a6398b68efb6497da8152c8c8 Mon Sep 17 00:00:00 2001 From: Piyushrathoree Date: Tue, 5 Aug 2025 14:36:17 +0530 Subject: [PATCH 6/9] update the suggested changes by coderabbit --- frontend/__tests__/unit/components/RecentRelease.test.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/__tests__/unit/components/RecentRelease.test.tsx b/frontend/__tests__/unit/components/RecentRelease.test.tsx index 8b4f434317..4280049023 100644 --- a/frontend/__tests__/unit/components/RecentRelease.test.tsx +++ b/frontend/__tests__/unit/components/RecentRelease.test.tsx @@ -255,7 +255,7 @@ describe('RecentReleases Component', () => { }) it('should render with default props when not provided', () => { - let container : HTMLElement + let container: HTMLElement act(() => { const result = render() container = result.container @@ -267,11 +267,11 @@ describe('RecentReleases Component', () => { }) it('should handle null/undefined data gracefully', () => { - const { unmount } = render() + const { unmount } = render() expect(screen.getByText('No recent releases.')).toBeInTheDocument() unmount() - render() + render() expect(screen.getByText('No recent releases.')).toBeInTheDocument() }) From b82f2b43342e10cef1f9091f5f228fff0568a3cd Mon Sep 17 00:00:00 2001 From: Piyushrathoree Date: Tue, 5 Aug 2025 23:31:31 +0530 Subject: [PATCH 7/9] update the change assisted by code rabbit and change test according to it --- .../unit/components/RecentRelease.test.tsx | 16 ++++++++++------ frontend/src/components/RecentReleases.tsx | 12 +++++++----- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/frontend/__tests__/unit/components/RecentRelease.test.tsx b/frontend/__tests__/unit/components/RecentRelease.test.tsx index 4280049023..8062ec73b7 100644 --- a/frontend/__tests__/unit/components/RecentRelease.test.tsx +++ b/frontend/__tests__/unit/components/RecentRelease.test.tsx @@ -319,14 +319,15 @@ describe('RecentReleases Component', () => { render() }) - const repoNameElement = screen.getByText(/our-awesome-project/i) + const repoButton = screen.getByRole('button') + expect(repoButton).toBeDisabled() + act(() => { - fireEvent.click(repoNameElement) + fireEvent.click(repoButton) }) - expect(mockRouterPush).toHaveBeenCalledWith( - '/organizations/undefined/repositories/our-awesome-project' - ) + // Should not navigate when organization name is missing + expect(mockRouterPush).not.toHaveBeenCalled() }) it('should handle repository click with missing repository name', () => { @@ -342,11 +343,14 @@ describe('RecentReleases Component', () => { }) const repoButton = screen.getByRole('button') + expect(repoButton).toBeDisabled() + act(() => { fireEvent.click(repoButton) }) - expect(mockRouterPush).toHaveBeenCalledWith('/organizations/our-org/repositories/') + // Should not navigate when repository name is missing + expect(mockRouterPush).not.toHaveBeenCalled() }) it('should render with proper CSS classes for styling', () => { diff --git a/frontend/src/components/RecentReleases.tsx b/frontend/src/components/RecentReleases.tsx index 5ea73c37fb..c8015f8e1c 100644 --- a/frontend/src/components/RecentReleases.tsx +++ b/frontend/src/components/RecentReleases.tsx @@ -84,11 +84,13 @@ const RecentReleases: React.FC = ({ From 3f66a652be12f53416634d934bf5372f1dffcb4c Mon Sep 17 00:00:00 2001 From: PIYUSH RATHORE <163632958+Piyushrathoree@users.noreply.github.com> Date: Sat, 2 Aug 2025 09:39:57 +0530 Subject: [PATCH 8/9] Update frontend/__tests__/unit/components/RecentRelease.test.tsx as per coderabbitai this commit fixes the timestamp data Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- frontend/__tests__/unit/components/RecentRelease.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/__tests__/unit/components/RecentRelease.test.tsx b/frontend/__tests__/unit/components/RecentRelease.test.tsx index 8062ec73b7..f822b59e22 100644 --- a/frontend/__tests__/unit/components/RecentRelease.test.tsx +++ b/frontend/__tests__/unit/components/RecentRelease.test.tsx @@ -69,7 +69,7 @@ const mockReleases: Release[] = [ { name: 'v1.0 The First Release', url: 'https://example.com/release/v1', - publishedAt: now, + publishedAt: 1722420000000, // 2024-07-31T10:00:00Z as timestamp repositoryName: 'our-awesome-project', organizationName: 'our-org', tagName: 'v1.0', From 471fced94210eabb1c0d76dd66a5bf55a698afc3 Mon Sep 17 00:00:00 2001 From: Arkadii Yakovets Date: Tue, 5 Aug 2025 20:06:37 -0700 Subject: [PATCH 9/9] Update code --- .../unit/components/ItemCardList.test.tsx | 1 - .../unit/components/RecentRelease.test.tsx | 13 +++++-------- frontend/src/components/RecentReleases.tsx | 14 +++++++------- frontend/src/types/release.ts | 1 - 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/frontend/__tests__/unit/components/ItemCardList.test.tsx b/frontend/__tests__/unit/components/ItemCardList.test.tsx index 5eafffd374..852a6e576d 100644 --- a/frontend/__tests__/unit/components/ItemCardList.test.tsx +++ b/frontend/__tests__/unit/components/ItemCardList.test.tsx @@ -178,7 +178,6 @@ const mockRelease: Release = { publishedAt: 1640995200000, repositoryName: 'test-repo', tagName: 'v1.0.0', - url: 'https://github.com/test-org/test-repo/releases/tag/v1.0.0', } describe('ItemCardList Component', () => { diff --git a/frontend/__tests__/unit/components/RecentRelease.test.tsx b/frontend/__tests__/unit/components/RecentRelease.test.tsx index f822b59e22..cbed308e81 100644 --- a/frontend/__tests__/unit/components/RecentRelease.test.tsx +++ b/frontend/__tests__/unit/components/RecentRelease.test.tsx @@ -68,8 +68,7 @@ const now = Date.now() const mockReleases: Release[] = [ { name: 'v1.0 The First Release', - url: 'https://example.com/release/v1', - publishedAt: 1722420000000, // 2024-07-31T10:00:00Z as timestamp + publishedAt: now, repositoryName: 'our-awesome-project', organizationName: 'our-org', tagName: 'v1.0', @@ -89,7 +88,6 @@ const mockReleases: Release[] = [ }, { name: 'v2.0 The Second Release', - url: 'https://example.com/release/v2', publishedAt: now, repositoryName: 'another-cool-project', organizationName: 'our-org', @@ -193,14 +191,13 @@ describe('RecentReleases Component', () => { // New test cases for comprehensive coverage - it('should handle releases with missing author information', () => { + it('should handle releases with missing author name', () => { const releasesWithMissingAuthor = [ { ...mockReleases[0], author: { ...mockReleases[0].author, - name: undefined, - login: undefined, + name: '', }, }, ] @@ -212,7 +209,7 @@ describe('RecentReleases Component', () => { // Should still render the release name expect(screen.getByText('v1.0 The First Release')).toBeInTheDocument() // Should handle missing author gracefully - expect(screen.queryByRole('img')).not.toBeInTheDocument() + expect(screen.getByAltText('testuser')).toBeInTheDocument() }) it('should handle releases with missing repository information', () => { @@ -330,7 +327,7 @@ describe('RecentReleases Component', () => { expect(mockRouterPush).not.toHaveBeenCalled() }) - it('should handle repository click with missing repository name', () => { + it('should disable repository button if repository name is missing', () => { const releasesWithMissingRepoName = [ { ...mockReleases[0], diff --git a/frontend/src/components/RecentReleases.tsx b/frontend/src/components/RecentReleases.tsx index c8015f8e1c..c8aadef0f1 100644 --- a/frontend/src/components/RecentReleases.tsx +++ b/frontend/src/components/RecentReleases.tsx @@ -44,7 +44,7 @@ const RecentReleases: React.FC = ({ {showAvatar && item?.author && ( = ({ > {item?.author?.name @@ -71,7 +71,7 @@ const RecentReleases: React.FC = ({ target="_blank" rel="noopener noreferrer" > - + @@ -86,8 +86,8 @@ const RecentReleases: React.FC = ({ className="cursor-pointer overflow-hidden text-ellipsis whitespace-nowrap text-gray-600 hover:underline dark:text-gray-400" disabled={!item.organizationName || !item.repositoryName} onClick={() => { - const org = item.organizationName ?? '' - const repo = item.repositoryName ?? '' + const org = item.organizationName || '' + const repo = item.repositoryName || '' if (!org || !repo) return router.push(`/organizations/${org}/repositories/${repo}`) }} diff --git a/frontend/src/types/release.ts b/frontend/src/types/release.ts index 296faa5e86..2e422ec81d 100644 --- a/frontend/src/types/release.ts +++ b/frontend/src/types/release.ts @@ -10,5 +10,4 @@ export type Release = { repository?: RepositoryDetails repositoryName: string tagName: string - url: string }