-
Notifications
You must be signed in to change notification settings - Fork 919
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
[Discover 2.0 Testing] Create View List of Saved Queries Test (Test-Id 124: View list of Saved query) #9166
base: main
Are you sure you want to change the base?
[Discover 2.0 Testing] Create View List of Saved Queries Test (Test-Id 124: View list of Saved query) #9166
Conversation
Signed-off-by: Argus Li <[email protected]>
Signed-off-by: Argus Li <[email protected]>
Signed-off-by: Argus Li <[email protected]>
Signed-off-by: Argus Li <[email protected]>
Signed-off-by: Argus Li <[email protected]>
Signed-off-by: Argus Li <[email protected]>
Signed-off-by: Argus Li <[email protected]>
...rch-dashboards/opensearch-dashboards/apps/query_enhancements/field_display_filtering.spec.js
Show resolved
Hide resolved
cy.saveQuery(config.saveName); | ||
}); | ||
}); | ||
it('should see all saved queries', () => { |
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.
do we need ... for ${config.testName}
?
EDIT: Nevermind, it looks like this it
is not part of the testConfigurations.forEach()
. If so could we add a blank line between 87 and 88 just to make that a bit cle4ar (nitpick comment)
}); | ||
it('should see all saved queries', () => { | ||
cy.getElementByTestId('saved-query-management-popover-button').click({ | ||
force: true, |
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 is force: true
needed here?
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.
I had some issues where sometimes just clicking wouldn't open the popover. I will add a comment here to explain.
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.
if it was not working but the element not obstructed, i wonder if this works:
cy.getElementByTestId('saved-query-management-popover-button').should('be.visible').click()
(This will ensure it is visible in the DOM before clicking. i wonder if you are attempting to click it before it is visible)
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.
I tried again without the force and it's working now. I think this one leftover from when I was trying to debug an issue. Removing the force.
cy.getElementByTestId('saved-query-management-open-button').click(); | ||
|
||
//Wait for queries to load | ||
cy.wait(2000); |
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 arbitrary 2000, could we wait for some element to be loaded?
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.
This was left over from when I copied your structure for saved search. It doesn't seem needed for saved queries. Removing.
@@ -0,0 +1,105 @@ | |||
/* |
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.
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's a specific flag for saved_queries specifically, my first thought is that it makes sense to just separate the files based on the ui version for now, but if there are any other specs that use the same flag, then putting them into separate folders would be a good idea.
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.
...re-opensearch-dashboards/opensearch-dashboards/apps/query_enhancements/saved_queries.spec.js
Show resolved
Hide resolved
default: | ||
throw new Error(`getQueryString encountered unsupported language: ${language}`); | ||
} | ||
}; |
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.
(I can do this)
But it looks like this and some other functions are exactly the same as mine. I will make some refactor in the future to put them in shared.
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.
I've separated this function because I will be needing to make some changes to it and its associated functions for the specific queries in following saved queries tests.
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.
@ArgusLi Lets move all the utils inside to this path /cypress/utils/apps/query_enhancements
. That will help us to consolidate the utils method in one place.
@@ -125,33 +125,49 @@ Cypress.Commands.add( | |||
} | |||
); | |||
|
|||
Cypress.Commands.add('saveQuery', (name, description) => { | |||
Cypress.Commands.add('saveQueryOldUI', (name, description = ' ') => { |
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.
can we rename this to something else? I dont' have enough context, but what constitutes a 'new ui' vs old ui? I don't like OldUi
because in a few months/years, what we consider now to be newUi
will become oldUi
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 flag is data.savedQueriesNewUI.enabled: false
, which is why I named it as such. I agree though. Would love to discuss this offline with @LDrago27.
cy.whenTestIdNotFound('saved-query-management-popover', () => { | ||
cy.getElementByTestId('saved-query-management-popover-button').click(); | ||
}); | ||
cy.getElementByTestId('saved-query-management-save-button').click(); | ||
|
||
cy.getElementByTestId('saveQueryFormTitle').type(name); | ||
cy.getElementByTestId('saveQueryFormDescription').type(description); | ||
|
||
cy.getElementByTestId('savedQueryFormSaveButton').click({ force: true }); |
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 is force
needed? Typically, this is only needed if the element is hidden by some other element in the UI (like a popover). if so, then it is valid that it is needed but a comment should be there signifying why it's needed. Else we can just get rid of force: true
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.
I think this is actually left over from some testing. Will reverify and check.
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.
Confirmed. Removing.
cy.getElementByTestId('saveQueryFormTitle').type(name); | ||
cy.getElementByTestId('saveQueryFormDescription').type(description); | ||
|
||
cy.getElementByTestId('savedQueryFormSaveButton').click({ force: true }); |
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.
same forc
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.
I think this is actually left over from some testing. Will reverify and check.
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.
Confirmed, removing.
cy.getElementByTestId('editDatasourceDeleteIcon').click(); | ||
cy.getElementByTestId('confirmModalConfirmButton').click(); | ||
cy.getElementByTestId('editDatasourceDeleteIcon').click({ force: true }); | ||
cy.getElementByTestId('confirmModalConfirmButton').click({ force: true }); |
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.
if we remove deleteDataSourceByName
from the other places, these changes don't need to be here. But IF i'm wrong and deleteDataSourceByName
needs to be there, two things:
- lets get rid of
cy.wait(2000)
and replace it with waiting for some element to exist. - Lets get rid of
force: true
unless its really needed (and if so, add a comment why)
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.
Let me try again. The reason why this was here is because of some really weird behaviour from Cypress. The deleteSourceByName
was initially in the afterEach
block, but I changed it to the after
block instead. When it was in the afterEach
block, when the first saved query was created, it executed perfectly, but would fail the next time it was run after the next saved query was created.
I tried getting the element without a chained click, which would lead to Cypress' timeout and retry logic, but for some reason it still failed. I tried using waitForLoader but that didn't work either, which is when I shifted to the wait. But after that, it still failed when clicking the editDatasourceDeleteIcon
button - the button was selected, and was clicked, but no action actually happened. Which is why I had to use force: true
. The same thing happened for confirmModalConfirmButton
.
But none of these will happen now given it is only run once in the after block
so I'll try and see if removing them will work now.
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.
Yup, because it's only run once now, it works without these forces and waits. Removing the wait and forces.
Signed-off-by: Argus Li <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9166 +/- ##
=======================================
Coverage 61.01% 61.01%
=======================================
Files 3812 3813 +1
Lines 91385 91396 +11
Branches 14438 14439 +1
=======================================
+ Hits 55762 55769 +7
- Misses 32065 32068 +3
- Partials 3558 3559 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Signed-off-by: Argus Li <[email protected]>
} | ||
}; | ||
|
||
/** |
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.
nit: Update the comments to indicate it is for saved queries
instead of saved search
Signed-off-by: Argus Li <[email protected]>
Description
Adds a Cypress test suite for filtering in the Discover page.
Issues Resolved
Closes #8976.
Screenshot
newUICompressed.mp4
oldUICompressed.mp4
Testing the changes
With OSD running, run
yarn run cypress open
. In E2E specs, you will see 2 new test specssaved_queries.spec.js
andsaved_queries_old_ui.spec.js
. Runsaved_queries.spec.js
ifdata.savedQueriesNewUI.enabled: true
in the OSD config, else runsaved_queries_old_ui.spec.js
.Changelog