-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathdashboard.e2e-spec.ts
131 lines (100 loc) · 5.03 KB
/
dashboard.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import {browser, by, element, protractor} from 'protractor';
/**
* Dashboard tests.
*
* End 2 End Protractor tests (using Jasmine) for testing Dashboard screen.
* See: http://www.protractortest.org/#/tutorial
*
* TODO - Use by.repeater()/model() instead of by.css() once Angular implement it for lists:
* https://angular.io/docs/ts/latest/guide/upgrade.html
* https://github.com/angular/protractor/issues/3205
*
* @author gazbert
*/
describe('Dashboard Tests', function () {
const WAIT_TIMEOUT = 300000;
const expectedMsg = 'BX-bot Admin Console';
beforeEach(function () {
browser.get('');
});
it('should redirect Dashboard if user does not enter a URL path', function () {
browser.getCurrentUrl().then(function (url) {
// https://stackoverflow.com/questions/28464604/more-than-one-element-found-for-locator-warning
const EC = protractor.ExpectedConditions;
const dashboard = element(by.id('dashboard-grid'));
browser.wait(EC.visibilityOf(dashboard), WAIT_TIMEOUT);
expect(url).toContain('/dashboard');
});
});
it('should display browser title: ' + expectedMsg, function () {
expect(browser.getTitle()).toEqual(expectedMsg);
});
it('should display Admin Console heading name: ' + expectedMsg, function () {
expect(element(by.css('h1')).getText()).toEqual(expectedMsg);
});
it('should display 8 Dashboard Bot items', function () {
// TODO below does not work with Angular2 :-(
// https://github.com/angular/protractor/issues/3205
// const dashboardItems = element.all(by.repeater('bot in bots'));
// so we'll resort to CSS locator instead
const dashboardItems = element.all(by.css('app-bxbot-ui-dashboard-item'));
// https://stackoverflow.com/questions/28464604/more-than-one-element-found-for-locator-warning
const EC = protractor.ExpectedConditions;
const dashboard = element(by.id('dashboard-grid'));
browser.wait(EC.visibilityOf(dashboard), WAIT_TIMEOUT);
expect(dashboardItems.count()).toBe(8);
});
it('should display Bitstamp as first Dashboard Bot item', function () {
const dashboardItems = element.all(by.css('app-bxbot-ui-dashboard-item'));
// https://stackoverflow.com/questions/28464604/more-than-one-element-found-for-locator-warning
const EC = protractor.ExpectedConditions;
const dashboard = element(by.id('dashboard-grid'));
browser.wait(EC.visibilityOf(dashboard), WAIT_TIMEOUT);
expect(dashboardItems.get(0).getText()).toContain('Bitstamp Bot');
});
it('should display Kraken as last Dashboard Bot item', function () {
const dashboardItems = element.all(by.css('app-bxbot-ui-dashboard-item'));
expect(dashboardItems.get(7).getText()).toContain('Kraken Bot');
});
it('should render Gemini Bot specific link', function () {
const dashboardItems = element.all(by.css('app-bxbot-ui-dashboard-item'));
// https://stackoverflow.com/questions/28464604/more-than-one-element-found-for-locator-warning
const EC = protractor.ExpectedConditions;
const dashboard = element(by.id('dashboard-grid'));
browser.wait(EC.visibilityOf(dashboard), WAIT_TIMEOUT);
dashboardItems.get(2).click().then(() =>
browser.getCurrentUrl().then(function (url) {
expect(url).toContain('/bot/gemini-1');
}));
});
it('should stay on Dashboard if user clicks on Dashboard button', function () {
browser.getCurrentUrl().then(function (url) {
const dashboardButton = element.all(by.css('dashboardButton'));
dashboardButton.click();
expect(url).toContain('/dashboard');
});
});
it('should filter displayed Bot items when user searches by Bot name', function () {
const dashboardItems = element.all(by.css('app-bxbot-ui-dashboard-item'));
// https://stackoverflow.com/questions/28464604/more-than-one-element-found-for-locator-warning
const EC = protractor.ExpectedConditions;
const dashboard = element(by.id('dashboard-grid'));
browser.wait(EC.visibilityOf(dashboard), WAIT_TIMEOUT);
expect(dashboardItems.count()).toBe(8);
const searchBox = element.all(by.id('search-box'));
searchBox.sendKeys('Bit');
expect(dashboardItems.count()).toBe(3);
expect(dashboardItems.get(0).getText()).toContain('Bitstamp');
expect(dashboardItems.get(1).getText()).toContain('ItBit');
expect(dashboardItems.get(2).getText()).toContain('Bitfinex');
searchBox.clear();
searchBox.sendKeys('Ok');
expect(dashboardItems.count()).toBe(1);
expect(dashboardItems.get(0).getText()).toContain('OKCoin');
searchBox.clear();
searchBox.sendKeys('G');
expect(dashboardItems.count()).toBe(2);
expect(dashboardItems.get(0).getText()).toContain('GDAX');
expect(dashboardItems.get(1).getText()).toContain('Gemini');
});
});