-
Notifications
You must be signed in to change notification settings - Fork 20
/
bot-details.e2e-spec.ts
185 lines (139 loc) · 8.1 KB
/
bot-details.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
import {browser, element, by, protractor} from 'protractor';
/**
* Bot Details screen tests.
*
* End 2 End Protractor tests (using Jasmine) for testing Bot Details 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('Bot Details Tests', function () {
const WAIT_TIMEOUT = 300000;
beforeEach(function () {
browser.get('');
});
it('should render GDAX Bot Details tab links', 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(1).click();
expect(element(by.css('h2')).getText()).toEqual('GDAX Bot Details');
const tabLinks = element.all(by.css('li'));
expect(tabLinks.count()).toBe(5);
expect(tabLinks.first().getText()).toEqual('Engine');
expect(tabLinks.get(1).getText()).toEqual('Exchange');
expect(tabLinks.get(2).getText()).toEqual('Markets');
expect(tabLinks.get(3).getText()).toEqual('Strategies');
expect(tabLinks.last().getText()).toEqual('Email Alerts');
const tabItems = element.all(by.css('app-bxbot-ui-tab'));
expect(tabItems.count()).toBe(5);
});
it('should render GDAX Engine Details', function () {
const dashboardItems = element.all(by.css('app-bxbot-ui-dashboard-item'));
const EC = protractor.ExpectedConditions;
const dashboard = element(by.id('dashboard-grid'));
browser.wait(EC.visibilityOf(dashboard), WAIT_TIMEOUT);
dashboardItems.get(1).click();
expect(element(by.css('h2')).getText()).toEqual('GDAX Bot Details');
expect(element(by.id('botId')).getAttribute('value')).toBe('gdax-1');
expect(element(by.id('botName')).getAttribute('value')).toBe('GDAX Bot');
expect(element(by.id('tradeCycleInterval')).getAttribute('value')).toBe('10');
expect(element(by.id('emergencyStopCurrency')).getAttribute('value')).toBe('BTC');
expect(element(by.id('emergencyStopBalance')).getAttribute('value')).toBe('0.8');
});
it('should render GDAX Exchange Details', function () {
const dashboardItems = element.all(by.css('app-bxbot-ui-dashboard-item'));
const EC = protractor.ExpectedConditions;
const dashboard = element(by.id('dashboard-grid'));
browser.wait(EC.visibilityOf(dashboard), WAIT_TIMEOUT);
dashboardItems.get(1).click();
expect(element(by.css('h2')).getText()).toEqual('GDAX Bot Details');
const tabLinks = element.all(by.css('li'));
tabLinks.get(1).click();
expect(element(by.id('exchangeName')).getAttribute('value')).toBe('GDAX');
expect(element(by.id('adapterClass')).getAttribute('value')).toBe('com.gazbert.bxbot.exchanges.GdaxExchangeAdapter');
expect(element(by.id('connectionTimeout')).getAttribute('value')).toBe('120');
expect(element(by.id('errorCode_0')).getAttribute('value')).toBe('503');
expect(element(by.id('errorCode_1')).getAttribute('value')).toBe('522');
expect(element(by.id('errorMessage_0')).getAttribute('value')).toBe('Connection reset');
expect(element(by.id('errorMessage_1')).getAttribute('value')).toBe('Connection refused');
});
it('should render GDAX Markets', function () {
const dashboardItems = element.all(by.css('app-bxbot-ui-dashboard-item'));
const EC = protractor.ExpectedConditions;
const dashboard = element(by.id('dashboard-grid'));
browser.wait(EC.visibilityOf(dashboard), WAIT_TIMEOUT);
dashboardItems.get(1).click();
expect(element(by.css('h2')).getText()).toEqual('GDAX Bot Details');
const tabLinks = element.all(by.css('li'));
tabLinks.get(2).click();
// Market 1
expect(element(by.id('marketEnabled_0')).getAttribute('ng-reflect-model')).toBe('false'); // must be better way?
expect(element(by.id('marketName_0')).getAttribute('value')).toBe('BTC/USD');
expect(element(by.id('baseCurrency_0')).getAttribute('value')).toBe('BTC');
expect(element(by.id('counterCurrency_0')).getAttribute('value')).toBe('USD');
expect(element(by.id('strategy_0')).getAttribute('value')).toBe('1: EMA Indicator');
// Market 2
expect(element(by.id('marketEnabled_1')).getAttribute('ng-reflect-model')).toBe('true');
expect(element(by.id('marketName_1')).getAttribute('value')).toBe('BTC/GBP');
expect(element(by.id('baseCurrency_1')).getAttribute('value')).toBe('BTC');
expect(element(by.id('counterCurrency_1')).getAttribute('value')).toBe('GBP');
expect(element(by.id('strategy_1')).getAttribute('value')).toBe('0: Long Scalper');
});
it('should render GDAX Strategies', function () {
const dashboardItems = element.all(by.css('app-bxbot-ui-dashboard-item'));
const EC = protractor.ExpectedConditions;
const dashboard = element(by.id('dashboard-grid'));
browser.wait(EC.visibilityOf(dashboard), WAIT_TIMEOUT);
dashboardItems.get(1).click();
expect(element(by.css('h2')).getText()).toEqual('GDAX Bot Details');
const tabLinks = element.all(by.css('li'));
tabLinks.get(3).click();
// Strat 1
expect(element(by.id('strategyName_0')).getAttribute('value')).toBe('Long Scalper');
expect(element(by.id('strategyDescription_0')).getAttribute('value'))
.toBe('Scalping strategy that buys low and sells high.');
expect(element(by.id('strategyClassname_0')).getAttribute('value'))
.toBe('com.gazbert.bxbot.strategies.LongScalperStrategy');
// Strat 2
expect(element(by.id('strategyName_1')).getAttribute('value')).toBe('EMA Indicator');
expect(element(by.id('strategyDescription_1')).getAttribute('value'))
.toBe('EMA Indicator algo for deciding when to enter and exit trades.');
expect(element(by.id('strategyClassname_1')).getAttribute('value'))
.toBe('com.gazbert.bxbot.strategies.EmaStrategy');
});
it('should render GDAX Email Alerts Config', function () {
const dashboardItems = element.all(by.css('app-bxbot-ui-dashboard-item'));
const EC = protractor.ExpectedConditions;
const dashboard = element(by.id('dashboard-grid'));
browser.wait(EC.visibilityOf(dashboard), WAIT_TIMEOUT);
dashboardItems.get(1).click();
expect(element(by.css('h2')).getText()).toEqual('GDAX Bot Details');
const tabLinks = element.all(by.css('li'));
tabLinks.get(4).click();
expect(element(by.id('alertsEnabled')).getAttribute('value')).toBe('on');
expect(element(by.id('accountUsername')).getAttribute('value')).toBe('solo');
expect(element(by.id('accountPassword')).getAttribute('value')).toBe('NeverTellMeTheOdds_');
expect(element(by.id('toAddress')).getAttribute('value')).toBe('lando@cloudcity.space');
expect(element(by.id('fromAddress')).getAttribute('value')).toBe('han.solo@falcon.space');
});
it('should navigate to Dashboard if user clicks on Dashboard button', function () {
browser.getCurrentUrl().then(function (url) {
const dashboardItems = element.all(by.css('app-bxbot-ui-dashboard-item'));
const EC = protractor.ExpectedConditions;
const dashboard = element(by.id('dashboard-grid'));
browser.wait(EC.visibilityOf(dashboard), WAIT_TIMEOUT);
dashboardItems.get(1).click();
expect(element(by.css('h2')).getText()).toEqual('GDAX Bot Details');
const dashboardButton = element.all(by.css('dashboardButton'));
dashboardButton.click();
expect(url).toContain('/dashboard');
});
});
});