Skip to content

Commit 55eac99

Browse files
committed
Split the E2E utils class into smaller files.
1 parent 4fae2ad commit 55eac99

File tree

11 files changed

+158
-166
lines changed

11 files changed

+158
-166
lines changed

e2e/components/dialog/dialog.e2e.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
import {browser, by, element, Key} from 'protractor';
2-
import {E2EUtils} from '../../utils.e2e';
2+
import {expectToExist, expectFocusOn} from '../../util/asserts';
3+
import {pressKeys, clickElementAtPoint} from '../../util/actions';
4+
import {waitForElement} from '../../util/query';
35

46
describe('dialog', () => {
5-
const utils = new E2EUtils();
6-
77
beforeEach(() => browser.get('/dialog'));
88

99
it('should open a dialog', () => {
1010
element(by.id('default')).click();
11-
utils.expectToExist('md-dialog-container');
11+
expectToExist('md-dialog-container');
1212
});
1313

1414
it('should close by clicking on the backdrop', () => {
1515
element(by.id('default')).click();
1616

1717
waitForDialog().then(() => {
1818
clickOnBackrop();
19-
utils.expectToExist('md-dialog-container', false);
19+
expectToExist('md-dialog-container', false);
2020
});
2121
});
2222

2323
it('should close by pressing escape', () => {
2424
element(by.id('default')).click();
2525

2626
waitForDialog().then(() => {
27-
utils.pressKeys(Key.ESCAPE);
28-
utils.expectToExist('md-dialog-container', false);
27+
pressKeys(Key.ESCAPE);
28+
expectToExist('md-dialog-container', false);
2929
});
3030
});
3131

@@ -34,15 +34,15 @@ describe('dialog', () => {
3434

3535
waitForDialog().then(() => {
3636
element(by.id('close')).click();
37-
utils.expectToExist('md-dialog-container', false);
37+
expectToExist('md-dialog-container', false);
3838
});
3939
});
4040

4141
it('should focus the first focusable element', () => {
4242
element(by.id('default')).click();
4343

4444
waitForDialog().then(() => {
45-
utils.expectFocusOn('md-dialog-container input');
45+
expectFocusOn('md-dialog-container input');
4646
});
4747
});
4848

@@ -53,7 +53,7 @@ describe('dialog', () => {
5353

5454
waitForDialog().then(() => {
5555
clickOnBackrop();
56-
utils.expectFocusOn(openButton);
56+
expectFocusOn(openButton);
5757
});
5858
});
5959

@@ -63,8 +63,8 @@ describe('dialog', () => {
6363
waitForDialog().then(() => {
6464
let tab = Key.TAB;
6565

66-
utils.pressKeys(tab, tab, tab);
67-
utils.expectFocusOn('#close');
66+
pressKeys(tab, tab, tab);
67+
expectFocusOn('#close');
6868
});
6969
});
7070

@@ -73,24 +73,24 @@ describe('dialog', () => {
7373

7474
waitForDialog().then(() => {
7575
clickOnBackrop();
76-
utils.expectToExist('md-dialog-container');
76+
expectToExist('md-dialog-container');
7777
});
7878
});
7979

8080
it('should be able to prevent closing by pressing escape', () => {
8181
element(by.id('disabled')).click();
8282

8383
waitForDialog().then(() => {
84-
utils.pressKeys(Key.ESCAPE);
85-
utils.expectToExist('md-dialog-container');
84+
pressKeys(Key.ESCAPE);
85+
expectToExist('md-dialog-container');
8686
});
8787
});
8888

8989
function waitForDialog() {
90-
return utils.waitForElement('md-dialog-container');
90+
return waitForElement('md-dialog-container');
9191
}
9292

9393
function clickOnBackrop() {
94-
utils.clickElementAtPoint('.cdk-overlay-backdrop', { x: 0, y: 0 });
94+
clickElementAtPoint('.cdk-overlay-backdrop', { x: 0, y: 0 });
9595
}
9696
});
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import {browser} from 'protractor';
2-
import {E2EUtils} from '../../utils.e2e';
2+
import {expectToExist} from '../../util/asserts';
33

