From 8843837f42cfeed3c7fea2bed27fe1f731dfde27 Mon Sep 17 00:00:00 2001 From: Kishore Kumaar Natarajan Date: Tue, 22 Apr 2025 15:07:28 -0700 Subject: [PATCH 1/3] Improve the Dynamic Column Cypress Signed-off-by: Kishore Kumaar Natarajan --- cypress/e2e/1_top_queries.cy.js | 61 +++--- cypress/fixtures/stub_top_queries.json | 252 +++++++++++++++++++++++++ 2 files changed, 284 insertions(+), 29 deletions(-) create mode 100644 cypress/fixtures/stub_top_queries.json diff --git a/cypress/e2e/1_top_queries.cy.js b/cypress/e2e/1_top_queries.cy.js index e847a539..09f17d29 100644 --- a/cypress/e2e/1_top_queries.cy.js +++ b/cypress/e2e/1_top_queries.cy.js @@ -10,9 +10,9 @@ import { METRICS } from '../support/constants'; const indexName = 'sample_index'; /** - Helper function to clean up the environment: - - Deletes the test index. - - Disables the top queries features. + Helper function to clean up the environment: + - Deletes the test index. + - Disables the top queries features. */ const clearAll = () => { cy.deleteIndexByName(indexName); @@ -114,6 +114,35 @@ describe('Query Insights Dashboard', () => { cy.contains('No items found'); }); + + it('should paginate the query table', () => { + for (let i = 0; i < 20; i++) { + cy.searchOnIndex(indexName); + } + cy.wait(10000); + cy.reload(); + cy.get('.euiPagination').should('be.visible'); + cy.get('.euiPagination__item').contains('2').click(); + // Verify rows on the second page + cy.get('.euiTableRow').should('have.length.greaterThan', 0); + }); + after(() => clearAll()); +}); + +describe('Query Insights Dashboard - Dynamic Columns with Stubbed Top Queries', () => { + beforeEach(() => { + cy.fixture('stub_top_queries.json').then((stubResponse) => { + cy.intercept('GET', '**/api/top_queries/*', { + statusCode: 200, + body: stubResponse, + }).as('getTopQueries'); + }); + + cy.navigateToOverview(); + cy.wait(1000); + cy.wait('@getTopQueries'); + }); + it('should render only individual query-related headers when NONE filter is applied', () => { cy.wait(1000); cy.get('.euiFilterButton').contains('Type').click(); @@ -142,16 +171,6 @@ describe('Query Insights Dashboard', () => { }); it('should render only group-related headers in the correct order when SIMILARITY filter is applied', () => { - cy.enableGrouping(); - cy.wait(1000); - cy.searchOnIndex(indexName); - cy.wait(1000); - cy.searchOnIndex(indexName); - cy.wait(1000); - cy.searchOnIndex(indexName); - cy.navigateToOverview(); - cy.wait(1000); - cy.wait(1000); cy.get('.euiFilterButton').contains('Type').click(); cy.get('.euiFilterSelectItem').contains('group').click(); cy.wait(1000); @@ -171,9 +190,6 @@ describe('Query Insights Dashboard', () => { }); }); it('should display both query and group data with proper headers when both are selected', () => { - clearAll(); - cy.wait(10000); - cy.reload(); cy.get('.euiFilterButton').contains('Type').click(); cy.get('.euiFilterSelectItem').contains('query').click(); cy.get('.euiFilterSelectItem').contains('group').click(); @@ -197,17 +213,4 @@ describe('Query Insights Dashboard', () => { expect(actualHeaders).to.deep.equal(expectedGroupHeaders); }); }); - it('should paginate the query table', () => { - for (let i = 0; i < 20; i++) { - cy.searchOnIndex(indexName); - } - cy.wait(10000); - cy.reload(); - cy.get('.euiPagination').should('be.visible'); - cy.get('.euiPagination__item').contains('2').click(); - // Verify rows on the second page - cy.get('.euiTableRow').should('have.length.greaterThan', 0); - }); - - after(() => clearAll()); }); diff --git a/cypress/fixtures/stub_top_queries.json b/cypress/fixtures/stub_top_queries.json new file mode 100644 index 00000000..bfd8ef86 --- /dev/null +++ b/cypress/fixtures/stub_top_queries.json @@ -0,0 +1,252 @@ +{ + "ok": true, + "response": { + "top_queries": [ + { + "timestamp": 1745354380225, + "id": "a2e1c822-3e3c-4d1b-adb2-9f73af094b43", + "search_type": "query_then_fetch", + "indices": [ + "my-index" + ], + "node_id": "UYKFun8PSAeJvkkt9cWf0w", + "group_by": "NONE", + "total_shards": 1, + "labels": { + "X-Opaque-Id": "90eb5c3b-8448-4af3-84ce-a941eee9ed5f" + }, + "measurements": { + "cpu": { + "number": 2921000, + "count": 1, + "aggregationType": "NONE" + }, + "latency": { + "number": 5, + "count": 1, + "aggregationType": "NONE" + }, + "memory": { + "number": 100840, + "count": 1, + "aggregationType": "NONE" + } + } + }, + { + "timestamp": 1745352966702, + "id": "130a5d36-615e-43e8-ad99-e1b90d527f44", + "search_type": "query_then_fetch", + "indices": [ + ".kibana" + ], + "node_id": "UYKFun8PSAeJvkkt9cWf0w", + "group_by": "SIMILARITY", + "total_shards": 1, + "labels": {}, + "query_group_hashcode": "2219a4bb71bd0d262e6d0f5504b88537", + "measurements": { + "memory": { + "number": 38024, + "count": 1, + "aggregationType": "AVERAGE" + }, + "cpu": { + "number": 2613000, + "count": 1, + "aggregationType": "AVERAGE" + }, + "latency": { + "number": 5, + "count": 1, + "aggregationType": "AVERAGE" + } + } + }, + { + "timestamp": 1745354380225, + "id": "a2e1c822-3e3c-4d1b-adb2-9f73af094b43", + "search_type": "query_then_fetch", + "indices": [ + "my-index" + ], + "node_id": "UYKFun8PSAeJvkkt9cWf0w", + "group_by": "NONE", + "total_shards": 1, + "labels": { + "X-Opaque-Id": "90eb5c3b-8448-4af3-84ce-a941eee9ed5f" + }, + "measurements": { + "memory": { + "number": 100840, + "count": 1, + "aggregationType": "NONE" + }, + "cpu": { + "number": 2921000, + "count": 1, + "aggregationType": "NONE" + }, + "latency": { + "number": 5, + "count": 1, + "aggregationType": "NONE" + } + } + }, + { + "timestamp": 1745354384266, + "id": "7cd4c7f1-3803-4c5e-a41c-258e04f96f78", + "search_type": "query_then_fetch", + "indices": [ + "my-index" + ], + "node_id": "UYKFun8PSAeJvkkt9cWf0w", + "group_by": "NONE", + "total_shards": 1, + "labels": { + "X-Opaque-Id": "8a936346-8d19-409c-9fe6-8b890eca1f7c" + }, + "measurements": { + "cpu": { + "number": 1831000, + "count": 1, + "aggregationType": "NONE" + }, + "latency": { + "number": 4, + "count": 1, + "aggregationType": "NONE" + }, + "memory": { + "number": 65760, + "count": 1, + "aggregationType": "NONE" + } + } + }, + { + "timestamp": 1745353380505, + "id": "76f5e51f-33f6-480c-8b20-8003abb93d19", + "search_type": "query_then_fetch", + "indices": [ + ".kibana" + ], + "node_id": "UYKFun8PSAeJvkkt9cWf0w", + "group_by": "SIMILARITY", + "total_shards": 1, + "labels": { + "X-Opaque-Id": "660baeb1-077b-4884-8bae-890cfe30e776" + }, + "query_group_hashcode": "a336f9580d5d980f7403f6d179f454eb", + "measurements": { + "memory": { + "number": 77784, + "count": 1, + "aggregationType": "AVERAGE" + }, + "cpu": { + "number": 1589000, + "count": 1, + "aggregationType": "AVERAGE" + }, + "latency": { + "number": 2, + "count": 1, + "aggregationType": "AVERAGE" + } + } + }, + { + "timestamp": 1745353802101, + "id": "37d633a7-20e6-41a1-96e9-cd4806511dbf", + "search_type": "query_then_fetch", + "indices": [ + ".kibana" + ], + "node_id": "UYKFun8PSAeJvkkt9cWf0w", + "group_by": "SIMILARITY", + "total_shards": 1, + "labels": {}, + "query_group_hashcode": "7cef9a399c117a0278025a89e943eebc", + "measurements": { + "memory": { + "number": 981144, + "count": 4, + "aggregationType": "AVERAGE" + }, + "cpu": { + "number": 6286000, + "count": 4, + "aggregationType": "AVERAGE" + }, + "latency": { + "number": 2, + "count": 1, + "aggregationType": "NONE" + } + } + }, + { + "timestamp": 1745353548574, + "id": "9982b7fc-0339-47d8-b77f-8de1bda76b72", + "search_type": "query_then_fetch", + "indices": [ + ".kibana" + ], + "node_id": "UYKFun8PSAeJvkkt9cWf0w", + "group_by": "SIMILARITY", + "total_shards": 1, + "labels": {}, + "query_group_hashcode": "7cef9a399c117a0278025a89e943eebc", + "measurements": { + "memory": { + "number": 1001464, + "count": 4, + "aggregationType": "AVERAGE" + }, + "cpu": { + "number": 5562000, + "count": 4, + "aggregationType": "AVERAGE" + }, + "latency": { + "number": 7, + "count": 4, + "aggregationType": "AVERAGE" + } + } + }, + { + "timestamp": 1745351166704, + "id": "d8dccf54-8dcb-4411-9fd6-977844be8fb3", + "search_type": "query_then_fetch", + "indices": [ + ".kibana" + ], + "node_id": "UYKFun8PSAeJvkkt9cWf0w", + "group_by": "SIMILARITY", + "total_shards": 1, + "labels": {}, + "query_group_hashcode": "2219a4bb71bd0d262e6d0f5504b88537", + "measurements": { + "memory": { + "number": 38024, + "count": 1, + "aggregationType": "AVERAGE" + }, + "cpu": { + "number": 840000, + "count": 1, + "aggregationType": "AVERAGE" + }, + "latency": { + "number": 1, + "count": 1, + "aggregationType": "NONE" + } + } + } + ] + } +} From 511648d9c1a98befe0e71fa975e93965d8e14031 Mon Sep 17 00:00:00 2001 From: Kishore Kumaar Natarajan Date: Tue, 22 Apr 2025 15:11:04 -0700 Subject: [PATCH 2/3] Improve the Dynamic Column Cypress Signed-off-by: Kishore Kumaar Natarajan --- cypress/e2e/1_top_queries.cy.js | 1 - 1 file changed, 1 deletion(-) diff --git a/cypress/e2e/1_top_queries.cy.js b/cypress/e2e/1_top_queries.cy.js index 09f17d29..91b1a571 100644 --- a/cypress/e2e/1_top_queries.cy.js +++ b/cypress/e2e/1_top_queries.cy.js @@ -114,7 +114,6 @@ describe('Query Insights Dashboard', () => { cy.contains('No items found'); }); - it('should paginate the query table', () => { for (let i = 0; i < 20; i++) { cy.searchOnIndex(indexName); From a2b8eba119cfe8ff845d74ef32157cb6c0a6b9fa Mon Sep 17 00:00:00 2001 From: Kishore Kumaar Natarajan Date: Tue, 22 Apr 2025 15:38:51 -0700 Subject: [PATCH 3/3] updated timestamp with old date Signed-off-by: Kishore Kumaar Natarajan --- cypress/fixtures/stub_top_queries.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cypress/fixtures/stub_top_queries.json b/cypress/fixtures/stub_top_queries.json index bfd8ef86..9b3608b6 100644 --- a/cypress/fixtures/stub_top_queries.json +++ b/cypress/fixtures/stub_top_queries.json @@ -3,7 +3,7 @@ "response": { "top_queries": [ { - "timestamp": 1745354380225, + "timestamp": 1443852054000, "id": "a2e1c822-3e3c-4d1b-adb2-9f73af094b43", "search_type": "query_then_fetch", "indices": [ @@ -34,7 +34,7 @@ } }, { - "timestamp": 1745352966702, + "timestamp": 1443852054000, "id": "130a5d36-615e-43e8-ad99-e1b90d527f44", "search_type": "query_then_fetch", "indices": [ @@ -64,7 +64,7 @@ } }, { - "timestamp": 1745354380225, + "timestamp": 1443852054000, "id": "a2e1c822-3e3c-4d1b-adb2-9f73af094b43", "search_type": "query_then_fetch", "indices": [ @@ -95,7 +95,7 @@ } }, { - "timestamp": 1745354384266, + "timestamp": 1443852054000, "id": "7cd4c7f1-3803-4c5e-a41c-258e04f96f78", "search_type": "query_then_fetch", "indices": [ @@ -126,7 +126,7 @@ } }, { - "timestamp": 1745353380505, + "timestamp": 1443852054000, "id": "76f5e51f-33f6-480c-8b20-8003abb93d19", "search_type": "query_then_fetch", "indices": [ @@ -158,7 +158,7 @@ } }, { - "timestamp": 1745353802101, + "timestamp": 1443852054000, "id": "37d633a7-20e6-41a1-96e9-cd4806511dbf", "search_type": "query_then_fetch", "indices": [ @@ -188,7 +188,7 @@ } }, { - "timestamp": 1745353548574, + "timestamp": 1443852054000, "id": "9982b7fc-0339-47d8-b77f-8de1bda76b72", "search_type": "query_then_fetch", "indices": [ @@ -218,7 +218,7 @@ } }, { - "timestamp": 1745351166704, + "timestamp": 1443852054000, "id": "d8dccf54-8dcb-4411-9fd6-977844be8fb3", "search_type": "query_then_fetch", "indices": [