Skip to content

Commit 9768ac1

Browse files
shining-bluemoon-11kasyaarkid15r
authored
Fix capitalization in project details block (#866)
* Fix capitalization in project details block as per issue #846 * fix check * add test case for capitalization issue * fix check * fix lint check * update the code * final fix check * Update code --------- Co-authored-by: Kate Golovanova <[email protected]> Co-authored-by: Arkadii Yakovets <[email protected]>
1 parent c77bcad commit 9768ac1

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

frontend/__tests__/src/data/mockProjectDetailsData.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const mockProjectDetailsData = {
77
key: 'example-project',
88
languages: ['Python', 'GraphQL', 'JavaScript'],
99
leaders: ['alice', 'bob'],
10-
level: 'Intermediate',
10+
level: 'Lab',
1111
name: 'Test Project',
1212
repositoriesCount: 3,
1313
starsCount: 10,
@@ -19,7 +19,7 @@ export const mockProjectDetailsData = {
1919
name: `Contributor ${i + 1}`,
2020
})),
2121
topics: ['graphql', 'django', 'backend'],
22-
type: 'Open Source',
22+
type: 'Tool',
2323
updatedAt: '2025-02-07T12:34:56Z',
2424
url: 'https://github.com/example-project',
2525
recentReleases: [

frontend/__tests__/src/pages/ProjectDetails.test.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ describe('ProjectDetailsPage', () => {
6565

6666
await waitFor(() => {
6767
expect(screen.getByText('Test Project')).toBeInTheDocument()
68-
expect(screen.getByText('Intermediate')).toBeInTheDocument()
68+
expect(screen.getByText('Lab')).toBeInTheDocument()
6969
})
7070
expect(screen.getByText('10 Forks')).toBeInTheDocument()
7171
expect(screen.getByText('10 Issues')).toBeInTheDocument()
@@ -168,6 +168,27 @@ describe('ProjectDetailsPage', () => {
168168
expect(setRecentIssuesMock).toHaveBeenCalledWith(undefined)
169169
})
170170

171+
test('renders project details with correct capitalization', async () => {
172+
;(useQuery as jest.Mock).mockReturnValue({
173+
data: mockProjectDetailsData,
174+
error: null,
175+
})
176+
177+
render(<ProjectDetailsPage />)
178+
179+
await waitFor(() => {
180+
const levelElement = screen.getByText(/Level:/)
181+
expect(levelElement).toBeInTheDocument()
182+
const levelValueElement = within(levelElement.parentElement).getByText('Lab')
183+
expect(levelValueElement).toBeInTheDocument()
184+
185+
const typeElement = screen.getByText(/Type:/)
186+
expect(typeElement).toBeInTheDocument()
187+
const typeValueElement = within(typeElement.parentElement).getByText('Tool')
188+
expect(typeValueElement).toBeInTheDocument()
189+
})
190+
})
191+
171192
test('handles missing project stats gracefully', async () => {
172193
;(useQuery as jest.Mock).mockReturnValue({
173194
data: {

frontend/src/pages/ProjectDetails.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,12 @@ const ProjectDetailsPage = () => {
6161
)
6262
const projectDetails = [
6363
{ label: 'Last Updated', value: formatDate(project.updatedAt) },
64-
{ label: 'Level', value: project.level[0].toUpperCase() + project.level.slice(1) },
64+
{
65+
label: 'Level',
66+
value: project.level[0].toUpperCase() + project.level.slice(1).toLowerCase(),
67+
},
6568
{ label: 'Project Leaders', value: project.leaders.join(', ') },
66-
{ label: 'Type', value: project.type[0].toUpperCase() + project.type.slice(1) },
69+
{ label: 'Type', value: project.type[0].toUpperCase() + project.type.slice(1).toLowerCase() },
6770
{
6871
label: 'URL',
6972
value: (

0 commit comments

Comments
 (0)