44
describe('grid-list', () => {
5-
const utils = new E2EUtils();
6-
75
beforeEach(() => browser.get('/grid-list'));
86

97
it('should render a grid list container', () => {
10-
utils.expectToExist('md-grid-list');
8+
expectToExist('md-grid-list');
119
});
1210

1311
it('should render list items inside the grid list container', () => {
14-
utils.expectToExist('md-grid-list md-grid-tile');
12+
expectToExist('md-grid-list md-grid-tile');
1513
});
1614
});

e2e/components/list/list.e2e.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import {browser} from 'protractor';
2-
import {E2EUtils} from '../../utils.e2e';
2+
import {expectToExist} from '../../util/asserts';
33

44
describe('list', () => {
5-
const utils = new E2EUtils();
6-
75
beforeEach(() => browser.get('/list'));
86

97
it('should render a list container', () => {
10-
utils.expectToExist('md-list');
8+
expectToExist('md-list');
119
});
1210

1311
it('should render list items inside the list container', () => {
14-
utils.expectToExist('md-list md-list-item');
12+
expectToExist('md-list md-list-item');
1513
});
1614
});

e2e/components/menu/menu.e2e.ts

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
import {browser, Key, protractor} from 'protractor';
2-
import {E2EUtils} from '../../utils.e2e';
32
import {MenuPage} from './menu-page';
3+
import {expectToExist, expectAlignedWith, expectFocusOn, expectLocation} from '../../util/asserts';
4+
import {pressKeys} from '../../util/actions';
45

