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
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ describe('BadgesAndAwards component', () => {
});

// Check summary cards
expect(screen.getByText('x8')).toBeInTheDocument(); // Total badges: 5 + 3
expect(screen.getByText('x5')).toBeInTheDocument();
expect(screen.getByText('Top reader badge')).toBeInTheDocument();

// Check badge items
Expand Down Expand Up @@ -245,7 +245,7 @@ describe('BadgesAndAwards component', () => {
renderComponent();

expect(screen.getByText('Badges & Awards')).toBeInTheDocument();
expect(screen.getByText('x8')).toBeInTheDocument(); // Total badges
expect(screen.getByText('x5')).toBeInTheDocument();
expect(screen.getByText('x0')).toBeInTheDocument(); // No awards
expect(screen.queryByAltText('Award')).not.toBeInTheDocument();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ export const BadgesAndAwards = ({
return null;
}

const totalTopReaderBadges =
topReaders?.reduce((sum, topReader) => sum + (topReader?.total || 0), 0) ??
0;
const totalAwards =
awards?.reduce((sum, award) => sum + (award?.count || 0), 0) ?? 0;

Expand All @@ -86,7 +83,7 @@ export const BadgesAndAwards = ({

<div className="my-3 flex gap-3">
<SummaryCard
count={`x${totalTopReaderBadges}`}
count={`x${topReaders?.[0]?.total ?? 0}`}
label="Top reader badge"
/>
<SummaryCard count={`x${totalAwards}`} label="Total Awards" />
Expand Down