/
modal-stack-confirmation.e2e-spec.ts
71 lines (51 loc) · 2.38 KB
/
modal-stack-confirmation.e2e-spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import {expectNoOpenModals, openUrl, sendKey} from '../../tools.po';
import {ModalStackConfirmationPage} from './modal-stack-confirmation.po';
import {Key} from 'protractor';
describe('Modal stacked with confirmation', () => {
let page: ModalStackConfirmationPage;
beforeAll(() => { page = new ModalStackConfirmationPage(); });
beforeEach(async() => await openUrl('modal/stack-confirmation'));
afterEach(async() => { await expectNoOpenModals(); });
it('should close modals correctly using close button', async() => {
await page.openModal();
// close with button
await page.getModalClose().click();
expect(await page.getOpenModals().count()).toBe(2, 'Confirmation modal should be opened');
// cancel closure with button
await page.getDismissalButton().click();
expect(await page.getOpenModals().count()).toBe(1, 'Confirmation modal should be dismissed');
// close again
await page.getModalClose().click();
expect(await page.getOpenModals().count()).toBe(2, 'Confirmation modal should be re-opened');
// close all modals
await page.getConfirmationButton().click();
});
it('should close modals correctly using ESC', async() => {
await page.openModal();
// close with Escape
await sendKey(Key.ESCAPE);
expect(await page.getOpenModals().count()).toBe(2, 'Confirmation modal should be opened');
// cancel closure with Escape
await sendKey(Key.ESCAPE);
expect(await page.getOpenModals().count()).toBe(1, 'Confirmation modal should be dismissed');
// close again
await sendKey(Key.ESCAPE);
expect(await page.getOpenModals().count()).toBe(2, 'Confirmation modal should be re-opened');
// close all modals
await page.getConfirmationButton().click();
});
it('should close modals correctly using backdrop click', async() => {
await page.openModal();
// close with click
await page.getModal(0).click();
expect(await page.getOpenModals().count()).toBe(2, 'Confirmation modal should be opened');
// cancel closure with click
await page.getModal(1).click();
expect(await page.getOpenModals().count()).toBe(1, 'Confirmation modal should be dismissed');
// close again
await page.getModal(0).click();
expect(await page.getOpenModals().count()).toBe(2, 'Confirmation modal should be re-opened');
// close all modals
await page.getConfirmationButton().click();
});
});