Skip to content

Commit ac3c973

Browse files
boss477JhaSourav07
andauthored
test(resume-preview): add accessibility compliance test suite (JhaSourav07#2876) (JhaSourav07#3007)
* test(resume-preview): add theme contrast test suite (JhaSourav07#2875) * test(resume-preview): add accessibility compliance test suite (JhaSourav07#2876) --------- Co-authored-by: Sourav Jha <souravkjha2007@gmail.com>
1 parent 65c6ce8 commit ac3c973

2 files changed

Lines changed: 190 additions & 0 deletions

File tree

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import { render, screen } from '@testing-library/react';
2+
import { describe, it, expect, vi } from 'vitest';
3+
import ResumePreviewForm from './ResumePreviewForm';
4+
import type { ReactNode, HTMLAttributes } from 'react';
5+
import '@testing-library/jest-dom';
6+
7+
vi.mock('framer-motion', () => ({
8+
motion: {
9+
div: ({ children, ...props }: HTMLAttributes<HTMLDivElement> & { children?: ReactNode }) => (
10+
<div {...props}>{children}</div>
11+
),
12+
},
13+
}));
14+
15+
const parsed = {
16+
name: 'John Doe',
17+
email: 'john@example.com',
18+
phone: '1234567890',
19+
skills: ['React'],
20+
education: [],
21+
experience: [],
22+
};
23+
24+
describe('ResumePreviewForm - Accessibility compliance', () => {
25+
const onBack = vi.fn();
26+
const onComplete = vi.fn();
27+
28+
it('checks that crucial fields have associated visible text labels', () => {
29+
render(
30+
<ResumePreviewForm
31+
githubUsername="john"
32+
parsed={parsed}
33+
fileName="resume.pdf"
34+
onBack={onBack}
35+
onComplete={onComplete}
36+
/>
37+
);
38+
39+
// Form inputs should have associated visible text labels
40+
expect(screen.getByText('Full Name')).toBeInTheDocument();
41+
expect(screen.getByText('Email')).toBeInTheDocument();
42+
expect(screen.getByText('Skills')).toBeInTheDocument();
43+
expect(screen.getByText('Education')).toBeInTheDocument();
44+
expect(screen.getByText('Experience')).toBeInTheDocument();
45+
});
46+
47+
it('checks that interactive inputs have focus-visible or outline configurations', () => {
48+
render(
49+
<ResumePreviewForm
50+
githubUsername="john"
51+
parsed={parsed}
52+
fileName="resume.pdf"
53+
onBack={onBack}
54+
onComplete={onComplete}
55+
/>
56+
);
57+
58+
const nameInput = screen.getByDisplayValue('John Doe');
59+
expect(nameInput).toHaveClass('focus:ring-2');
60+
expect(nameInput).toHaveClass('focus:ring-emerald-500');
61+
expect(nameInput).toHaveClass('outline-none');
62+
});
63+
64+
it('checks that the save button is disabled when saving to prevent multiple submissions', () => {
65+
render(
66+
<ResumePreviewForm
67+
githubUsername="john"
68+
parsed={parsed}
69+
fileName="resume.pdf"
70+
onBack={onBack}
71+
onComplete={onComplete}
72+
/>
73+
);
74+
75+
// Initially not disabled
76+
const saveButton = screen.getByRole('button', { name: /Save Profile/i });
77+
expect(saveButton).not.toBeDisabled();
78+
});
79+
});
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import { render } from '@testing-library/react';
2+
import { describe, it, expect, vi } from 'vitest';
3+
import ResumePreviewForm from './ResumePreviewForm';
4+
import type { ReactNode, HTMLAttributes } from 'react';
5+
import '@testing-library/jest-dom';
6+
7+
vi.mock('framer-motion', () => ({
8+
motion: {
9+
div: ({ children, ...props }: HTMLAttributes<HTMLDivElement> & { children?: ReactNode }) => (
10+
<div {...props}>{children}</div>
11+
),
12+
},
13+
}));
14+
15+
const parsed = {
16+
name: 'John Doe',
17+
email: 'john@example.com',
18+
phone: '1234567890',
19+
skills: ['React'],
20+
education: [],
21+
experience: [],
22+
};
23+
24+
describe('ResumePreviewForm - Theme Contrast & Visual Cohesion', () => {
25+
const onBack = vi.fn();
26+
const onComplete = vi.fn();
27+
28+
it('verifies dark and light background/border contrast classes on the outer container', () => {
29+
const { container } = render(
30+
<ResumePreviewForm
31+
githubUsername="john"
32+
parsed={parsed}
33+
fileName="resume.pdf"
34+
onBack={onBack}
35+
onComplete={onComplete}
36+
/>
37+
);
38+
39+
const mainContainer = container.firstElementChild;
40+
expect(mainContainer).toHaveClass('bg-white');
41+
expect(mainContainer).toHaveClass('dark:bg-[#0a0a0a]');
42+
expect(mainContainer).toHaveClass('border-black/10');
43+
expect(mainContainer).toHaveClass('dark:border-[rgba(255,255,255,0.08)]');
44+
});
45+
46+
it('verifies contrast text classes for headings, labels, and helper descriptions', () => {
47+
const { getByText } = render(
48+
<ResumePreviewForm
49+
githubUsername="john"
50+
parsed={parsed}
51+
fileName="resume.pdf"
52+
onBack={onBack}
53+
onComplete={onComplete}
54+
/>
55+
);
56+
57+
const title = getByText('Review Parsed Data');
58+
expect(title).toHaveClass('text-gray-900');
59+
expect(title).toHaveClass('dark:text-white');
60+
61+
const subtitle = getByText(/From: resume.pdf/);
62+
expect(subtitle).toHaveClass('text-gray-500');
63+
expect(subtitle).toHaveClass('dark:text-white/50');
64+
65+
const nameLabel = getByText('Full Name');
66+
expect(nameLabel).toHaveClass('text-gray-600');
67+
expect(nameLabel).toHaveClass('dark:text-white/70');
68+
});
69+
70+
it('verifies visual cohesion classes on input elements', () => {
71+
const { getByDisplayValue } = render(
72+
<ResumePreviewForm
73+
githubUsername="john"
74+
parsed={parsed}
75+
fileName="resume.pdf"
76+
onBack={onBack}
77+
onComplete={onComplete}
78+
/>
79+
);
80+
81+
const nameInput = getByDisplayValue('John Doe');
82+
expect(nameInput).toHaveClass('bg-gray-50');
83+
expect(nameInput).toHaveClass('dark:bg-[#111]');
84+
expect(nameInput).toHaveClass('text-gray-900');
85+
expect(nameInput).toHaveClass('dark:text-white');
86+
expect(nameInput).toHaveClass('border-black/10');
87+
expect(nameInput).toHaveClass('dark:border-[rgba(255,255,255,0.1)]');
88+
});
89+
90+
it('verifies button styles maintain cohesive contrast levels', () => {
91+
const { getByText, getAllByText } = render(
92+
<ResumePreviewForm
93+
githubUsername="john"
94+
parsed={parsed}
95+
fileName="resume.pdf"
96+
onBack={onBack}
97+
onComplete={onComplete}
98+
/>
99+
);
100+
101+
const backButton = getByText('Back');
102+
expect(backButton).toHaveClass('border-black/10');
103+
expect(backButton).toHaveClass('dark:border-[rgba(255,255,255,0.15)]');
104+
expect(backButton).toHaveClass('text-gray-600');
105+
expect(backButton).toHaveClass('dark:text-white/70');
106+
107+
const addSkillBtn = getAllByText('Add')[0];
108+
expect(addSkillBtn).toHaveClass('text-emerald-600');
109+
expect(addSkillBtn).toHaveClass('dark:text-emerald-400');
110+
});
111+
});

0 commit comments

Comments
 (0)