Skip to content

Commit e82ee2a

Browse files
authored
Improve appointment accessibility (DevExpress#29649)
Co-authored-by: Vladimir Bushmanov <[email protected]>
1 parent d8d082e commit e82ee2a

File tree

15 files changed

+517
-269
lines changed

15 files changed

+517
-269
lines changed

e2e/testcafe-devextreme/tests/scheduler/common/a11y/appointment.ts

Lines changed: 60 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -7,49 +7,54 @@ import { checkOptions } from './axe_options';
77
fixture.disablePageReloads`a11y - appointment`
88
.page(url(__dirname, '../../../container.html'));
99

10+
const appointmentItem = {
11+
text: 'App 1',
12+
startDate: Date.UTC(2021, 1, 1, 12),
13+
endDate: Date.UTC(2021, 1, 1, 13),
14+
};
15+
const currentDate = Date.UTC(2021, 1, 1);
16+
1017
['month', 'week', 'day'].forEach((currentView) => {
11-
test(`appointment should have correct aria-label without grouping (${currentView})`, async (t) => {
18+
test(`appointment should have correct aria-label without description (${currentView})`, async (t) => {
1219
const scheduler = new Scheduler('#container');
20+
const appointment = scheduler.getAppointment('App 1');
1321

1422
await t
15-
.expect(
16-
scheduler.getAppointment('App 1').element.attributes['aria-label'],
17-
)
18-
.eql(undefined);
23+
.expect(appointment.getAriaLabel())
24+
.eql('App 1: February 1, 2021, 12:00 PM - 1:00 PM')
25+
.expect(await appointment.hasAriaDescription())
26+
.notOk();
1927

2028
await a11yCheck(t, checkOptions, '#container');
2129
}).before(async () => {
2230
await createWidget('dxScheduler', {
23-
dataSource: [{
24-
text: 'App 1',
25-
startDate: new Date(2021, 1, 1, 12),
26-
endDate: new Date(2021, 1, 1, 13),
27-
}],
31+
timeZone: 'UTC',
32+
dataSource: [appointmentItem],
2833
currentView,
29-
currentDate: new Date(2021, 1, 1),
34+
currentDate,
3035
});
3136
});
3237

3338
test(`appointment should have correct aria-label with one group (${currentView})`, async (t) => {
3439
const scheduler = new Scheduler('#container');
35-
36-
const attrs = await scheduler.getAppointment('App 1').element.attributes;
40+
const appointment = scheduler.getAppointment('App 1');
3741

3842
await t
39-
.expect(attrs['aria-roledescription'])
40-
.eql('February 1, 2021, Group: resource1, ');
43+
.expect(appointment.getAriaLabel())
44+
.eql('App 1: February 1, 2021, 12:00 PM - 1:00 PM')
45+
.expect(await appointment.getAriaDescription())
46+
.eql('Group: resource1; Group 1: resource1');
4147

4248
await a11yCheck(t, checkOptions, '#container');
4349
}).before(async () => {
4450
await createWidget('dxScheduler', {
51+
timeZone: 'UTC',
4552
dataSource: [{
46-
text: 'App 1',
47-
startDate: new Date(2021, 1, 1, 12),
48-
endDate: new Date(2021, 1, 1, 13),
53+
...appointmentItem,
4954
groupId: 1,
5055
}],
5156
currentView,
52-
currentDate: new Date(2021, 1, 1),
57+
currentDate,
5358
groups: ['groupId'],
5459
resources: [
5560
{
@@ -58,32 +63,33 @@ fixture.disablePageReloads`a11y - appointment`
5863
text: 'resource1',
5964
id: 1,
6065
}],
66+
label: 'Group 1',
6167
},
6268
],
6369
});
6470
});
6571

6672
test(`appointment should have correct aria-label with multiple group (${currentView})`, async (t) => {
6773
const scheduler = new Scheduler('#container');
68-
69-
const attrs = await scheduler.getAppointment('App 1').element.attributes;
74+
const appointment = scheduler.getAppointment('App 1');
7075

7176
await t
72-
.expect(attrs['aria-roledescription'])
73-
.eql('February 1, 2021, Group: resource11, resource21, ');
77+
.expect(appointment.getAriaLabel())
78+
.eql('App 1: February 1, 2021, 12:00 PM - 1:00 PM')
79+
.expect(await appointment.getAriaDescription())
80+
.eql('Group: resource11, resource21; Group 1: resource11; Group 2: resource21, resource22');
7481

7582
await a11yCheck(t, checkOptions, '#container');
7683
}).before(async () => {
7784
await createWidget('dxScheduler', {
85+
timeZone: 'UTC',
7886
dataSource: [{
79-
text: 'App 1',
80-
startDate: new Date(2021, 1, 1, 12),
81-
endDate: new Date(2021, 1, 1, 13),
87+
...appointmentItem,
8288
groupId1: 1,
83-
groupId2: 1,
89+
groupId2: [1, 2],
8490
}],
8591
currentView,
86-
currentDate: new Date(2021, 1, 1),
92+
currentDate,
8793
groups: ['groupId1', 'groupId2'],
8894
resources: [
8995
{
@@ -92,13 +98,18 @@ fixture.disablePageReloads`a11y - appointment`
9298
text: 'resource11',
9399
id: 1,
94100
}],
101+
label: 'Group 1',
95102
},
96103
{
97104
fieldExpr: 'groupId2',
98105
dataSource: [{
99106
text: 'resource21',
100107
id: 1,
108+
}, {
109+
text: 'resource22',
110+
id: 2,
101111
}],
112+
label: 'Group 2',
102113
},
103114
],
104115
});
@@ -125,23 +136,18 @@ fixture.disablePageReloads`a11y - appointment`
125136
},
126137
],
127138
currentView,
128-
currentDate: new Date(2021, 3, 29),
139+
currentDate: new Date('2021-04-29T18:30:00.000Z'),
129140
startDayHour: 9,
130141
});
131142
});
132143

