This repository has been archived by the owner on Mar 31, 2024. It is now read-only.
forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsettings_page.js
344 lines (298 loc) · 10.8 KB
/
settings_page.js
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
// in test/support/pages/settings_page.js
define(function (require) {
var config = require('intern').config;
var Promise = require('bluebird');
var Common = require('./common');
var defaultTimeout = config.timeouts.default;
var common;
function settingsPage(remote) {
this.remote = remote;
common = new Common(this.remote);
}
settingsPage.prototype = {
constructor: settingsPage,
clickAdvancedTab: function () {
common.debug('in clickAdvancedTab');
return common.findTestSubject('settingsNav advanced').click();
},
getAdvancedSettings: function getAdvancedSettings(propertyName) {
common.debug('in setAdvancedSettings');
return common.findTestSubject('advancedSetting&' + propertyName + ' currentValue')
.getVisibleText();
},
clickAdvancedTab: function () {
common.debug('in clickAdvancedTab');
return common.findTestSubject('settingsNav advanced').click();
},
setAdvancedSettings: function setAdvancedSettings(propertyName, propertyValue) {
var self = this;
return common.findTestSubject('advancedSetting&' + propertyName + ' editButton')
.click()
.then(function () {
return common.sleep(1000);
})
.then(function setAdvancedSettingsClickPropertyValue(selectList) {
return self.remote.findByCssSelector('option[label="' + propertyValue + '"]')
.click();
})
.then(function setAdvancedSettingsClickSaveButton() {
return common.findTestSubject('advancedSetting&' + propertyName + ' saveButton')
.click();
});
},
getAdvancedSettings: function getAdvancedSettings(propertyName) {
var self = this;
common.debug('in setAdvancedSettings');
return common.findTestSubject('advancedSetting&' + propertyName + ' currentValue')
.getVisibleText();
},
navigateTo: function () {
return common.navigateToApp('settings');
},
getTimeBasedEventsCheckbox: function () {
return this.remote.setFindTimeout(defaultTimeout)
.findByCssSelector('input[ng-model="index.isTimeBased"]');
},
getTimeBasedIndexPatternCheckbox: function (timeout) {
timeout = timeout || defaultTimeout;
// fail faster since we're sometimes checking that it doesn't exist
return this.remote.setFindTimeout(timeout)
.findByCssSelector('input[ng-model="index.nameIsPattern"]');
},
getIndexPatternField: function () {
return this.remote.setFindTimeout(defaultTimeout)
.findByCssSelector('[ng-model="index.name"]');
},
getTimeFieldNameField: function () {
return this.remote.setFindTimeout(defaultTimeout)
.findDisplayedByCssSelector('select[ng-model="index.timeField"]');
},
selectTimeFieldOption: function (selection) {
var self = this;
// open dropdown
return self.getTimeFieldNameField().click()
.then(function () {
// close dropdown, keep focus
return self.getTimeFieldNameField().click();
})
.then(function () {
return common.tryForTime(defaultTimeout, function () {
return self.getTimeFieldOption(selection).click()
.then(function () {
return self.getTimeFieldOption(selection).isSelected();
})
.then(function (selected) {
if (!selected) throw new Error('option not selected: ' + selected);
});
});
});
},
getTimeFieldOption: function (selection) {
return this.remote.setFindTimeout(defaultTimeout)
.findDisplayedByCssSelector('option[label="' + selection + '"]').click();
},
getCreateButton: function () {
return this.remote.setFindTimeout(defaultTimeout)
.findDisplayedByCssSelector('.btn');
},
clickCreateButton: function () {
return this.remote.setFindTimeout(defaultTimeout)
.findByCssSelector('.btn').click();
},
clickDefaultIndexButton: function () {
return this.remote.setFindTimeout(defaultTimeout)
.findByCssSelector('button.btn.btn-warning.ng-scope').click();
},
clickDeletePattern: function () {
return this.remote.setFindTimeout(defaultTimeout)
.findByCssSelector('button.btn.btn-danger.ng-scope').click();
},
getIndexPageHeading: function () {
return this.remote.setFindTimeout(defaultTimeout)
.findByCssSelector('h1.title.ng-binding.ng-isolate-scope');
},
getConfigureHeader: function () {
return this.remote.setFindTimeout(defaultTimeout)
.findByCssSelector('h1');
},
getTableHeader: function () {
return this.remote.setFindTimeout(defaultTimeout)
.findAllByCssSelector('table.table.table-condensed thead tr th');
},
sortBy: function (columnName) {
return this.remote.setFindTimeout(defaultTimeout)
.findAllByCssSelector('table.table.table-condensed thead tr th span')
.then(function (chartTypes) {
function getChartType(chart) {
return chart.getVisibleText()
.then(function (chartString) {
if (chartString === columnName) {
return chart.click();
}
});
}
var getChartTypesPromises = chartTypes.map(getChartType);
return Promise.all(getChartTypesPromises);
});
},
getTableRow: function (rowNumber, colNumber) {
return this.remote.setFindTimeout(defaultTimeout)
// passing in zero-based index, but adding 1 for css 1-based indexes
.findByCssSelector('div.agg-table-paginated table.table.table-condensed tbody tr:nth-child(' +
(rowNumber + 1) + ') td.ng-scope:nth-child(' +
(colNumber + 1) + ') span.ng-binding'
);
},
getFieldsTabCount: function () {
var self = this;
var selector = 'li.kbn-settings-tab.active a small';
return common.tryForTime(defaultTimeout, function () {
return self.remote.setFindTimeout(defaultTimeout / 10)
.findByCssSelector(selector).getVisibleText()
.then(function (theText) {
// the value has () around it, remove them
return theText.replace(/\((.*)\)/, '$1');
});
});
},
getPageSize: function () {
var selectedItemLabel = '';
return this.remote.setFindTimeout(defaultTimeout)
.findAllByCssSelector('select.ng-pristine.ng-valid.ng-untouched option')
.then(function (chartTypes) {
function getChartType(chart) {
var thisChart = chart;
return chart.isSelected()
.then(function (isSelected) {
if (isSelected === true) {
return thisChart.getProperty('label')
.then(function (theLabel) {
selectedItemLabel = theLabel;
});
}
});
}
var getChartTypesPromises = chartTypes.map(getChartType);
return Promise.all(getChartTypesPromises);
})
.then(function () {
return selectedItemLabel;
});
},
getPageFieldCount: function () {
return this.remote.setFindTimeout(defaultTimeout)
.findAllByCssSelector('div.agg-table-paginated table.table.table-condensed tbody tr td.ng-scope:nth-child(1) span.ng-binding');
},
goToPage: function (pageNum) {
return this.remote.setFindTimeout(defaultTimeout)
.findByCssSelector('ul.pagination-other-pages-list.pagination-sm.ng-scope li.ng-scope:nth-child(' +
(pageNum + 1) + ') a.ng-binding'
)
.then(function (page) {
return page.click();
});
},
openControlsRow: function (row) {
return this.remote.setFindTimeout(defaultTimeout)
.findByCssSelector('table.table.table-condensed tbody tr:nth-child(' +
(row + 1) + ') td.ng-scope div.actions a.btn.btn-xs.btn-default i.fa.fa-pencil'
)
.then(function (page) {
return page.click();
});
},
openControlsByName: function (name) {
return this.remote.setFindTimeout(defaultTimeout)
.findByCssSelector('div.actions a.btn.btn-xs.btn-default[href$="/' + name + '"]')
.then(function (button) {
return button.click();
});
},
increasePopularity: function () {
return this.remote.setFindTimeout(defaultTimeout)
.findByCssSelector('button.btn.btn-default[aria-label="Plus"]')
.then(function (button) {
return button.click();
});
},
getPopularity: function () {
return this.remote.setFindTimeout(defaultTimeout)
.findByCssSelector('input[ng-model="editor.field.count"]')
.then(function (input) {
return input.getProperty('value');
});
},
controlChangeCancel: function () {
return this.remote.setFindTimeout(defaultTimeout)
.findByCssSelector('button.btn.btn-primary[aria-label="Cancel"]')
.then(function (button) {
return button.click();
});
},
controlChangeSave: function () {
return this.remote.setFindTimeout(defaultTimeout)
.findByCssSelector('button.btn.btn-success.ng-binding[aria-label="Update Field"]')
.then(function (button) {
return button.click();
});
},
setPageSize: function (size) {
return this.remote.setFindTimeout(defaultTimeout)
.findByCssSelector('form.form-inline.pagination-size.ng-scope.ng-pristine.ng-valid div.form-group option[label="' + size + '"]')
.then(function (button) {
return button.click();
});
},
createIndexPattern: function () {
var self = this;
return common.tryForTime(defaultTimeout, function () {
return self.selectTimeFieldOption('@timestamp')
.then(function () {
return self.getCreateButton().click();
});
})
.then(function () {
return common.tryForTime(defaultTimeout, function () {
return self.remote.getCurrentUrl()
.then(function (currentUrl) {
if (!currentUrl.match(/indices\/.+\?/)) {
throw new Error('Index pattern not created');
} else {
common.debug('Index pattern created: ' + currentUrl);
}
});
});
});
},
removeIndexPattern: function () {
var self = this;
var alertText;
return common.tryForTime(defaultTimeout, function () {
return self.clickDeletePattern()
.then(function () {
return self.remote.getAlertText();
})
.then(function (text) {
alertText = text;
})
.then(function () {
return self.remote.acceptAlert();
});
})
.then(function () {
return common.tryForTime(defaultTimeout, function () {
return self.remote.getCurrentUrl()
.then(function (currentUrl) {
if (currentUrl.match(/indices\/.+\?/)) {
throw new Error('Index pattern not removed');
}
});
});
})
.then(function () {
return alertText;
});
}
};
return settingsPage;
});