Skip to content

Commit 3348f45

Browse files
authored
Merge pull request #251 from codeunia-dev/internproject
feat(resume): Add comprehensive accessibility and testing infrastructure
2 parents 285ba2d + 747ac56 commit 3348f45

File tree

73 files changed

+17889
-9
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+17889
-9
lines changed

__tests__/accessibility.test.tsx

Lines changed: 679 additions & 0 deletions
Large diffs are not rendered by default.

__tests__/cross-browser.test.tsx

Lines changed: 489 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
import React from 'react';
2+
import { render, screen, fireEvent } from '@testing-library/react';
3+
import '@testing-library/jest-dom';
4+
import { EducationSection } from '@/components/resume/sections/EducationSection';
5+
import { Education } from '@/types/resume';
6+
7+
describe('EducationSection', () => {
8+
const mockOnChange = jest.fn();
9+
10+
beforeEach(() => {
11+
mockOnChange.mockClear();
12+
});
13+
14+
it('should render empty state when no education entries exist', () => {
15+
render(<EducationSection content={[]} onChange={mockOnChange} />);
16+
17+
expect(screen.getByText('No education entries yet')).toBeInTheDocument();
18+
expect(screen.getByText('Click "Add Education" to get started')).toBeInTheDocument();
19+
});
20+
21+
it('should render add education button', () => {
22+
render(<EducationSection content={[]} onChange={mockOnChange} />);
23+
24+
expect(screen.getByRole('button', { name: /add education/i })).toBeInTheDocument();
25+
});
26+
27+
it('should add a new education entry when add button is clicked', () => {
28+
render(<EducationSection content={[]} onChange={mockOnChange} />);
29+
30+
const addButton = screen.getByRole('button', { name: /add education/i });
31+
fireEvent.click(addButton);
32+
33+
expect(mockOnChange).toHaveBeenCalledWith(
34+
expect.arrayContaining([
35+
expect.objectContaining({
36+
institution: '',
37+
degree: '',
38+
field: '',
39+
current: false,
40+
})
41+
])
42+
);
43+
});
44+
45+
it('should render education entry with all required fields', () => {
46+
const education: Education = {
47+
id: '1',
48+
institution: 'MIT',
49+
degree: 'Bachelor of Science',
50+
field: 'Computer Science',
51+
start_date: '2018-09',
52+
end_date: '2022-05',
53+
current: false,
54+
gpa: '3.9',
55+
achievements: ['Dean\'s List'],
56+
};
57+
58+
render(<EducationSection content={[education]} onChange={mockOnChange} />);
59+
60+
expect(screen.getByText('MIT')).toBeInTheDocument();
61+
expect(screen.getByText('Bachelor of Science in Computer Science')).toBeInTheDocument();
62+
});
63+
64+
it('should update institution field', () => {
65+
const education: Education = {
66+
id: '1',
67+
institution: '',
68+
degree: '',
69+
field: '',
70+
start_date: '',
71+
current: false,
72+
};
73+
74+
render(<EducationSection content={[education]} onChange={mockOnChange} />);
75+
76+
const institutionInput = screen.getByPlaceholderText('University of California, Berkeley');
77+
fireEvent.change(institutionInput, { target: { value: 'Stanford University' } });
78+
79+
expect(mockOnChange).toHaveBeenCalledWith([
80+
expect.objectContaining({
81+
institution: 'Stanford University',
82+
})
83+
]);
84+
});
85+
86+
it('should handle current checkbox correctly', () => {
87+
const education: Education = {
88+
id: '1',
89+
institution: 'MIT',
90+
degree: 'PhD',
91+
field: 'AI',
92+
start_date: '2022-09',
93+
current: false,
94+
};
95+
96+
render(<EducationSection content={[education]} onChange={mockOnChange} />);
97+
98+
const currentCheckbox = screen.getByRole('checkbox', { name: /i currently study here/i });
99+
fireEvent.click(currentCheckbox);
100+
101+
expect(mockOnChange).toHaveBeenCalledWith([
102+
expect.objectContaining({
103+
current: true,
104+
end_date: undefined,
105+
})
106+
]);
107+
});
108+
109+
it('should add achievement to education entry', () => {
110+
const education: Education = {
111+
id: '1',
112+
institution: 'MIT',
113+
degree: 'BS',
114+
field: 'CS',
115+
start_date: '2018-09',
116+
current: false,
117+
achievements: [],
118+
};
119+
120+
render(<EducationSection content={[education]} onChange={mockOnChange} />);
121+
122+
// Find the achievements section and click its Add button
123+
const achievementsLabel = screen.getByText('Achievements & Honors (Optional)');
124+
const achievementsSection = achievementsLabel.closest('div');
125+
126+
if (achievementsSection) {
127+
const addButton = achievementsSection.querySelector('button');
128+
if (addButton) {
129+
fireEvent.click(addButton);
130+
131+
expect(mockOnChange).toHaveBeenCalledWith([
132+
expect.objectContaining({
133+
achievements: [''],
134+
})
135+
]);
136+
}
137+
}
138+
});
139+
140+
it('should remove education entry', () => {
141+
const education: Education = {
142+
id: '1',
143+
institution: 'MIT',
144+
degree: 'BS',
145+
field: 'CS',
146+
start_date: '2018-09',
147+
current: false,
148+
};
149+
150+
render(<EducationSection content={[education]} onChange={mockOnChange} />);
151+
152+
const deleteButton = screen.getByRole('button', { name: '' });
153+
fireEvent.click(deleteButton);
154+
155+
expect(mockOnChange).toHaveBeenCalledWith([]);
156+
});
157+
158+
it('should render multiple education entries', () => {
159+
const educations: Education[] = [
160+
{
161+
id: '1',
162+
institution: 'MIT',
163+
degree: 'BS',
164+
field: 'CS',
165+
start_date: '2018-09',
166+
current: false,
167+
},
168+
{
169+
id: '2',
170+
institution: 'Stanford',
171+
degree: 'MS',
172+
field: 'AI',
173+
start_date: '2022-09',
174+
current: true,
175+
},
176+
];
177+
178+
render(<EducationSection content={educations} onChange={mockOnChange} />);
179+
180+
expect(screen.getByText('MIT')).toBeInTheDocument();
181+
expect(screen.getByText('Stanford')).toBeInTheDocument();
182+
});
183+
});

0 commit comments

Comments
 (0)