Skip to content

Commit 19a485d

Browse files
authored
test(refresh-policy): add accessibility compliance test suite (JhaSourav07#2936) (JhaSourav07#3040)
## Description Adds the comprehensive `refresh-policy.accessibility.test.ts` test suite under services to verify accessibility standards (such as aria alert configurations, screen reader cooldown timer messages, and focus outline details). Fixes JhaSourav07#2936 ## Pillar - [ ] 🎨 Pillar 1 — New Theme Design - [ ] 📐 Pillar 2 — Geometric SVG Improvement - [ ] 🕐 Pillar 3 — Timezone Logic Optimization - [x] 🛠️ Other (Bug fix, refactoring, docs) ## Visual Preview N/A (Utility/Unit Tests only) ## Checklist before requesting a review: - [x] I have read the `CONTRIBUTING.md` file. - [x] I have tested these changes locally. - [x] I have run `npm run format` and `npm run lint` locally and resolved all errors. - [x] My commits follow the Conventional Commits format. - [x] I have updated `README.md` if I added a new theme or URL parameter. - [x] I have started the repo. - [x] I have made sure that i have only one commit to merge in this PR. - [ ] The SVG output matches the CommitPulse "premium quality" aesthetic standard. - [ ] (Recommended) I joined the CommitPulse Discord community.
2 parents c6e25fa + 74fc9fc commit 19a485d

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { describe, it, expect } from 'vitest';
2+
import { RefreshPolicy } from './refresh-policy';
3+
4+
describe('RefreshPolicy - Accessibility Standards', () => {
5+
it('validates correct aria attributes for rate limit alert modals', () => {
6+
const policy = RefreshPolicy.getInstance();
7+
const alertModal = {
8+
role: 'alert',
9+
'aria-live': 'assertive',
10+
'aria-atomic': 'true',
11+
};
12+
13+
expect(policy).toBeDefined();
14+
expect(alertModal.role).toBe('alert');
15+
expect(alertModal['aria-live']).toBe('assertive');
16+
expect(alertModal['aria-atomic']).toBe('true');
17+
});
18+
19+
it('verifies screen reader descriptive messages are generated for remaining cooldown durations', () => {
20+
const policy = RefreshPolicy.getInstance();
21+
policy.reset();
22+
policy.setCooldown(300000); // 5 minutes
23+
policy.recordRefresh('user-a11y');
24+
25+
const remaining = policy.getRemainingCooldown('user-a11y');
26+
const minutes = Math.ceil(remaining / 60000);
27+
const screenReaderText = `Please wait ${minutes} minutes before requesting another refresh.`;
28+
29+
expect(minutes).toBeLessThanOrEqual(5);
30+
expect(screenReaderText).toContain('Please wait');
31+
expect(screenReaderText).toContain('minutes before requesting another refresh');
32+
});
33+
34+
it('asserts custom alert dismiss button maintains focus outlines', () => {
35+
const dismissButton = {
36+
role: 'button',
37+
'aria-label': 'Dismiss rate limit warning',
38+
style: { outline: '2px solid transparent', ringColor: 'rgb(16, 185, 129)' },
39+
};
40+
41+
expect(dismissButton.role).toBe('button');
42+
expect(dismissButton['aria-label']).toBe('Dismiss rate limit warning');
43+
expect(dismissButton.style.ringColor).toBe('rgb(16, 185, 129)');
44+
});
45+
});

0 commit comments

Comments
 (0)