-
Notifications
You must be signed in to change notification settings - Fork 9
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
Fix dynamically display columns #103
base: main
Are you sure you want to change the base?
Fix dynamically display columns #103
Conversation
Signed-off-by: Kishore Kumaar Natarajan <kkamazonn@amazon.com>
Signed-off-by: Kishore Kumaar Natarajan <kkamazonn@amazon.com>
Signed-off-by: Kishore Kumaar Natarajan <kkamazonn@amazon.com>
Why are the latency, cpu and memory columns displayed twice in each screenshot? @KishoreKicha14 |
If it’s not too big a change, we can debate about changing the column names to average latency, average cpu…… and so on for only groups? What do others think about this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the issues @deshsidd mentioned above, the rest of the logic looks good to me!
@KishoreKicha14 Thanks for the change, could you also add unit tests and cypress tests in this PR as well?
@@ -259,6 +275,15 @@ const QueryInsights = ({ | |||
truncateText: true, | |||
}, | |||
]; | |||
const columnsToShow = selectedFilter === 'SIMILARITY' ? groupColumns : queryColumns; | |||
const filteredQueries = queries.filter((query) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about
const filteredQueries = queries.filter(query =>
!selectedFilter || query.group_by === selectedFilter
);
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
Signed-off-by: Kishore Kumaar Natarajan <kkamazonn@amazon.com>
Signed-off-by: Kishore Kumaar Natarajan <kkamazonn@amazon.com>
cypress/e2e/1_top_queries.cy.js
Outdated
@@ -22,7 +22,7 @@ const clearAll = () => { | |||
}; | |||
|
|||
describe('Query Insights Dashboard', () => { | |||
// Setup before each test | |||
// // Setup before each test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
cypress/e2e/1_top_queries.cy.js
Outdated
cy.contains('.euiTableHeaderCell', header).should('exist'); | ||
}); | ||
}); | ||
beforeEach(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need beforeEach here? this looks identical to
beforeEach(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
cypress/e2e/1_top_queries.cy.js
Outdated
cy.get('.euiFilterSelectItem').contains('group').click(); | ||
|
||
// Wait for table update | ||
cy.get('.euiTableHeaderCell').should('have.length.lessThan', 20); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why dont we assert a fixed length here? The number of headers in each scenarios should be deterministic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to fixed length
cypress/e2e/1_top_queries.cy.js
Outdated
]; | ||
|
||
// Wait for the table to load by checking if headers are visible | ||
cy.get('.euiTableHeaderCell').should('have.length.greaterThan', 6); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why greater then instead of equals?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to fixed length
|
||
await waitFor(() => expect(screen.getByRole('table')).toBeInTheDocument()); | ||
const headers = await waitFor(() => screen.getAllByRole('columnheader', { hidden: false })); | ||
console.log( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the console log.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
const expectedHeaders = ['ID', 'Type', 'Query Count', 'Latency', 'CPU Time', 'Memory Usage']; | ||
expectedHeaders.forEach((header) => { | ||
expect( | ||
headers.some((h) => h.textContent?.trim().toLowerCase() === header.toLowerCase()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why headers.some
?
we should also compare the actual value without ignoring the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modified
renderQueryInsights(); | ||
await waitFor(() => expect(screen.getByRole('table')).toBeInTheDocument()); | ||
const typeElements = screen.getAllByText('Type'); | ||
const typeFilterButton = typeElements.find((el) => el.closest('button')); // Ensure it's a button |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a button. why use closest
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
|
||
await waitFor(() => { | ||
expectedHeaders.forEach(async (header) => { | ||
expect(await screen.findByText(header)).toBeInTheDocument(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of finding on the whole screen and assert to be in document, could you narrow down the test to that specific table?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modified
]; | ||
|
||
await waitFor(() => { | ||
expectedHeaders.forEach(async (header) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, the sequence matters here. let's also test the header sequence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modified checking sequence as well
cypress/e2e/1_top_queries.cy.js
Outdated
|
||
// Verify each expected header exists | ||
expectedHeaders.forEach((header) => { | ||
cy.contains('.euiTableHeaderCell', header).should('exist'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sequence matters here. let's also test the header sequence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modified checking sequence as well
Signed-off-by: kishore.nat98@gmail.com <kkamazonn@amazon.com>
Signed-off-by: kishore.nat98@gmail.com <kkamazonn@amazon.com>
Signed-off-by: kishore.nat98@gmail.com <kkamazonn@amazon.com>
Signed-off-by: kishore.nat98@gmail.com <kkamazonn@amazon.com>
Cypress tests failing, please take a look |
@KishoreKicha14 Looks like this change might not be addressed? Please update the screenshots based on the latest code if these have been addressed. Thanks |
Should we have separate columns for average latency and average CPU, or should the column names dynamically change? The challenge arises when both group and query are selected. How should we handle this? |
column names can dynamically change when only groups data is in the table. |
discussed this with @ansjcy , and he mentioned regarding column naming: Only groups selected → Show averaged column names (e.g., "Average Latency," "Average CPU"). |
For both can use the same approach we have today, i.e Latency, etc. |
Signed-off-by: kishore.nat98@gmail.com <kkamazonn@amazon.com>
Signed-off-by: kishore.nat98@gmail.com <kkamazonn@amazon.com>
Discussed with UX offline, we agreed to use: |
Description
Problem:
The Top N queries table can display:
Only queries
Only groups
Combination of queries/groups
Some columns are applicable to only queries (eg: indices) and others to only groups (eg: query count).
Table should dynamically display the applicable columns based on the data in the table and only display the applicable columns.
This PR ensures that even when no selection is made and all query types are groups, the applicable columns are dynamically displayed.
Issues Resolved
Closes: [#45]
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.