Skip to content

Commit 067d028

Browse files
test(customizecta): add heading accessibility assertions (JhaSourav07#797)
## Description Fixes JhaSourav07#713 Added accessibility-focused assertions for the `CustomizeCTA` heading to improve semantic HTML test coverage. ## Changes Made * Added assertion for an `h2` heading level * Added assertion to verify exactly one `h2` exists * Added assertion for the exact heading text: `Want to fine-tune your monolith?` ## Pillar * [x] 🛠️ Other (Bug fix, refactoring, docs) ## Validation * Ran `npm run test` * Verified all existing `CustomizeCTA` tests pass
1 parent 55e9c4a commit 067d028

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

app/components/CustomizeCTA.test.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,22 @@ describe('CustomizeCTA', () => {
4949
it('renders the descriptive body copy', () => {
5050
render(<CustomizeCTA />);
5151

52-
// Partial match because the text is long and may contain internal whitespace in the DOM.
5352
expect(screen.getByText(/Dial in every pixel/i)).toBeTruthy();
5453
});
5554
});
5655

5756
describe('document structure', () => {
58-
it('renders the section heading as an <h2>', () => {
57+
it('renders the section heading as exactly one <h2>', () => {
5958
render(<CustomizeCTA />);
6059

61-
const heading = screen.getByRole('heading', { level: 2 });
60+
const heading = screen.getByRole('heading', {
61+
level: 2,
62+
name: 'Want to fine-tune your monolith?',
63+
});
64+
6265
expect(heading).toBeTruthy();
63-
expect(heading.textContent).toContain('Want to fine-tune your monolith?');
66+
expect(screen.getAllByRole('heading', { level: 2 })).toHaveLength(1);
67+
expect(heading.textContent).toBe('Want to fine-tune your monolith?');
6468
});
6569

6670
it('renders exactly one link', () => {
@@ -108,8 +112,6 @@ describe('CustomizeCTA', () => {
108112
it('marks the decorative shimmer overlay as aria-hidden', () => {
109113
const { container } = render(<CustomizeCTA />);
110114

111-
// The shimmer span is purely visual — hiding it prevents screen readers
112-
// from announcing it as a mysterious empty element.
113115
const hiddenSpans = container.querySelectorAll('span[aria-hidden="true"]');
114116
expect(hiddenSpans.length).toBeGreaterThan(0);
115117
});

0 commit comments

Comments
 (0)