forked from opensearch-project/dashboards-observability
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrace_analytics_traces.spec.js
286 lines (249 loc) · 10.9 KB
/
trace_analytics_traces.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
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
/// <reference types="cypress" />
import { setTimeFilter, SPAN_ID, TRACE_ID, SPAN_ID_TREE_VIEW } from '../../utils/constants';
describe('Testing traces table empty state', () => {
beforeEach(() => {
cy.visit('app/observability-traces#/traces', {
onBeforeLoad: (win) => {
win.sessionStorage.clear();
},
});
});
it('Renders empty state', () => {
cy.contains(' (0)').should('exist');
cy.contains('No matches').should('exist');
});
});
describe('Testing traces table', () => {
beforeEach(() => {
cy.visit('app/observability-traces#/traces', {
onBeforeLoad: (win) => {
win.sessionStorage.clear();
},
});
cy.get("[data-test-subj='indexPattern-switch-link']").click();
cy.get("[data-test-subj='data_prepper-mode']").click();
setTimeFilter();
});
it('Renders the traces table', () => {
cy.contains(' (108)').should('exist');
cy.contains('03/25/2021 10:23:45').should('exist');
cy.contains('03f9c770db5ee2f1caac0afc36db49ba').should('exist');
cy.contains('224.99').should('exist');
// test data contains output from data-prepper 0.8, which doesn't have fields denormalized
// Trace Analytics should be able to handle the discrepancy if some fields cannot be parsed
cy.contains('Invalid date').should('exist');
cy.contains('-').should('exist');
});
it('Sorts the traces table', () => {
cy.get('.euiTableRow').first().contains('-').should('exist');
cy.get('.euiTableCellContent').contains('Trace group').click();
cy.get('.euiTableRow').first().contains('/**').should('exist');
});
it('Searches correctly', () => {
cy.get('input[type="search"]').focus().type(`${TRACE_ID}{enter}`);
cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').click();
cy.contains(' (1)').should('exist');
cy.contains('03/25/2021 10:21:22').should('exist');
});
});
describe('Testing trace view', () => {
beforeEach(() => {
cy.visit(`app/observability-traces#/traces`, {
onBeforeLoad: (win) => {
win.sessionStorage.clear();
},
});
cy.get("[data-test-subj='indexPattern-switch-link']").click();
cy.get("[data-test-subj='data_prepper-mode']").click();
setTimeFilter();
cy.get('input[type="search"]').focus().type(`${TRACE_ID}`);
cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').click();
cy.get('.euiTableRow').should('have.length.lessThan', 3);//Replaces wait
cy.get('[data-test-subj="trace-link"]').eq(0).click();
});
it('Renders the trace view', () => {
cy.contains('43.75%').should('exist');
cy.contains('42.58%').should('exist');
cy.contains('03/25/2021 10:21:22').should('exist');
cy.contains(TRACE_ID).should('exist');
cy.get('div.js-plotly-plot').should('have.length.gte', 2);
cy.get('text[data-unformatted="database <br>mysql.APM "]').should('exist');
cy.contains(`"${SPAN_ID}"`).should('exist');
});
it('Has working breadcrumbs', () => {
cy.get('.euiBreadcrumb').contains(TRACE_ID).click();
cy.get('.euiBreadcrumb').contains('Traces').click();
cy.get('.euiBreadcrumb').contains('Trace analytics').click();
cy.get('.euiBreadcrumb').contains('Observability').click();
cy.get('.euiTitle').contains('Logs').should('exist');
});
it('Renders data grid, flyout and filters', () => {
cy.get('.euiButton__text[title="Span list"]').click({ force: true });
cy.contains('2 columns hidden').should('exist');
cy.get('.euiLink').contains(SPAN_ID).trigger('mouseover', { force: true });
cy.get('button[data-datagrid-interactable="true"]').eq(0).click({ force: true });
cy.get('button[data-datagrid-interactable="true"]').eq(0).click({ force: true }); // first click doesn't go through eui data grid
cy.contains('Span detail').should('exist');
cy.contains('Span attributes').should('exist');
cy.get('.euiTextColor').contains('Span ID').trigger('mouseover');
cy.get('.euiButtonIcon[aria-label="span-flyout-filter-icon"').click({ force: true });
cy.get('.euiBadge__text').contains('spanId: ').should('exist');
cy.contains('Spans (1)').should('exist');
});
});
describe('Testing traces table', () => {
beforeEach(() => {
cy.visit('app/observability-traces#/traces', {
onBeforeLoad: (win) => {
win.sessionStorage.clear();
},
});
cy.get("[data-test-subj='indexPattern-switch-link']").click();
cy.get("[data-test-subj='data_prepper-mode']").click();
setTimeFilter();
});
it.only('Renders the traces table and verify Table Column, Pagination and Rows Data ', () => {
cy.get('.euiTableCellContent__text').contains('Trace ID').should('exist');
cy.get('.euiTableCellContent__text').contains('Trace group').should('exist');
cy.get('.euiTableCellContent__text').contains('Duration (ms)').should('exist');
cy.get('.euiTableCellContent__text').contains('Percentile in trace group').should('exist');
cy.get('.euiTableCellContent__text').contains('Errors').should('exist');
cy.get('.euiTableCellContent__text').contains('Last updated').should('exist');
cy.get("[data-test-subj='tableHeaderCell_trace_group_1']").click();
cy.contains('mysql').should('not.exist');
cy.get('[data-test-subj="pagination-button-next"]').click();
cy.contains('HTTP POST').should('exist');
cy.get('[data-test-subj="pagination-button-previous"]').click();
cy.contains('56.88').should('exist');
cy.get('.euiButtonEmpty').contains('5').click();
cy.contains('386d26555771f39c0caaf').should('exist');
cy.contains('5be8370207cbb002a165d').click();
cy.contains('client_create_order').should('exist');
cy.get('path[style*="rgb(116, 146, 231)"]').should('exist');
cy.go('back');
cy.get('.euiButtonEmpty__text').contains('Rows per page').click();
cy.get('.euiContextMenuItem__text').contains('15 rows').click();
let expected_row_count = 15;
cy.get('.euiTable--auto')
.find("tr")
.then((row) => {
let total = row.length - 1;
expect(total).to.equal(expected_row_count);
});
});
});
describe('Testing traces tree view', () => {
beforeEach(() => {
cy.visit('app/observability-traces#/traces', {
onBeforeLoad: (win) => {
win.sessionStorage.clear();
},
});
cy.get("[data-test-subj='indexPattern-switch-link']").click();
cy.get("[data-test-subj='data_prepper-mode']").click();
setTimeFilter();
cy.get('[data-test-subj="globalLoadingIndicator"]').should('not.exist');
cy.contains('02feb3a4f611abd81f2a53244d1278ae').click();
cy.get('h1.overview-content').contains('02feb3a4f611abd81f2a53244d1278ae').should('exist');
});
it('Verifies tree view and table toggle functionality with expand/collapse logic', () => {
cy.get('.euiButtonGroup').contains('Tree view').click();
cy.contains('Expand all').should('exist');
cy.contains("Collapse all").should('exist')
//Waiting time for render to complete
cy.get("[data-test-subj='treeExpandAll']").click();
cy.get("[data-test-subj='treeCollapseAll']").click();
cy.get("[data-test-subj='spanId-link']")
.should('have.length', 6)
.then((initialSpanIds) => {
const initialCount = initialSpanIds.length;
expect(initialCount).to.equal(6);
cy.get("[data-test-subj='treeExpandAll']").click();
cy.get("[data-test-subj='spanId-link']").then((expandedSpanIds) => {
const expandedCount = expandedSpanIds.length;
expect(expandedCount).to.equal(10);
});
cy.get("[data-test-subj='treeCollapseAll']").click();
cy.get("[data-test-subj='spanId-link']").then((collapsedSpanIds) => {
const collapsedCount = collapsedSpanIds.length;
expect(collapsedCount).to.equal(6); // Collapsed rows should match the initial count
});
});
});
it('Verifies tree view expand arrow functionality', () => {
cy.get('.euiButtonGroup').contains('Tree view').click();
cy.contains('Expand all').should('exist');
cy.contains("Collapse all").should('exist')
// Waiting time for render to complete
cy.get("[data-test-subj='treeExpandAll']").click();
cy.get("[data-test-subj='treeCollapseAll']").click();
cy.get("[data-test-subj='spanId-link']").then((initialSpanIds) => {
const initialCount = initialSpanIds.length;
expect(initialCount).to.equal(6);
// Find and click the first tree view expand arrow
cy.get("[data-test-subj='treeViewExpandArrow']").first().click();
// Check the number of Span IDs after expanding the arrow (should be 7)
cy.get("[data-test-subj='spanId-link']").then((expandedSpanIds) => {
const expandedCount = expandedSpanIds.length;
expect(expandedCount).to.equal(7);
});
});
});
it('Verifies span flyout', () => {
cy.get('.euiButtonGroup').contains('Tree view').click();
cy.contains('Expand all').should('exist');
cy.contains("Collapse all").should('exist')
// Waiting time for render to complete
cy.get("[data-test-subj='treeExpandAll']").click();
cy.get("[data-test-subj='treeCollapseAll']").click();
// Open flyout for a span
cy.get("[data-test-subj='spanId-link']")
.contains(SPAN_ID_TREE_VIEW)
.click()
cy.contains('Span detail').should('exist');
cy.contains('Span attributes').should('exist');
});
it('Handles toggling between full screen and regular modes', () => {
cy.get('.euiButtonGroup').contains('Tree view').click();
cy.contains('Expand all').should('exist');
cy.contains("Collapse all").should('exist')
// Waiting time for render to complete
cy.get("[data-test-subj='treeExpandAll']").click();
cy.get("[data-test-subj='treeCollapseAll']").click();
cy.get('[data-test-subj="fullScreenButton"]').click();
cy.get('.euiButtonEmpty__text').should('contain.text', 'Exit full screen');
cy.get('[data-test-subj="fullScreenButton"]').click();
cy.get('.euiButtonEmpty__text').should('contain.text', 'Full screen');
});
});
describe('Testing switch mode to jaeger', () => {
beforeEach(() => {
cy.visit('app/observability-traces#/traces', {
onBeforeLoad: (win) => {
win.sessionStorage.clear();
},
});
setTimeFilter();
cy.get("[data-test-subj='indexPattern-switch-link']").click();
cy.get("[data-test-subj='jaeger-mode']").click();
});
it('Verifies columns and data', () => {
cy.contains('08ee9fd9bf964384').should('exist');
cy.contains('0.012').should('exist');
cy.contains('No').should('exist');
cy.contains('01/24/2023 08:33:35').should('exist');
cy.contains('Latency (ms)').should('exist');
cy.contains('Trace ID').should('exist');
cy.contains('Errors').should('exist');
cy.contains('Last updated').should('exist');
});
it('Verifies Trace View', () => {
cy.contains('08ee9fd9bf964384').click();
cy.contains("Time spent by service").should('exist');
cy.get("[data-test-subj='span-gantt-chart-panel']").should('exist');
})
});