Skip to content

Commit bb8cb58

Browse files
committed
test(cherry-blossom): add accessibility coverage
1 parent 6724b3a commit bb8cb58

1 file changed

Lines changed: 74 additions & 0 deletions

File tree

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { describe, it, expect, vi, beforeEach } from 'vitest';
2+
import { render, screen, waitFor } from '@testing-library/react';
3+
import '@testing-library/jest-dom/vitest';
4+
import CherryBlossom from './CherryBlossom';
5+
import type React from 'react';
6+
7+
vi.mock('framer-motion', () => ({
8+
motion: {
9+
div: ({
10+
children,
11+
...props
12+
}: React.PropsWithChildren<React.HTMLAttributes<HTMLDivElement>>) => (
13+
<div data-testid="motion-div" {...props}>
14+
{children}
15+
</div>
16+
),
17+
},
18+
}));
19+
20+
describe('CherryBlossom accessibility', () => {
21+
beforeEach(() => {
22+
vi.restoreAllMocks();
23+
});
24+
25+
it('renders as a decorative non-interactive overlay', async () => {
26+
const { container } = render(<CherryBlossom />);
27+
28+
await waitFor(() => {
29+
const overlay = container.querySelector('.pointer-events-none');
30+
expect(overlay).toBeInTheDocument();
31+
});
32+
});
33+
34+
it('contains no focusable interactive controls', async () => {
35+
const { container } = render(<CherryBlossom />);
36+
37+
await waitFor(() => {
38+
expect(container.querySelectorAll('button,input,textarea,select,a,[tabindex]')).toHaveLength(
39+
0
40+
);
41+
});
42+
});
43+
44+
it('does not expose interactive motion petals', async () => {
45+
render(<CherryBlossom />);
46+
47+
await waitFor(() => {
48+
const petals = screen.getAllByTestId('motion-div');
49+
50+
petals.forEach((petal) => {
51+
expect(petal).not.toHaveAttribute('role', 'button');
52+
});
53+
});
54+
});
55+
56+
it('maintains normal document accessibility flow', async () => {
57+
const { container } = render(<CherryBlossom />);
58+
59+
await waitFor(() => {
60+
const overlay = container.querySelector('.fixed.inset-0');
61+
expect(overlay).toBeInTheDocument();
62+
expect(overlay).toHaveClass('pointer-events-none');
63+
});
64+
});
65+
66+
it('renders decorative SVG content without accessibility violations', async () => {
67+
const { container } = render(<CherryBlossom />);
68+
69+
await waitFor(() => {
70+
const svgs = container.querySelectorAll('svg');
71+
expect(svgs.length).toBeGreaterThanOrEqual(27);
72+
});
73+
});
74+
});

0 commit comments

Comments
 (0)