diff --git a/frontend/__tests__/unit/components/CardDetailsPage.test.tsx b/frontend/__tests__/unit/components/CardDetailsPage.test.tsx index 5398688b0c..784c320cb7 100644 --- a/frontend/__tests__/unit/components/CardDetailsPage.test.tsx +++ b/frontend/__tests__/unit/components/CardDetailsPage.test.tsx @@ -634,16 +634,8 @@ describe('CardDetailsPage', () => { const userSummary =
Custom user summary content
render() - expect(screen.getByText('Summary')).toBeInTheDocument() - expect(screen.getByText('Custom user summary content')).toBeInTheDocument() - }) - - it('renders heatmap section when heatmap prop is provided', () => { - const heatmap =
Contribution heatmap
- render() - - expect(screen.getByText('Contribution Heatmap')).toBeInTheDocument() - expect(screen.getByTestId('custom-heatmap')).toBeInTheDocument() + const userSummaryContent = screen.getByText('Custom user summary content') + expect(userSummaryContent).toBeInTheDocument() }) it('renders health metrics when type is project and health data is available', () => { @@ -1272,12 +1264,6 @@ describe('CardDetailsPage', () => { ), - heatmap: ( -
- -
Legend
-
- ), } render() @@ -1285,7 +1271,8 @@ describe('CardDetailsPage', () => { expect(screen.getByText('Nested')).toBeInTheDocument() expect(screen.getByText('Content')).toBeInTheDocument() expect(screen.getByText('Complex user summary')).toBeInTheDocument() - expect(screen.getByTestId('complex-heatmap')).toBeInTheDocument() + expect(screen.getByText('Item 1')).toBeInTheDocument() + expect(screen.getByText('Item 2')).toBeInTheDocument() }) it('renders correctly with all optional sections enabled', () => { @@ -1294,7 +1281,6 @@ describe('CardDetailsPage', () => { type: 'project', summary: 'Project summary text', userSummary:
User summary content
, - heatmap:
Heatmap content
, socialLinks: ['https://github.com/test', 'https://twitter.com/test'], entityKey: 'test-entity', projectName: 'Test Project Name', @@ -1312,7 +1298,6 @@ describe('CardDetailsPage', () => { expect(screen.getByText('Project summary text')).toBeInTheDocument() expect(screen.getByText('User summary content')).toBeInTheDocument() - expect(screen.getByTestId('heatmap')).toBeInTheDocument() expect(screen.getByTestId('health-metrics')).toBeInTheDocument() expect(screen.getByTestId('top-contributors-list')).toBeInTheDocument() expect(screen.getByTestId('repositories-card')).toBeInTheDocument() diff --git a/frontend/__tests__/unit/pages/UserDetails.test.tsx b/frontend/__tests__/unit/pages/UserDetails.test.tsx index 75bdf32930..cd2d2c9427 100644 --- a/frontend/__tests__/unit/pages/UserDetails.test.tsx +++ b/frontend/__tests__/unit/pages/UserDetails.test.tsx @@ -90,7 +90,6 @@ describe('UserDetailsPage', () => { expect(screen.getByText('Test User')).toBeInTheDocument() expect(screen.getByText('Statistics')).toBeInTheDocument() - expect(screen.getByText('Contribution Heatmap')).toBeInTheDocument() expect(screen.getByText('Test Company')).toBeInTheDocument() expect(screen.getByText('Test Location')).toBeInTheDocument() expect(screen.getByText('10 Followers')).toBeInTheDocument() @@ -233,13 +232,22 @@ describe('UserDetailsPage', () => { ;(useQuery as jest.Mock).mockReturnValue({ data: mockUserDetailsData, error: null, + loading: false, + }) + ;(fetchHeatmapData as jest.Mock).mockResolvedValue({ + years: [{ year: '2023' }], // Provide years data to satisfy condition in component }) render() + // Wait for useEffect to process the fetchHeatmapData result await waitFor(() => { - const heatmapTitle = screen.getByText('Contribution Heatmap') - expect(heatmapTitle).toBeInTheDocument() + const heatmapContainer = screen + .getByAltText('Heatmap Background') + .closest('div.hidden.lg\\:block') + expect(heatmapContainer).toBeInTheDocument() + expect(heatmapContainer).toHaveClass('hidden') + expect(heatmapContainer).toHaveClass('lg:block') }) }) @@ -269,6 +277,15 @@ describe('UserDetailsPage', () => { await waitFor(() => { const userName = screen.getByText('Test User') expect(userName).toBeInTheDocument() + const avatar = screen.getByAltText('Test User') + expect(avatar).toHaveClass('rounded-full') + expect(avatar).toHaveClass('h-[200px]') + expect(avatar).toHaveClass('w-[200px]') + + // Check for responsive classes + const summaryContainer = avatar.closest('div.flex') + expect(summaryContainer).toHaveClass('flex-col') + expect(summaryContainer).toHaveClass('lg:flex-row') }) }) @@ -466,6 +483,9 @@ describe('UserDetailsPage', () => { render() await waitFor(() => { expect(screen.getAllByText('N/A').length).toBe(3) + const bioContainer = screen.getByText('@testuser').closest('div') + expect(bioContainer).toHaveClass('text-center') + expect(bioContainer).toHaveClass('lg:text-left') }) }) test('does not render sponsor block', async () => { diff --git a/frontend/src/app/members/[memberKey]/page.tsx b/frontend/src/app/members/[memberKey]/page.tsx index 3ea4f24d54..b7c747324f 100644 --- a/frontend/src/app/members/[memberKey]/page.tsx +++ b/frontend/src/app/members/[memberKey]/page.tsx @@ -35,10 +35,7 @@ const UserDetailsPage: React.FC = () => { const [data, setData] = useState({} as HeatmapData) const [isLoading, setIsLoading] = useState(true) const [username, setUsername] = useState('') - const [imageLink, setImageLink] = useState('') const [isPrivateContributor, setIsPrivateContributor] = useState(false) - const canvasRef = useRef(null) - const theme = 'blue' const { data: graphQLData, error: graphQLRequestError } = useQuery(GET_USER_DATA, { variables: { key: memberKey }, @@ -75,14 +72,6 @@ const UserDetailsPage: React.FC = () => { fetchData() }, [memberKey, user]) - useEffect(() => { - if (canvasRef.current && data && data.years && data.years.length > 0) { - drawContributions(canvasRef.current, { data, username, theme }) - const imageURL = canvasRef.current.toDataURL() - setImageLink(imageURL) - } - }, [username, data]) - const formattedBio = user?.bio?.split(' ').map((word, index) => { // Regex to match GitHub usernames, but if last character is not a word character or @, it's a punctuation const mentionMatch = word.match(/^@([\w-]+(?:\.[\w-]+)*)([^\w@])?$/) @@ -142,6 +131,7 @@ const UserDetailsPage: React.FC = () => { const Heatmap = () => { const canvasRef = useRef(null) + const [imgSrc, setImgSrc] = useState('') const { resolvedTheme } = useTheme() const isDarkMode = (resolvedTheme ?? 'light') === 'dark' @@ -153,61 +143,71 @@ const UserDetailsPage: React.FC = () => { themeName: isDarkMode ? 'dark' : 'light', }) const imageURL = canvasRef.current.toDataURL() - setImageLink(imageURL) + setImgSrc(imageURL) + } else { + setImgSrc('') } }, [isDarkMode]) return ( -
-
-
- - {imageLink ? ( -
- Contribution Heatmap -
- ) : ( -
- Heatmap Background -
-
- )} -
+
+
+ + {imgSrc ? ( +
+ Contribution Heatmap +
+ ) : ( +
+ Heatmap Background +
+
+ )}
) } const UserSummary = () => ( -
- {user?.name -
- - @{user?.login} - -

{formattedBio}

+
+
+ {user?.name +
+
+
+ + @{user?.login} + +

{formattedBio}

+
+ + {!isPrivateContributor && ( +
+ +
+ )}
) @@ -215,7 +215,6 @@ const UserDetailsPage: React.FC = () => { return ( } pullRequests={pullRequests} recentIssues={issues} recentMilestones={milestones} diff --git a/frontend/src/components/CardDetailsPage.tsx b/frontend/src/components/CardDetailsPage.tsx index 0e288b327b..5f872a0ed5 100644 --- a/frontend/src/components/CardDetailsPage.tsx +++ b/frontend/src/components/CardDetailsPage.tsx @@ -1,6 +1,5 @@ import { faCircleInfo, - faSquarePollVertical, faChartPie, faFolderOpen, faCode, @@ -50,7 +49,6 @@ const DetailsCard = ({ entityKey, geolocationData = null, healthMetricsData, - heatmap, isActive = true, languages, projectName, @@ -116,20 +114,7 @@ const DetailsCard = ({ )} - {userSummary && ( - }> - {userSummary} - - )} - - {heatmap && ( - } - > - {heatmap} - - )} + {userSummary && {userSummary}}