Skip to content

Commit 28fd1f9

Browse files
KishoreKicha14Kishore Kumaar Natarajan
and
Kishore Kumaar Natarajan
authored
[Improvement] Improved Cypress test that validates the dynamic column (#168)
* Improve the Dynamic Column Cypress Signed-off-by: Kishore Kumaar Natarajan <[email protected]> * Improve the Dynamic Column Cypress Signed-off-by: Kishore Kumaar Natarajan <[email protected]> * updated timestamp with old date Signed-off-by: Kishore Kumaar Natarajan <[email protected]> --------- Signed-off-by: Kishore Kumaar Natarajan <[email protected]> Co-authored-by: Kishore Kumaar Natarajan <[email protected]>
1 parent 952246f commit 28fd1f9

File tree

2 files changed

+283
-29
lines changed

2 files changed

+283
-29
lines changed

cypress/e2e/1_top_queries.cy.js

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import { METRICS } from '../support/constants';
1010
const indexName = 'sample_index';
1111

1212
/**
13-
Helper function to clean up the environment:
14-
- Deletes the test index.
15-
- Disables the top queries features.
13+
Helper function to clean up the environment:
14+
- Deletes the test index.
15+
- Disables the top queries features.
1616
*/
1717
const clearAll = () => {
1818
cy.deleteIndexByName(indexName);
@@ -114,6 +114,34 @@ describe('Query Insights Dashboard', () => {
114114
cy.contains('No items found');
115115
});
116116

117+
it('should paginate the query table', () => {
118+
for (let i = 0; i < 20; i++) {
119+
cy.searchOnIndex(indexName);
120+
}
121+
cy.wait(10000);
122+
cy.reload();
123+
cy.get('.euiPagination').should('be.visible');
124+
cy.get('.euiPagination__item').contains('2').click();
125+
// Verify rows on the second page
126+
cy.get('.euiTableRow').should('have.length.greaterThan', 0);
127+
});
128+
after(() => clearAll());
129+
});
130+
131+
describe('Query Insights Dashboard - Dynamic Columns with Stubbed Top Queries', () => {
132+
beforeEach(() => {
133+
cy.fixture('stub_top_queries.json').then((stubResponse) => {
134+
cy.intercept('GET', '**/api/top_queries/*', {
135+
statusCode: 200,
136+
body: stubResponse,
137+
}).as('getTopQueries');
138+
});
139+
140+
cy.navigateToOverview();
141+
cy.wait(1000);
142+
cy.wait('@getTopQueries');
143+
});
144+
117145
it('should render only individual query-related headers when NONE filter is applied', () => {
118146
cy.wait(1000);
119147
cy.get('.euiFilterButton').contains('Type').click();
@@ -142,16 +170,6 @@ describe('Query Insights Dashboard', () => {
142170
});
143171

144172
it('should render only group-related headers in the correct order when SIMILARITY filter is applied', () => {
145-
cy.enableGrouping();
146-
cy.wait(1000);
147-
cy.searchOnIndex(indexName);
148-
cy.wait(1000);
149-
cy.searchOnIndex(indexName);
150-
cy.wait(1000);
151-
cy.searchOnIndex(indexName);
152-
cy.navigateToOverview();
153-
cy.wait(1000);
154-
cy.wait(1000);
155173
cy.get('.euiFilterButton').contains('Type').click();
156174
cy.get('.euiFilterSelectItem').contains('group').click();
157175
cy.wait(1000);
@@ -171,9 +189,6 @@ describe('Query Insights Dashboard', () => {
171189
});
172190
});
173191
it('should display both query and group data with proper headers when both are selected', () => {
174-
clearAll();
175-
cy.wait(10000);
176-
cy.reload();
177192
cy.get('.euiFilterButton').contains('Type').click();
178193
cy.get('.euiFilterSelectItem').contains('query').click();
179194
cy.get('.euiFilterSelectItem').contains('group').click();
@@ -197,17 +212,4 @@ describe('Query Insights Dashboard', () => {
197212
expect(actualHeaders).to.deep.equal(expectedGroupHeaders);
198213
});
199214
});
200-
it('should paginate the query table', () => {
201-
for (let i = 0; i < 20; i++) {
202-
cy.searchOnIndex(indexName);
203-
}
204-
cy.wait(10000);
205-
cy.reload();
206-
cy.get('.euiPagination').should('be.visible');
207-
cy.get('.euiPagination__item').contains('2').click();
208-
// Verify rows on the second page
209-
cy.get('.euiTableRow').should('have.length.greaterThan', 0);
210-
});
211-
212-
after(() => clearAll());
213215
});
Lines changed: 252 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
{
2+
"ok": true,
3+
"response": {
4+
"top_queries": [
5+
{
6+
"timestamp": 1443852054000,
7+
"id": "a2e1c822-3e3c-4d1b-adb2-9f73af094b43",
8+
"search_type": "query_then_fetch",
9+
"indices": [
10+
"my-index"
11+
],
12+
"node_id": "UYKFun8PSAeJvkkt9cWf0w",
13+
"group_by": "NONE",
14+
"total_shards": 1,
15+
"labels": {
16+
"X-Opaque-Id": "90eb5c3b-8448-4af3-84ce-a941eee9ed5f"
17+
},
18+
"measurements": {
19+
"cpu": {
20+
"number": 2921000,
21+
"count": 1,
22+
"aggregationType": "NONE"
23+
},
24+
"latency": {
25+
"number": 5,
26+
"count": 1,
27+
"aggregationType": "NONE"
28+
},
29+
"memory": {
30+
"number": 100840,
31+
"count": 1,
32+
"aggregationType": "NONE"
33+
}
34+
}
35+
},
36+
{
37+
"timestamp": 1443852054000,
38+
"id": "130a5d36-615e-43e8-ad99-e1b90d527f44",
39+
"search_type": "query_then_fetch",
40+
"indices": [
41+
".kibana"
42+
],
43+
"node_id": "UYKFun8PSAeJvkkt9cWf0w",
44+
"group_by": "SIMILARITY",
45+
"total_shards": 1,
46+
"labels": {},
47+
"query_group_hashcode": "2219a4bb71bd0d262e6d0f5504b88537",
48+
"measurements": {
49+
"memory": {
50+
"number": 38024,
51+
"count": 1,
52+
"aggregationType": "AVERAGE"
53+
},
54+
"cpu": {
55+
"number": 2613000,
56+
"count": 1,
57+
"aggregationType": "AVERAGE"
58+
},
59+
"latency": {
60+
"number": 5,
61+
"count": 1,
62+
"aggregationType": "AVERAGE"
63+
}
64+
}
65+
},
66+
{
67+
"timestamp": 1443852054000,
68+
"id": "a2e1c822-3e3c-4d1b-adb2-9f73af094b43",
69+
"search_type": "query_then_fetch",
70+
"indices": [
71+
"my-index"
72+
],
73+
"node_id": "UYKFun8PSAeJvkkt9cWf0w",
74+
"group_by": "NONE",
75+
"total_shards": 1,
76+
"labels": {
77+
"X-Opaque-Id": "90eb5c3b-8448-4af3-84ce-a941eee9ed5f"
78+
},
79+
"measurements": {
80+
"memory": {
81+
"number": 100840,
82+
"count": 1,
83+
"aggregationType": "NONE"
84+
},
85+
"cpu": {
86+
"number": 2921000,
87+
"count": 1,
88+
"aggregationType": "NONE"
89+
},
90+
"latency": {
91+
"number": 5,
92+
"count": 1,
93+
"aggregationType": "NONE"
94+
}
95+
}
96+
},
97+
{
98+
"timestamp": 1443852054000,
99+
"id": "7cd4c7f1-3803-4c5e-a41c-258e04f96f78",
100+
"search_type": "query_then_fetch",
101+
"indices": [
102+
"my-index"
103+
],
104+
"node_id": "UYKFun8PSAeJvkkt9cWf0w",
105+
"group_by": "NONE",
106+
"total_shards": 1,
107+
"labels": {
108+
"X-Opaque-Id": "8a936346-8d19-409c-9fe6-8b890eca1f7c"
109+
},
110+
"measurements": {
111+
"cpu": {
112+
"number": 1831000,
113+
"count": 1,
114+
"aggregationType": "NONE"
115+
},
116+
"latency": {
117+
"number": 4,
118+
"count": 1,
119+
"aggregationType": "NONE"
120+
},
121+
"memory": {
122+
"number": 65760,
123+
"count": 1,
124+
"aggregationType": "NONE"
125+
}
126+
}
127+
},
128+
{
129+
"timestamp": 1443852054000,
130+
"id": "76f5e51f-33f6-480c-8b20-8003abb93d19",
131+
"search_type": "query_then_fetch",
132+
"indices": [
133+
".kibana"
134+
],
135+
"node_id": "UYKFun8PSAeJvkkt9cWf0w",
136+
"group_by": "SIMILARITY",
137+
"total_shards": 1,
138+
"labels": {
139+
"X-Opaque-Id": "660baeb1-077b-4884-8bae-890cfe30e776"
140+
},
141+
"query_group_hashcode": "a336f9580d5d980f7403f6d179f454eb",
142+
"measurements": {
143+
"memory": {
144+
"number": 77784,
145+
"count": 1,
146+
"aggregationType": "AVERAGE"
147+
},
148+
"cpu": {
149+
"number": 1589000,
150+
"count": 1,
151+
"aggregationType": "AVERAGE"
152+
},
153+
"latency": {
154+
"number": 2,
155+
"count": 1,
156+
"aggregationType": "AVERAGE"
157+
}
158+
}
159+
},
160+
{
161+
"timestamp": 1443852054000,
162+
"id": "37d633a7-20e6-41a1-96e9-cd4806511dbf",
163+
"search_type": "query_then_fetch",
164+
"indices": [
165+
".kibana"
166+
],
167+
"node_id": "UYKFun8PSAeJvkkt9cWf0w",
168+
"group_by": "SIMILARITY",
169+
"total_shards": 1,
170+
"labels": {},
171+
"query_group_hashcode": "7cef9a399c117a0278025a89e943eebc",
172+
"measurements": {
173+
"memory": {
174+
"number": 981144,
175+
"count": 4,
176+
"aggregationType": "AVERAGE"
177+
},
178+
"cpu": {
179+
"number": 6286000,
180+
"count": 4,
181+
"aggregationType": "AVERAGE"
182+
},
183+
"latency": {
184+
"number": 2,
185+
"count": 1,
186+
"aggregationType": "NONE"
187+
}
188+
}
189+
},
190+
{
191+
"timestamp": 1443852054000,
192+
"id": "9982b7fc-0339-47d8-b77f-8de1bda76b72",
193+
"search_type": "query_then_fetch",
194+
"indices": [
195+
".kibana"
196+
],
197+
"node_id": "UYKFun8PSAeJvkkt9cWf0w",
198+
"group_by": "SIMILARITY",
199+
"total_shards": 1,
200+
"labels": {},
201+
"query_group_hashcode": "7cef9a399c117a0278025a89e943eebc",
202+
"measurements": {
203+
"memory": {
204+
"number": 1001464,
205+
"count": 4,
206+
"aggregationType": "AVERAGE"
207+
},
208+
"cpu": {
209+
"number": 5562000,
210+
"count": 4,
211+
"aggregationType": "AVERAGE"
212+
},
213+
"latency": {
214+
"number": 7,
215+
"count": 4,
216+
"aggregationType": "AVERAGE"
217+
}
218+
}
219+
},
220+
{
221+
"timestamp": 1443852054000,
222+
"id": "d8dccf54-8dcb-4411-9fd6-977844be8fb3",
223+
"search_type": "query_then_fetch",
224+
"indices": [
225+
".kibana"
226+
],
227+
"node_id": "UYKFun8PSAeJvkkt9cWf0w",
228+
"group_by": "SIMILARITY",
229+
"total_shards": 1,
230+
"labels": {},
231+
"query_group_hashcode": "2219a4bb71bd0d262e6d0f5504b88537",
232+
"measurements": {
233+
"memory": {
234+
"number": 38024,
235+
"count": 1,
236+
"aggregationType": "AVERAGE"
237+
},
238+
"cpu": {
239+
"number": 840000,
240+
"count": 1,
241+
"aggregationType": "AVERAGE"
242+
},
243+
"latency": {
244+
"number": 1,
245+
"count": 1,
246+
"aggregationType": "NONE"
247+
}
248+
}
249+
}
250+
]
251+
}
252+
}

0 commit comments

Comments
 (0)