133144
test('appointments should have right role', async (t) => {
134145
const scheduler = new Scheduler('#container');
135146
const appt = scheduler.getAppointment('Website Re-Design Plan');
136-
const contentId = await appt.element.find('.dx-scheduler-appointment-content').getAttribute('id');
137147

138148
await t
139149
.expect(appt.element.getAttribute('role'))
140-
.eql('application');
141-
142-
await t
143-
.expect(appt.element.getAttribute('aria-describedby'))
144-
.eql(contentId);
150+
.eql('button');
145151

146152
await t
147153
.expect(appt.element.getAttribute('aria-activedescendant'))
@@ -159,7 +165,7 @@ fixture.disablePageReloads`a11y - appointment`
159165
},
160166
],
161167
currentView,
162-
currentDate: new Date(2021, 3, 29),
168+
currentDate: new Date('2021-04-29T18:30:00.000Z'),
163169
startDayHour: 9,
164170
});
165171
});
@@ -168,22 +174,22 @@ fixture.disablePageReloads`a11y - appointment`
168174
[
169175
{
170176
currentView: 'week',
171-
startDate: new Date(2021, 1, 1, 12),
172-
endDate: new Date(2021, 1, 3, 13),
177+
startDate: Date.UTC(2021, 1, 1, 12),
178+
endDate: Date.UTC(2021, 1, 3, 13),
173179
labels: [
174-
'February 1, 2021 - February 3, 2021 (1/3), ',
175-
'February 1, 2021 - February 3, 2021 (2/3), ',
176-
'February 1, 2021 - February 3, 2021 (3/3), ',
180+
'App 1: February 1, 2021, 12:00 PM - February 3, 2021, 1:00 PM (1/3)',
181+
'App 1: February 1, 2021, 12:00 PM - February 3, 2021, 1:00 PM (2/3)',
182+
'App 1: February 1, 2021, 12:00 PM - February 3, 2021, 1:00 PM (3/3)',
177183
],
178184
},
179185
{
180186
currentView: 'month',
181-
startDate: new Date(2021, 1, 1, 12),
182-
endDate: new Date(2021, 1, 17, 13),
187+
startDate: Date.UTC(2021, 1, 1, 12),
188+
endDate: Date.UTC(2021, 1, 17, 13),
183189
labels: [
184-
'February 1, 2021 - February 17, 2021 (1/3), ',
185-
'February 1, 2021 - February 17, 2021 (2/3), ',
186-
'February 1, 2021 - February 17, 2021 (3/3), ',
190+
'App 1: February 1, 2021, 12:00 PM - February 17, 2021, 1:00 PM (1/3)',
191+
'App 1: February 1, 2021, 12:00 PM - February 17, 2021, 1:00 PM (2/3)',
192+
'App 1: February 1, 2021, 12:00 PM - February 17, 2021, 1:00 PM (3/3)',
187193
],
188194
},
189195
].forEach(({
@@ -193,10 +199,9 @@ fixture.disablePageReloads`a11y - appointment`
193199
const scheduler = new Scheduler('#container');
194200

195201
const apptLabels = await Promise.all([0, 1, 2].map(
196-
async (i) => {
197-
const appt = scheduler.getAppointment('App 1', i);
198-
const attrs = await appt.element.attributes;
199-
return attrs['aria-roledescription'];
202+
(i) => {
203+
const appointment = scheduler.getAppointment('App 1', i);
204+
return appointment.getAriaLabel();
200205
},
201206
));
202207

@@ -207,14 +212,15 @@ fixture.disablePageReloads`a11y - appointment`
207212
await a11yCheck(t, checkOptions, '#container');
208213
}).before(async () => {
209214
await createWidget('dxScheduler', {
215+
timeZone: 'UTC',
210216
dataSource: [{
211217
text: 'App 1',
212218
startDate,
213219
endDate,
214220
}],
215221
allDayPanelMode: 'hidden',
216222
currentView,
217-
currentDate: new Date(2021, 1, 1),
223+
currentDate: Date.UTC(2021, 1, 1),
218224
});
219225
});
220226
});
@@ -409,11 +415,11 @@ test('Scheduler a11y: Appointment collector button doesn\'t have info about date
409415

410416
test('appointment aria label should contain date with right timezone', async (t) => {
411417
const scheduler = new Scheduler('#container');
412-
const appt = scheduler.getAppointmentByIndex(0);
418+
const appointment = scheduler.getAppointmentByIndex(0);
413419

414420
await t
415-
.expect(appt.element.getAttribute('aria-roledescription'))
416-
.eql('March 29, 2021, ');
421+
.expect(appointment.getAriaLabel())
422+
.eql('Install New Router in Dev Room: March 29, 2021, 2:30 PM - 3:30 PM');
417423

418424
await a11yCheck(t, checkOptions, '#container');
419425
}).before(async () => {

0 commit comments

Comments
 (0)