Skip to content

Commit d913f13

Browse files
committed
test(alert): fix a11y test to use new aria-labelledby values
1 parent 5afe018 commit d913f13

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

core/src/components/alert/test/a11y/alert.e2e.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,24 @@ configs({ directions: ['ltr'] }).forEach(({ config, title }) => {
124124
await page.goto(`/src/components/alert/test/a11y`, config);
125125
});
126126

127-
test('should have aria-labelledby when header is set', async ({ page }) => {
128-
await testAria(page, 'noMessage', 'alert-1-hdr', null);
127+
test('should have aria-labelledby set to both when header and subHeader are set', async ({ page }) => {
128+
await testAria(page, 'bothHeadersOnly', 'alert-1-hdr alert-1-sub-hdr', null);
129+
});
130+
131+
test('should have aria-labelledby set when only header is set', async ({ page }) => {
132+
await testAria(page, 'headerOnly', 'alert-1-hdr', null);
133+
});
134+
135+
test('should fall back to subHeader for aria-labelledby if header is not defined', async ({ page }) => {
136+
await testAria(page, 'subHeaderOnly', 'alert-1-sub-hdr', null);
129137
});
130138

131139
test('should have aria-describedby when message is set', async ({ page }) => {
132140
await testAria(page, 'noHeaders', null, 'alert-1-msg');
133141
});
134142

135-
test('should fall back to subHeader for aria-labelledby if header is not defined', async ({ page }) => {
136-
await testAria(page, 'subHeaderOnly', 'alert-1-sub-hdr', 'alert-1-msg');
143+
test('should have aria-labelledby and aria-describedby when headers and message are set', async ({ page }) => {
144+
await testAria(page, 'headersAndMessage', 'alert-1-hdr alert-1-sub-hdr', 'alert-1-msg');
137145
});
138146

139147
test('should allow for manually specifying aria attributes', async ({ page }) => {

core/src/components/alert/test/a11y/index.html

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919
<main class="ion-padding">
2020
<h1>Alert - A11y</h1>
2121

22-
<button class="expand" id="bothHeaders" onclick="presentBothHeaders()">Both Headers</button>
22+
<button class="expand" id="bothHeadersOnly" onclick="presentBothHeadersOnly()">Both Headers Only</button>
23+
<button class="expand" id="headerOnly" onclick="presentHeaderOnly()">Header Only</button>
2324
<button class="expand" id="subHeaderOnly" onclick="presentSubHeaderOnly()">Subheader Only</button>
2425
<button class="expand" id="noHeaders" onclick="presentNoHeaders()">No Headers</button>
25-
<button class="expand" id="noMessage" onclick="presentNoMessage()">No Message</button>
26+
<button class="expand" id="headersAndMessage" onclick="presentHeadersAndMessage()">Headers and Message</button>
2627
<button class="expand" id="customAria" onclick="presentCustomAria()">Custom Aria</button>
2728
<button class="expand" id="ariaLabelButton" onclick="presentAriaLabelButton()">Aria Label Button</button>
2829
<button class="expand" id="checkbox" onclick="presentAlertCheckbox()">Checkbox</button>
@@ -34,19 +35,24 @@ <h1>Alert - A11y</h1>
3435
await alert.present();
3536
}
3637

37-
function presentBothHeaders() {
38+
function presentBothHeadersOnly() {
3839
openAlert({
3940
header: 'Header',
4041
subHeader: 'Subtitle',
41-
message: 'This is an alert message.',
42+
buttons: ['OK'],
43+
});
44+
}
45+
46+
function presentHeaderOnly() {
47+
openAlert({
48+
header: 'Header',
4249
buttons: ['OK'],
4350
});
4451
}
4552

4653
function presentSubHeaderOnly() {
4754
openAlert({
4855
subHeader: 'Subtitle',
49-
message: 'This is an alert message.',
5056
buttons: ['OK'],
5157
});
5258
}
@@ -58,10 +64,11 @@ <h1>Alert - A11y</h1>
5864
});
5965
}
6066

61-
function presentNoMessage() {
67+
function presentHeadersAndMessage() {
6268
openAlert({
6369
header: 'Header',
6470
subHeader: 'Subtitle',
71+
message: 'This is an alert message.',
6572
buttons: ['OK'],
6673
});
6774
}

0 commit comments

Comments
 (0)