diff --git a/frontend/__tests__/a11y/components/RepositoryCard.a11y.test.tsx b/frontend/__tests__/a11y/components/RepositoryCard.a11y.test.tsx index 427e07caaa..bedf7b68a4 100644 --- a/frontend/__tests__/a11y/components/RepositoryCard.a11y.test.tsx +++ b/frontend/__tests__/a11y/components/RepositoryCard.a11y.test.tsx @@ -5,6 +5,7 @@ import { RepositoryCardProps } from 'types/project' import RepositoryCard from 'components/RepositoryCard' const createMockRepository = (index: number): RepositoryCardProps => ({ + updatedAt: '2025-01-01T00:00:00.000Z', contributorsCount: 10 + index, forksCount: 5 + index, key: `repo-${index}`, diff --git a/frontend/__tests__/unit/components/RepositoryCard.test.tsx b/frontend/__tests__/unit/components/RepositoryCard.test.tsx index a46b483cad..1e9bde985f 100644 --- a/frontend/__tests__/unit/components/RepositoryCard.test.tsx +++ b/frontend/__tests__/unit/components/RepositoryCard.test.tsx @@ -48,6 +48,7 @@ describe('RepositoryCard', () => { }) const createMockRepository = (index: number): RepositoryCardProps => ({ + updatedAt: '2025-01-01T00:00:00.000Z', contributorsCount: 10 + index, forksCount: 5 + index, key: `repo-${index}`, @@ -72,6 +73,12 @@ describe('RepositoryCard', () => { url: `https://github.com/org-${index}/repo-${index}`, }) + it('displays repository updated date when available', () => { + const repositories = [createMockRepository(0)] + render() + expect(screen.getByText(/Updated/i)).toBeInTheDocument() + }) + it('renders without crashing with empty repositories', () => { render() expect(screen.queryByRole('button', { name: /Show/ })).not.toBeInTheDocument() diff --git a/frontend/src/components/RepositoryCard.tsx b/frontend/src/components/RepositoryCard.tsx index 03c0b5a661..db7ed45808 100644 --- a/frontend/src/components/RepositoryCard.tsx +++ b/frontend/src/components/RepositoryCard.tsx @@ -86,6 +86,12 @@ const RepositoryItem = ({ details }: { details: RepositoryCardProps }) => { unit="Issue" value={details.openIssuesCount} /> + + {details.updatedAt && ( +
+ Updated {new Date(details.updatedAt).toLocaleDateString()} +
+ )} ) diff --git a/frontend/src/server/fetchAlgoliaData.ts b/frontend/src/server/fetchAlgoliaData.ts index 63e065e9d7..fe238e9c99 100644 --- a/frontend/src/server/fetchAlgoliaData.ts +++ b/frontend/src/server/fetchAlgoliaData.ts @@ -35,6 +35,22 @@ export const fetchAlgoliaData = async ( }), }) + if (response.status === 400) { + const errorData = await response.json() + + if ( + typeof errorData?.error === 'string' && + errorData.error.includes('Invalid query value') + ) { + return { + hits: [], + totalPages: 0, + } + } + + throw new AppError(400, 'Search service error') + } + if (!response.ok) { throw new AppError(response.status, 'Search service error') } diff --git a/frontend/src/server/queries/organizationQueries.ts b/frontend/src/server/queries/organizationQueries.ts index 14e231e56c..193a66acbf 100644 --- a/frontend/src/server/queries/organizationQueries.ts +++ b/frontend/src/server/queries/organizationQueries.ts @@ -76,6 +76,7 @@ export const GET_ORGANIZATION_DATA = gql` url } repositories(organization: $login, limit: 12) { + updatedAt id contributorsCount forksCount diff --git a/frontend/src/types/project.ts b/frontend/src/types/project.ts index 7b39bc729f..3d94386aeb 100644 --- a/frontend/src/types/project.ts +++ b/frontend/src/types/project.ts @@ -63,6 +63,7 @@ export type RepositoryCardListProps = { } export type RepositoryCardProps = { + updatedAt?: string contributorsCount: number forksCount: number isArchived?: boolean