Skip to content

Commit 10a7d53

Browse files
committed
rewrite test
1 parent b45b9e1 commit 10a7d53

File tree

1 file changed

+24
-28
lines changed
  • e2e/testcafe-devextreme/tests/scheduler/common/keyboardNavigation

1 file changed

+24
-28
lines changed

e2e/testcafe-devextreme/tests/scheduler/common/keyboardNavigation/appointments.ts

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,27 @@ import Scheduler from 'devextreme-testcafe-models/scheduler';
22
import { ClientFunction } from 'testcafe';
33
import url from '../../../../helpers/getPageUrl';
44
import { createWidget } from '../../../../helpers/createWidget';
5+
import { getDocumentScrollTop } from '../../../../helpers/domUtils';
56

67
fixture.disablePageReloads`KeyboardNavigation.Appointments`
78
.page(url(__dirname, '../../../container.html'));
89

9-
const PARENT_SELECTOR = '#parentContainer';
1010
const SCHEDULER_SELECTOR = '#container';
1111

1212
test('Document should not scroll on \'End\' press when appointment is focused', async (t) => {
1313
const scheduler = new Scheduler(SCHEDULER_SELECTOR);
1414

15-
await t
16-
.click(scheduler.getAppointment('Appointment 1').element)
17-
.pressKey('End');
15+
await t.click(scheduler.getAppointment('Appointment 1').element);
1816

19-
const scrollTop = await ClientFunction(() => document.documentElement.scrollTop)();
17+
const expectedScrollTop = await getDocumentScrollTop();
2018

21-
await t.expect(scrollTop).eql(0);
19+
await t
20+
.pressKey('End')
21+
.expect(getDocumentScrollTop()).eql(expectedScrollTop);
2222
}).before(async () => {
23-
ClientFunction((selector) => {
24-
const parent = document.querySelector(selector) as HTMLElement;
25-
parent.style.height = '2000px';
26-
})(PARENT_SELECTOR);
23+
await ClientFunction(() => {
24+
document.body.style.height = '2000px';
25+
})();
2726

2827
await createWidget('dxScheduler', {
2928
dataSource: [
@@ -48,29 +47,27 @@ test('Document should not scroll on \'End\' press when appointment is focused',
4847
currentDate: new Date(2015, 1, 9),
4948
});
5049
}).after(async () => {
51-
ClientFunction((selector) => {
52-
const parent = document.querySelector(selector) as HTMLElement;
53-
parent.style.height = '';
54-
})(PARENT_SELECTOR);
50+
await ClientFunction(() => {
51+
document.body.style.height = '';
52+
})();
5553
});
5654

5755
test('Document should not scroll on \'Home\' press when appointment is focused', async (t) => {
5856
const scheduler = new Scheduler(SCHEDULER_SELECTOR);
59-
const initialScrollTop = 100;
6057

6158
await t
62-
.scroll(0, initialScrollTop)
63-
.click(scheduler.getAppointment('Appointment 1').element)
64-
.pressKey('Home');
59+
.scroll(0, 100)
60+
.click(scheduler.getAppointment('Appointment 1').element);
6561

66-
const scrollTop = await ClientFunction(() => document.documentElement.scrollTop)();
62+
const expectedScrollTop = await getDocumentScrollTop();
6763

68-
await t.expect(scrollTop).eql(initialScrollTop);
64+
await t
65+
.pressKey('Home')
66+
.expect(getDocumentScrollTop()).eql(expectedScrollTop);
6967
}).before(async () => {
70-
ClientFunction((selector) => {
71-
const parent = document.querySelector(selector) as HTMLElement;
72-
parent.style.height = '2000px';
73-
})(PARENT_SELECTOR);
68+
await ClientFunction(() => {
69+
document.body.style.height = '2000px';
70+
})();
7471

7572
await createWidget('dxScheduler', {
7673
dataSource: [
@@ -95,8 +92,7 @@ test('Document should not scroll on \'Home\' press when appointment is focused',
9592
currentDate: new Date(2015, 1, 9),
9693
});
9794
}).after(async () => {
98-
ClientFunction((selector) => {
99-
const parent = document.querySelector(selector) as HTMLElement;
100-
parent.style.height = '';
101-
})(PARENT_SELECTOR);
95+
await ClientFunction(() => {
96+
document.body.style.height = '';
97+
})();
10298
});

0 commit comments

Comments
 (0)