Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand Down
7 changes: 7 additions & 0 deletions frontend/__tests__/unit/components/RepositoryCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand All @@ -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(<RepositoryCard repositories={repositories} />)
expect(screen.getByText(/Updated/i)).toBeInTheDocument()
})
Comment thread
Tanishq-mellu marked this conversation as resolved.

it('renders without crashing with empty repositories', () => {
render(<RepositoryCard repositories={[]} />)
expect(screen.queryByRole('button', { name: /Show/ })).not.toBeInTheDocument()
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/components/RepositoryCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ const RepositoryItem = ({ details }: { details: RepositoryCardProps }) => {
unit="Issue"
value={details.openIssuesCount}
/>

{details.updatedAt && (
<div className="text-xs text-gray-500 dark:text-gray-400">
Updated {new Date(details.updatedAt).toLocaleDateString()}
</div>
)}
Comment thread
Tanishq-mellu marked this conversation as resolved.
</div>
</div>
)
Expand Down
21 changes: 20 additions & 1 deletion frontend/src/server/fetchAlgoliaData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,29 @@ export const fetchAlgoliaData = async <T>(
}),
})

if (response.status === 400) {
const errorData = await response.json()

if (
typeof errorData?.error === 'string' &&
Comment thread
Tanishq-mellu marked this conversation as resolved.
errorData.error.includes('Invalid query value')
) {

if (
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Outdated
typeof errorData?.error === 'string' &&
errorData.error.includes('Invalid query value')
) {
return {
hits: [],
totalPages: 0,
}
}

throw new AppError(400, 'Search service error')
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Outdated

Comment thread
Tanishq-mellu marked this conversation as resolved.
Comment thread
coderabbitai[bot] marked this conversation as resolved.
if (!response.ok) {
throw new AppError(response.status, 'Search service error')
}

const results = await response.json()
if (results && results.hits.length > 0) {
const { hits, nbPages } = results
Expand Down
1 change: 1 addition & 0 deletions frontend/src/server/queries/organizationQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export const GET_ORGANIZATION_DATA = gql`
url
}
repositories(organization: $login, limit: 12) {
updatedAt
id
contributorsCount
forksCount
Expand Down
1 change: 1 addition & 0 deletions frontend/src/types/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export type RepositoryCardListProps = {
}

export type RepositoryCardProps = {
updatedAt?: string
contributorsCount: number
forksCount: number
isArchived?: boolean
Expand Down