-
Notifications
You must be signed in to change notification settings - Fork 114
/
Copy pathrollups_spec.js
296 lines (231 loc) · 8.96 KB
/
rollups_spec.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
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
import { BASE_PATH, IM_PLUGIN_NAME } from '../../../utils/constants';
import sampleRollup from '../../../fixtures/plugins/index-management-dashboards-plugin/sample_rollup';
const ROLLUP_ID = 'test_rollup_id';
describe('Rollups', () => {
beforeEach(() => {
// Set welcome screen tracking to true
localStorage.setItem('home:welcome:show', 'true');
// Go to sample data page
cy.visit(`${BASE_PATH}/app/home#/tutorial_directory/sampleData`);
// Click on "Sample data" tab
cy.contains('Sample data').click({ force: true });
// Load sample eCommerce data
cy.get(`button[data-test-subj="addSampleDataSetecommerce"]`).click({
force: true,
});
// Verify that sample data is add by checking toast notification
cy.contains('Sample eCommerce orders installed', { timeout: 60000 });
// Visit ISM OSD
cy.visit(`${BASE_PATH}/app/${IM_PLUGIN_NAME}#/rollups`);
// Common text to wait for to confirm page loaded, give up to 60 seconds for initial load
cy.contains('Create rollup', { timeout: 60000 });
});
describe('can be created', () => {
before(() => {
cy.deleteAllIndices();
cy.deleteIMJobs();
});
it('successfully', () => {
// Confirm we loaded empty state
cy.contains(
'Rollup jobs help you conserve storage space for historical time series data while preserving the specific information you need'
);
// Route us to create rollup page
cy.contains('Create rollup').click({ force: true });
// Type in the rollup ID
cy.get(`input[placeholder="my-rollupjob1"]`).type(ROLLUP_ID, {
force: true,
});
// Get description input box
cy.get(`textarea[data-test-subj="description"]`)
.focus()
.type('some description');
// Enter source index
cy.get(`div[data-test-subj="sourceIndexCombobox"]`)
.find(`input[data-test-subj="comboBoxSearchInput"]`)
.focus()
.type('opensearch_dashboards_sample_data_ecommerce{enter}');
// Enter target index
cy.get(`div[data-test-subj="targetIndexCombobox"]`)
.find(`input[data-test-subj="comboBoxSearchInput"]`)
.focus()
.type('target_index{enter}');
// Click the next button
cy.get('button').contains('Next').click({ force: true });
// Confirm that we got to step 2 of creation page
cy.contains('Time aggregation');
// Enter timestamp field
cy.get(`input[data-test-subj="comboBoxSearchInput"]`)
.focus()
.type('order_date{enter}');
// Add aggregation
cy.get(`button[data-test-subj="addFieldsAggregationEmpty"]`).click({
force: true,
});
// Select a few fields
cy.get(`input[data-test-subj="checkboxSelectRow-customer_gender"]`).click(
{ force: true }
);
cy.get(`input[data-test-subj="checkboxSelectRow-day_of_week_i"]`).click({
force: true,
});
cy.get(`input[data-test-subj="checkboxSelectRow-geoip.city_name"]`).click(
{ force: true }
);
// Click the Add button from add fields modal
cy.get(`button[data-test-subj="addFieldsAggregationAdd"]`).click({
force: true,
});
// Confirm fields are added
cy.contains('customer_gender');
cy.contains('day_of_week_i');
cy.contains('geoip.city_name');
// Add metrics
cy.get(`button[data-test-subj="addFieldsMetricEmpty"]`).click({
force: true,
});
// Select a few fields
cy.get(
`input[data-test-subj="checkboxSelectRow-products.taxless_price"]`
).click({ force: true });
cy.get(`input[data-test-subj="checkboxSelectRow-total_quantity"]`).click({
force: true,
});
// Click the Add button from add fields modal
cy.get(`button[data-test-subj="addFieldsMetricAdd"]`).click({
force: true,
});
// Confirm fields are added
cy.contains('products.taxless_price');
cy.contains('total_quantity');
cy.get(`input[data-test-subj="min-total_quantity"]`).click({
force: true,
});
cy.get(`input[data-test-subj="max-total_quantity"]`).click({
force: true,
});
cy.get(`input[data-test-subj="sum-total_quantity"]`).click({
force: true,
});
cy.get(`input[data-test-subj="all-products.taxless_price"]`).click({
force: true,
});
// Click the next button
cy.get('button').contains('Next').click({ force: true });
// Confirm that we got to step 3 of creation page
cy.contains('Enable job by default');
// Click the next button
cy.get('button').contains('Next').click({ force: true });
// Confirm that we got to step 4 of creation page
cy.contains('Job name and indexes');
// Click the create button
cy.get('button').contains('Create').click({ force: true });
// Verify that sample data is add by checking toast notification
cy.contains(`Created rollup: ${ROLLUP_ID}`);
});
});
describe('can be edited', () => {
before(() => {
cy.deleteAllIndices();
cy.deleteIMJobs();
cy.createRollup(ROLLUP_ID, sampleRollup);
});
it('successfully', () => {
// Confirm we have our initial rollup
cy.contains(ROLLUP_ID);
// Select checkbox for our rollup job
cy.get(`#_selection_column_${ROLLUP_ID}-checkbox`).check({ force: true });
// Click on Actions popover menu
cy.get(`[data-test-subj="actionButton"]`).click({ force: true });
// Click Edit button
cy.get(`[data-test-subj="editButton"]`).click({ force: true });
// Wait for initial rollup job to load
cy.contains(
'An example rollup job that rolls up the sample ecommerce data'
);
cy.get(`textArea[data-test-subj="description"]`)
.focus()
.clear()
.type('A new description');
// Click Save changes button
cy.get(`[data-test-subj="editRollupSaveChangesButton"]`).click({
force: true,
});
// Confirm we get toaster saying changes saved
cy.contains(`Changes to "${ROLLUP_ID}" saved!`);
// Click into rollup job details page
cy.get(`[data-test-subj="rollupLink_${ROLLUP_ID}"]`).click({
force: true,
});
// Confirm new description shows in details page
cy.contains('A new description');
});
});
describe('can be deleted', () => {
before(() => {
cy.deleteAllIndices();
cy.deleteIMJobs();
cy.createRollup(ROLLUP_ID, sampleRollup);
});
it('successfully', () => {
// Confirm we have our initial rollup
cy.contains(ROLLUP_ID);
// Select checkbox for our rollup job
cy.get(`#_selection_column_${ROLLUP_ID}-checkbox`).check({ force: true });
// Click on Actions popover menu
cy.get(`[data-test-subj="actionButton"]`).click({ force: true });
// Click Delete button
cy.get(`[data-test-subj="deleteButton"]`).click({ force: true });
// Type "delete" to confirm deletion
cy.get(`input[placeholder="delete"]`).type('delete', { force: true });
// Click the delete confirmation button in modal
cy.get(`[data-test-subj="confirmModalConfirmButton"]`).click();
// Confirm we got deleted toaster
cy.contains(`"${ROLLUP_ID}" successfully deleted!`);
// Confirm showing empty loading state
cy.contains(
'Rollup jobs help you conserve storage space for historical time series data while preserving the specific information you need'
);
});
});
describe('can be enabled and disabled', () => {
before(() => {
cy.deleteAllIndices();
cy.deleteIMJobs();
cy.createRollup(ROLLUP_ID, sampleRollup);
});
it('successfully', () => {
// Confirm we have our initial rollup
cy.contains(ROLLUP_ID);
// Intercept different rollups requests endpoints to wait before clicking disable and enable buttons
cy.intercept(`/api/ism/rollups/${ROLLUP_ID}`).as('getRollup');
cy.intercept(`/api/ism/rollups/${ROLLUP_ID}/_stop`).as('stopRollup');
// Click into rollup job details page
cy.get(`[data-test-subj="rollupLink_${ROLLUP_ID}"]`).click({
force: true,
});
cy.contains(`${ROLLUP_ID}`);
cy.wait('@getRollup').wait(2000);
// Click Disable button
cy.get(`[data-test-subj="disableButton"]`)
.should('not.be.disabled')
.click({ force: true });
cy.wait('@stopRollup');
cy.wait('@getRollup');
// Confirm we get toaster saying rollup job is disabled
cy.contains(`${ROLLUP_ID} is disabled`);
// Extra wait required for page data to load, otherwise "Enable" button will be disabled
cy.wait(2000);
// Click Enable button
cy.get(`[data-test-subj="enableButton"]`)
.should('not.be.disabled')
.click({ force: true });
// Confirm we get toaster saying rollup job is enabled
cy.contains(`${ROLLUP_ID} is enabled`);
});
});
});