Skip to content

[Improvement] Improved Cypress test that validates the dynamic column #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 31 additions & 29 deletions cypress/e2e/1_top_queries.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
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);
Expand Down Expand Up @@ -44,7 +44,7 @@
/**
* Validate the main overview page loads correctly
*/
it('should display the main overview page', () => {

Check warning on line 47 in cypress/e2e/1_top_queries.cy.js

View workflow job for this annotation

GitHub Actions / Run lint

Test has no assertions
cy.get('.euiBasicTable').should('be.visible');
cy.contains('Query insights - Top N queries');
cy.url().should('include', '/queryInsights');
Expand Down Expand Up @@ -82,7 +82,7 @@
});
});

it('should switch between tabs', () => {

Check warning on line 85 in cypress/e2e/1_top_queries.cy.js

View workflow job for this annotation

GitHub Actions / Run lint

Test has no assertions
// Click Configuration tab
cy.getElementByText('.euiTab', 'Configuration').click({ force: true });
cy.contains('Query insights - Configuration');
Expand All @@ -93,27 +93,55 @@
cy.url().should('include', '/queryInsights');
});

it('should filter queries', () => {

Check warning on line 96 in cypress/e2e/1_top_queries.cy.js

View workflow job for this annotation

GitHub Actions / Run lint

Test has no assertions
cy.get('.euiFieldSearch').should('be.visible');
cy.get('.euiFieldSearch').type('sample_index');
// Add assertions for filtered results
cy.get('.euiTableRow').should('have.length.greaterThan', 0);
});

it('should clear the search input and reset results', () => {

Check warning on line 103 in cypress/e2e/1_top_queries.cy.js

View workflow job for this annotation

GitHub Actions / Run lint

Test has no assertions
cy.get('.euiFieldSearch').type('random_string');
cy.get('.euiTableRow').should('have.length.greaterThan', 0);
cy.get('.euiFieldSearch').clear();
cy.get('.euiTableRow').should('have.length.greaterThan', 0);
});

it('should display a message when no top queries are found', () => {

Check warning on line 110 in cypress/e2e/1_top_queries.cy.js

View workflow job for this annotation

GitHub Actions / Run lint

Test has no assertions
clearAll();
cy.wait(10000);
cy.reload();
cy.contains('No items found');
});

it('should paginate the query table', () => {

Check warning on line 117 in cypress/e2e/1_top_queries.cy.js

View workflow job for this annotation

GitHub Actions / Run lint

Test has no assertions
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();
Expand Down Expand Up @@ -142,16 +170,6 @@
});

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);
Expand All @@ -171,9 +189,6 @@
});
});
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();
Expand All @@ -197,17 +212,4 @@
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());
});
252 changes: 252 additions & 0 deletions cypress/fixtures/stub_top_queries.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
{
"ok": true,
"response": {
"top_queries": [
{
"timestamp": 1443852054000,
"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": 1443852054000,
"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": 1443852054000,
"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": 1443852054000,
"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": 1443852054000,
"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": 1443852054000,
"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": 1443852054000,
"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": 1443852054000,
"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"
}
}
}
]
}
}
Loading