56
describe('menu', () => {
67
const menuSelector = '.md-menu-panel';
7-
const utils = new E2EUtils();
88
let page: MenuPage;
99

1010
beforeEach(() => page = new MenuPage());
1111

1212
it('should open menu when the trigger is clicked', () => {
13-
utils.expectToExist(menuSelector, false);
13+
expectToExist(menuSelector, false);
1414
page.trigger().click();
1515

16-
utils.expectToExist(menuSelector);
16+
expectToExist(menuSelector);
1717
expect(page.menu().getText()).toEqual('One\nTwo\nThree\nFour');
1818
});
1919

2020
it('should close menu when menu item is clicked', () => {
2121
page.trigger().click();
2222
page.items(0).click();
23-
utils.expectToExist(menuSelector, false);
23+
expectToExist(menuSelector, false);
2424
});
2525

2626
it('should run click handlers on regular menu items', () => {
@@ -43,18 +43,18 @@ describe('menu', () => {
4343
page.triggerTwo().click();
4444

4545
expect(page.menu().getText()).toEqual('One\nTwo\nThree\nFour');
46-
utils.expectAlignedWith(page.menu(), '#trigger-two');
46+
expectAlignedWith(page.menu(), '#trigger-two');
4747

4848
page.backdrop().click();
49-
utils.expectToExist(menuSelector, false);
49+
expectToExist(menuSelector, false);
5050

5151
page.trigger().click();
5252

5353
expect(page.menu().getText()).toEqual('One\nTwo\nThree\nFour');
54-
utils.expectAlignedWith(page.menu(), '#trigger');
54+
expectAlignedWith(page.menu(), '#trigger');
5555

5656
page.backdrop().click();
57-
utils.expectToExist(menuSelector, false);
57+
expectToExist(menuSelector, false);
5858
});
5959

6060
it('should mirror classes on host to menu template in overlay', () => {
@@ -68,71 +68,71 @@ describe('menu', () => {
6868
beforeEach(() => {
6969
// click start button to avoid tabbing past navigation
7070
page.start().click();
71-
utils.pressKeys(Key.TAB);
71+
pressKeys(Key.TAB);
7272
});
7373

7474
it('should auto-focus the first item when opened with ENTER', () => {
75-
utils.pressKeys(Key.ENTER);
76-
utils.expectFocusOn(page.items(0));
75+
pressKeys(Key.ENTER);
76+
expectFocusOn(page.items(0));
7777
});
7878

7979
it('should auto-focus the first item when opened with SPACE', () => {
80-
utils.pressKeys(Key.SPACE);
81-
utils.expectFocusOn(page.items(0));
80+
pressKeys(Key.SPACE);
81+
expectFocusOn(page.items(0));
8282
});
8383

8484
it('should not focus the first item when opened with mouse', () => {
8585
page.trigger().click();
86-
utils.expectFocusOn(page.trigger());
86+
expectFocusOn(page.trigger());
8787
});
8888

8989
it('should focus subsequent items when down arrow is pressed', () => {
90-
utils.pressKeys(Key.ENTER, Key.DOWN);
91-
utils.expectFocusOn(page.items(1));
90+
pressKeys(Key.ENTER, Key.DOWN);
91+
expectFocusOn(page.items(1));
9292
});
9393

9494
it('should focus previous items when up arrow is pressed', () => {
95-
utils.pressKeys(Key.ENTER, Key.DOWN, Key.UP);
96-
utils.expectFocusOn(page.items(0));
95+
pressKeys(Key.ENTER, Key.DOWN, Key.UP);
96+
expectFocusOn(page.items(0));
9797
});
9898

9999
it('should skip disabled items using arrow keys', () => {
100-
utils.pressKeys(Key.ENTER, Key.DOWN, Key.DOWN);
101-
utils.expectFocusOn(page.items(3));
100+
pressKeys(Key.ENTER, Key.DOWN, Key.DOWN);
101+
expectFocusOn(page.items(3));
102102

103-
utils.pressKeys(Key.UP);
104-
utils.expectFocusOn(page.items(1));
103+
pressKeys(Key.UP);
104+
expectFocusOn(page.items(1));
105105
});
106106

107107
it('should close the menu when tabbing past items', () => {
108-
utils.pressKeys(Key.ENTER, Key.TAB);
109-
utils.expectToExist(menuSelector, false);
108+
pressKeys(Key.ENTER, Key.TAB);
109+
expectToExist(menuSelector, false);
110110

111-
utils.pressKeys(Key.TAB, Key.ENTER);
112-
utils.expectToExist(menuSelector);
111+
pressKeys(Key.TAB, Key.ENTER);
112+
expectToExist(menuSelector);
113113

114-
utils.pressKeys(protractor.Key.chord(Key.SHIFT, Key.TAB));
115-
utils.expectToExist(menuSelector, false);
114+
pressKeys(protractor.Key.chord(Key.SHIFT, Key.TAB));
115+
expectToExist(menuSelector, false);
116116
});
117117

118118
it('should wrap back to menu when arrow keying past items', () => {
119119
let down = Key.DOWN;
120-
utils.pressKeys(Key.ENTER, down, down, down);
121-
utils.expectFocusOn(page.items(0));
120+
pressKeys(Key.ENTER, down, down, down);
121+
expectFocusOn(page.items(0));
122122

123-
utils.pressKeys(Key.UP);
124-
utils.expectFocusOn(page.items(3));
123+
pressKeys(Key.UP);
124+
expectFocusOn(page.items(3));
125125
});
126126

127127
it('should focus before and after trigger when tabbing past items', () => {
128128
let shiftTab = protractor.Key.chord(Key.SHIFT, Key.TAB);
129129

130-
utils.pressKeys(Key.ENTER, Key.TAB);
131-
utils.expectFocusOn(page.triggerTwo());
130+
pressKeys(Key.ENTER, Key.TAB);
131+
expectFocusOn(page.triggerTwo());
132132

133133
// navigate back to trigger
134-
utils.pressKeys(shiftTab, Key.ENTER, shiftTab);
135-
utils.expectFocusOn(page.start());
134+
pressKeys(shiftTab, Key.ENTER, shiftTab);
135+
expectFocusOn(page.start());
136136
});
137137

138138
});
@@ -143,7 +143,7 @@ describe('menu', () => {
143143
page.trigger().click();
144144

145145
// menu.x should equal trigger.x, menu.y should equal trigger.y
146-
utils.expectAlignedWith(page.menu(), '#trigger');
146+
expectAlignedWith(page.menu(), '#trigger');
147147
});
148148

149149
it('should align overlay end to origin end when x-position is "before"', () => {
@@ -154,7 +154,7 @@ describe('menu', () => {
154154
// menu = 112px wide. trigger = 60px wide. 112 - 60 = 52px of menu to the left of trigger.
155155
// trigger.x (left corner) - 52px (menu left of trigger) = expected menu.x (left corner)
156156
// menu.y should equal trigger.y because only x position has changed.
157-
utils.expectLocation(page.beforeMenu(), {x: trigger.x - 52, y: trigger.y});
157+
expectLocation(page.beforeMenu(), {x: trigger.x - 52, y: trigger.y});
158158
});
159159
});
160160

@@ -166,7 +166,7 @@ describe('menu', () => {
166166
// menu.x should equal trigger.x because only y position has changed.
167167
// menu = 64px high. trigger = 20px high. 64 - 20 = 44px of menu extending up past trigger.
168168
// trigger.y (top corner) - 44px (menu above trigger) = expected menu.y (top corner)
169-
utils.expectLocation(page.aboveMenu(), {x: trigger.x, y: trigger.y - 44});
169+
expectLocation(page.aboveMenu(), {x: trigger.x, y: trigger.y - 44});
170170
});
171171
});
172172

@@ -176,7 +176,7 @@ describe('menu', () => {
176176

177177
// trigger.x (left corner) - 52px (menu left of trigger) = expected menu.x
178178
// trigger.y (top corner) - 44px (menu above trigger) = expected menu.y
179-
utils.expectLocation(page.combinedMenu(), {x: trigger.x - 52, y: trigger.y - 44});
179+
expectLocation(page.combinedMenu(), {x: trigger.x - 52, y: trigger.y - 44});
180180
});
181181
});
182182

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
import {browser} from 'protractor';
2-
import {E2EUtils} from '../../utils.e2e';
2+
import {expectToExist} from '../../util/asserts';
33

44
describe('progress-bar', () => {
5-
const utils = new E2EUtils();
6-
75
beforeEach(() => browser.get('/progress-bar'));
86

97
it('should render a determinate progress bar', () => {
10-
utils.expectToExist('md-progress-bar[mode="determinate"]');
8+
expectToExist('md-progress-bar[mode="determinate"]');
119
});
1210

1311
it('should render a buffer progress bar', () => {
14-
utils.expectToExist('md-progress-bar[mode="buffer"]');
12+
expectToExist('md-progress-bar[mode="buffer"]');
1513
});
1614

1715
it('should render a query progress bar', () => {
18-
utils.expectToExist('md-progress-bar[mode="query"]');
16+
expectToExist('md-progress-bar[mode="query"]');
1917
});
2018

2119
it('should render a indeterminate progress bar', () => {
22-
utils.expectToExist('md-progress-bar[mode="indeterminate"]');
20+
expectToExist('md-progress-bar[mode="indeterminate"]');
2321
});
2422
});

e2e/components/slide-toggle/slide-toggle.e2e.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import {browser, element, by, Key} from 'protractor';
2-
import {E2EUtils} from '../../utils.e2e';
2+
import {expectToExist} from '../../util/asserts';
33

44
describe('slide-toggle', () => {
5-
const utils = new E2EUtils();
65
const getInput = () => element(by.css('#normal-slide-toggle input'));
76
const getNormalToggle = () => element(by.css('#normal-slide-toggle'));
87

98
beforeEach(() => browser.get('slide-toggle'));
109

1110
it('should render a slide-toggle', () => {
12-
utils.expectToExist('md-slide-toggle');
11+
expectToExist('md-slide-toggle');
1312
});
1413

1514
it('should change the checked state on click', () => {

0 commit comments

Comments
 (0)