|
| 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