-
Notifications
You must be signed in to change notification settings - Fork 962
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 Filtering Test (TestId-69: Filtering) #9119
[Discover 2.0 Testing] Create Filtering Test (TestId-69: Filtering) #9119
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #9119 +/- ##
=======================================
Coverage 60.93% 60.93%
=======================================
Files 3809 3809
Lines 91267 91267
Branches 14413 14413
=======================================
+ Hits 55616 55618 +2
+ Misses 32097 32096 -1
+ Partials 3554 3553 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
* @param {string} expectedQueryHitsAfterFilterApplied expected number of hits in string after the filter is applied. Note you should add commas when necessary e.g. 9,999 | ||
*/ | ||
export function verifyDocTableFirstExpandedFieldFirstRowExistsFilterButtonFiltersCorrectField( | ||
docTableRowNumber, |
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 we need a specific utility for the first row?
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.
Moving it to the spec instead.
Signed-off-by: Federico Silva <[email protected]>
* Check if the first expanded Doc Table Field's first row's Filter For, Filter Out and Exists Filter buttons are disabled. | ||
* @param {boolean} isEnabled Boolean determining if these buttons are disabled | ||
*/ | ||
export function verifyDocTableFirstExpandedFieldFirstRowFilterForFilterOutExistsFilterButtons( |
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 we need a utility to check enable or disable? We can write directly in the test, right?
it('verifies filter buttons state', () => {
const shouldText = isEnabled ? 'be.enabled' : 'be.disabled';
cy.getElementByTestId('addInclusiveFilterButton').should(shouldText);
cy.getElementByTestId('removeInclusiveFilterButton').should(shouldText);
cy.getElementByTestId('addExistsFilterButton').should(shouldText);
});
* @param {string} expectedQueryHitsWithoutFilter expected number of hits in string after the filter is removed Note you should add commas when necessary e.g. 9,999 | ||
* @param {string} expectedQueryHitsAfterFilterApplied expected number of hits in string after the filter is applied. Note you should add commas when necessary e.g. 9,999 | ||
*/ | ||
export function verifyDocTableFirstExpandedFieldFirstRowFilterForButtonFiltersCorrectField( |
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 combine this filter for and filter out into one? and simplify toggle (exists) one to see if we combine all three?
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.
Ok I have combined for and out into one. The toggle is very different so I'm not combining it.
Signed-off-by: Federico Silva <[email protected]>
* @param {number} expandedDocumentRowNumber Integer starts from 0 for the first row | ||
* @param {string} expectedQueryHitsWithoutFilter expected number of hits in string after the filter is removed Note you should add commas when necessary e.g. 9,999 | ||
* @param {string} expectedQueryHitsAfterFilterApplied expected number of hits in string after the filter is applied. Note you should add commas when necessary e.g. 9,999 | ||
* @example verifyDocTableFirstExpandedFieldFirstRowFilterForButtonFiltersCorrectField('for', 0, 0, '10,000', '1'); |
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.
Nice! I did not know about @example
}); | ||
|
||
beforeEach(() => { | ||
cy.navigateToWorkSpaceHomePage(`${BASE_PATH}`, `${workspace}`); |
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 change this to navigateToWorkSpaceSpecificPage
with page: 'discover'
? See #9112 (comment) for rationale
@@ -162,3 +162,187 @@ function checkForElementVisibility() { | |||
} | |||
}); | |||
} | |||
|
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.
- All the newly added functions here are regular functions, not cypress commands. Since this file is
commands.js
, only Cypress.Commands.add functions should be here - So we got two options to rectify this. Either: 1) Make all these functions into cypress custom commands or 2) move these functions out to another file . I am going to vote for choice 2 for the following reason:
- Cypress best practices recommends it (See
1. Don't make everything a custom command
) (I personally feel that we use too much cypress commands in the codebase already)
- Cypress best practices recommends it (See
As to where we should move these... This is just a suggestion but what I did was create a utils
directory next to the tests itself: https://github.com/opensearch-project/OpenSearch-Dashboards/pull/9112/files#diff-80ee042bf13b443df19ca0fbb20fc6242ca982791beef74d65eb1d8d74f39f89
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 agree that we should move them to their own file. I will move them to a similarly named utils file.
expectedQueryHitsAfterFilterApplied: string, | ||
shouldMatch: boolean | ||
); | ||
verifyDocTableFirstExpandedFieldFirstRowToggleColumnButtonHasIntendedBehavior(); |
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.
Because these aren't Cypress custom commands, the types shouldn't be added here nested within declare namespace Cypress { interface Chainable
. Because then our IDEs think we can chain these off of cy
:
If you move these functions to a separate file, we don't need to create a typescript dec file for it, since you already JSDoc-annotated it
{ name: 'PPL', isFilterButtonsEnabled: false }, | ||
], | ||
}, | ||
}; |
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.
btw if my PR gets merged, you can leverage it: https://github.com/opensearch-project/OpenSearch-Dashboards/pull/9112/files#diff-d7928a5f6f39c85900fa1e53e0feef6c1c26ea04701b1eb658be5eb2e89d9bd1R104
For example, isFilterButtonsEnabled
in my datatype is here: https://github.com/opensearch-project/OpenSearch-Dashboards/pull/9112/files#diff-d7928a5f6f39c85900fa1e53e0feef6c1c26ea04701b1eb658be5eb2e89d9bd1R54
@@ -30,10 +30,49 @@ Cypress.Commands.add('getElementsByTestIds', (testIds, options = {}) => { | |||
return cy.get(selectors.join(','), options); | |||
}); | |||
|
|||
Cypress.Commands.add('getElementByDataTestId', (testId) => { | |||
return cy.get(`[data-testid="${testId}"]`); | |||
/** |
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 doesn't appear these JSDocs help with IDEs, at least on my machine. Since these aren't regular functions, I don't think JSDocs will help us here. Could we remove them and instead add the typings to here? https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/cypress/utils/index.d.ts
Signed-off-by: Federico Silva <[email protected]>
Signed-off-by: Argus Li <[email protected]>
…pensearch-project#9119) * Add test for filtering functionality for discover, which enables query enhancement * Make test more robust: Add logic to use date picker start and end buttons if set to absolute times. Check the table length directly instead of number of hits to avoid bug where not all results load. --------- Signed-off-by: Argus Li <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Signed-off-by: Federico Silva <[email protected]>
…pensearch-project#9119) * Add test for filtering functionality for discover, which enables query enhancement * Make test more robust: Add logic to use date picker start and end buttons if set to absolute times. Check the table length directly instead of number of hits to avoid bug where not all results load. --------- Signed-off-by: Argus Li <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> Signed-off-by: Federico Silva <[email protected]>
…pensearch-project#9119) * Add test for filtering functionality for discover, which enables query enhancement * Make test more robust: Add logic to use date picker start and end buttons if set to absolute times. Check the table length directly instead of number of hits to avoid bug where not all results load. --------- Signed-off-by: Argus Li <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
…ing backports (#9261) * [Discover] Makes caching dataset options optional (#8799) * [Discover] Makes caching dataset options optional. * Adds unit test * Changeset file for PR #8799 created/updated * Update test Signed-off-by: Kawika Avilla <[email protected]> --------- Signed-off-by: Kawika Avilla <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> Co-authored-by: Kawika Avilla <[email protected]> * Upgrade Cypress to v12 (#8995) * Update Cypress to v12 (#8926) * Update cypress to v12 Signed-off-by: Daniel Rowe <[email protected]> * Add required e2e.js Signed-off-by: Daniel Rowe <[email protected]> * Changeset file for PR #8926 created/updated * Update license header Signed-off-by: Daniel Rowe <[email protected]> * Update license in e2e.js Signed-off-by: Daniel Rowe <[email protected]> --------- Signed-off-by: Daniel Rowe <[email protected]> Signed-off-by: Daniel Rowe <[email protected]> Co-authored-by: Daniel Rowe <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> * fix: support imports without extensions in cypress webpack build (#8993) * fix: support imports without extensions in cypress webpack build Signed-off-by: Daniel Rowe <[email protected]> * Changeset file for PR #8993 created/updated * use typescript config Signed-off-by: Daniel Rowe <[email protected]> * fix lint Signed-off-by: Daniel Rowe <[email protected]> * disable new test isolation feature This isolation was causing regressions Signed-off-by: Daniel Rowe <[email protected]> --------- Signed-off-by: Daniel Rowe <[email protected]> Signed-off-by: Daniel Rowe <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> --------- Signed-off-by: Daniel Rowe <[email protected]> Signed-off-by: Daniel Rowe <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> * [Discover Test] TestID-69: Filtering. Add data-test-subj tags. (#9027) * Update Cypress to v12 (#8926) * Update cypress to v12 Signed-off-by: Daniel Rowe <[email protected]> * Add required e2e.js Signed-off-by: Daniel Rowe <[email protected]> * Changeset file for PR #8926 created/updated * Update license header Signed-off-by: Daniel Rowe <[email protected]> * Update license in e2e.js Signed-off-by: Daniel Rowe <[email protected]> --------- Signed-off-by: Daniel Rowe <[email protected]> Signed-off-by: Daniel Rowe <[email protected]> Co-authored-by: Daniel Rowe <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> * fix: support imports without extensions in cypress webpack build (#8993) * fix: support imports without extensions in cypress webpack build Signed-off-by: Daniel Rowe <[email protected]> * Changeset file for PR #8993 created/updated * use typescript config Signed-off-by: Daniel Rowe <[email protected]> * fix lint Signed-off-by: Daniel Rowe <[email protected]> * disable new test isolation feature This isolation was causing regressions Signed-off-by: Daniel Rowe <[email protected]> --------- Signed-off-by: Daniel Rowe <[email protected]> Signed-off-by: Daniel Rowe <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> * Add data-test-subj tags. Signed-off-by: Argus Li <[email protected]> --------- Signed-off-by: Daniel Rowe <[email protected]> Signed-off-by: Daniel Rowe <[email protected]> Signed-off-by: Argus Li <[email protected]> Co-authored-by: Daniel Rowe <[email protected]> Co-authored-by: Daniel Rowe <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> * Migrate query enhancement tests from functional repo to main (#9048) * migrate query enhacenement tests Signed-off-by: abbyhu2000 <[email protected]> * ignore lint in data files Signed-off-by: abbyhu2000 <[email protected]> * remove yarn lock changes Signed-off-by: abbyhu2000 <[email protected]> * add changelog Signed-off-by: abbyhu2000 <[email protected]> --------- Signed-off-by: abbyhu2000 <[email protected]> * Add missing data-test-subj tags for discover plugin (#9049) * Add data-test-subj for discover Signed-off-by: Anan Zhuang <[email protected]> * fix comment Signed-off-by: Anan Zhuang <[email protected]> --------- Signed-off-by: Anan Zhuang <[email protected]> * Add missing data-test-subj tags for data plugin (#9051) * Add missing data-test-subj tags for data plugin * Update Snapshots * Fix as per the comments --------- Signed-off-by: Suchit Sahoo <[email protected]> Co-authored-by: Anan Zhuang <[email protected]> * Follow up on #9048 by updating data and utilities (#9060) * Follow up on #9048 by updating data and utilities Feature branch PRs: #9038 #9006 Signed-off-by: Anan <[email protected]> * fix comment Signed-off-by: Anan <[email protected]> * update path and add utility from suchit commit Signed-off-by: Anan <[email protected]> * update the path to run sample test Signed-off-by: Anan <[email protected]> * fix PR comments Signed-off-by: Anan <[email protected]> * skip tests before enable workspace Signed-off-by: Anan <[email protected]> --------- Signed-off-by: Anan <[email protected]> * refactor some query-enhancement utility functions, add some missing typings (#9074) * refactor some query-enhancement utility functions, add some missing typings Signed-off-by: Justin Kim <[email protected]> * Changeset file for PR #9074 created/updated --------- Signed-off-by: Justin Kim <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> * add queryEditorLanguageOptions data-test-subj on language_selector.tsx (#9029) Signed-off-by: Federico Silva <[email protected]> Co-authored-by: Federico Silva <[email protected]> * Re-enable dataset_selector.spec.js and queries.spec.js under workspace (#9082) * Re-enable dataset_selector.spec.js and queries.spec.js under workspace Signed-off-by: Anan <[email protected]> * fix comment Signed-off-by: Anan <[email protected]> * add verifyHitCount for PPL Signed-off-by: Anan <[email protected]> * Changeset file for PR #9082 created/updated --------- Signed-off-by: Anan <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> * Make createWorkspaceIndexPatterns to handle no default cluster and clean up (#9129) * Make createWorkspaceIndexPatterns to handle no default cluster and clean up Signed-off-by: Anan <[email protected]> * Changeset file for PR #9129 created/updated --------- Signed-off-by: Anan <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> * add data-test-subj (#9135) Signed-off-by: Federico Silva <[email protected]> * [Discover] Adding Cypress Tests for S3 Datasets (#9113) * [Discover 2.0 Testing] Create Filtering Test (TestId-69: Filtering) (#9119) * Add test for filtering functionality for discover, which enables query enhancement * Make test more robust: Add logic to use date picker start and end buttons if set to absolute times. Check the table length directly instead of number of hits to avoid bug where not all results load. --------- Signed-off-by: Argus Li <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> * Add tests for saved search creation and loading for query enhancement (#9112) * Add tests for saved search creation and loading for query enhancement * click on a random element before typing on query editor to bypass the popover that appears * address pr comments - refactor to create saved search as an api call * address pr comments - specifically navigate to discover page before setting datasource Signed-off-by: Justin Kim <[email protected]> --------- Signed-off-by: Justin Kim <[email protected]> Signed-off-by: Anan Zhuang <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> Co-authored-by: Anan Zhuang <[email protected]> * fix: 0 rendered in discover when there are no results (#9153) * fix: 0 rendered in discover when there are no results Signed-off-by: Daniel Rowe <[email protected]> * Changeset file for PR #9153 created/updated --------- Signed-off-by: Daniel Rowe <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> * [Cypress][Fix] Update saved search utilities (#9151) * update saved search * minor refactor4 on setDatePickerDatesAndSearchIfRelevant Signed-off-by: Justin Kim <[email protected]> --------- Signed-off-by: Justin Kim <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> * chore: use relative paths in cypress (#9079) * chore: use relative paths in cypress when we move to running tests in parallel we won't be able to use a single hardcoded basepath as these can differ by tasks Signed-off-by: Daniel Rowe <[email protected]> * Changeset file for PR #9079 created/updated --------- Signed-off-by: Daniel Rowe <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> * [Discover 2.0 Testing] Create View List of Saved Queries Test (Test-Id 124: View list of Saved query) (#9166) * add spec for old ui Signed-off-by: Argus Li <[email protected]> * Add comment about cleaning up saved queries Signed-off-by: Argus Li <[email protected]> * Add data-test-subj for save query new ui Signed-off-by: Argus Li <[email protected]> * Add data-test-subj for save query button for new ui Signed-off-by: Argus Li <[email protected]> * Add data-test-subj for open query button in query management popover Signed-off-by: Argus Li <[email protected]> * Add new ui spec to test list saved queries Signed-off-by: Argus Li <[email protected]> * Fix DataSource url Signed-off-by: Argus Li <[email protected]> * Changeset file for PR #9166 created/updated * Address Justin's comments. Signed-off-by: Argus Li <[email protected]> * Remove final force. Signed-off-by: Argus Li <[email protected]> * Fix final force. Signed-off-by: Argus Li <[email protected]> * Move utils to Suchit's suggested location, fix comments Signed-off-by: Argus Li <[email protected]> * Rename specs, change cypress workflow to use new save query ui, merge old ui and new ui commands Signed-off-by: Argus Li <[email protected]> * fix import Signed-off-by: Argus Li <[email protected]> --------- Signed-off-by: Argus Li <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> * change casing to folder structures to be compliant with our rules (#9197) Signed-off-by: Justin Kim <[email protected]> * [Fix] Saved Search Integ Test Update: update saving a new saved search test spec (#9200) * wait for the page to be loaded before loading a saved search * when loading a saved search and saving it as a new saved search, use a different name Signed-off-by: Justin Kim <[email protected]> --------- Signed-off-by: Justin Kim <[email protected]> * refactor query enhancement tests (#9208) Signed-off-by: Justin Kim <[email protected]> * chore: change casing of data-logs to be compliant with our git hook rules (#9220) Signed-off-by: Justin Kim <[email protected]> * chore: remove unused/redundant functions from field_display_filtering utils (#9219) Signed-off-by: Justin Kim <[email protected]> * Create cypress command namespacing util (#9150) * update cy.createInitialWorkspaceWithDataSource -> cy.osd.createInitialWorkspaceWithDataSource (#9262) Signed-off-by: Justin Kim <[email protected]> --------- Signed-off-by: Kawika Avilla <[email protected]> Signed-off-by: Daniel Rowe <[email protected]> Signed-off-by: Daniel Rowe <[email protected]> Signed-off-by: Argus Li <[email protected]> Signed-off-by: abbyhu2000 <[email protected]> Signed-off-by: Anan Zhuang <[email protected]> Signed-off-by: Suchit Sahoo <[email protected]> Signed-off-by: Anan <[email protected]> Signed-off-by: Justin Kim <[email protected]> Signed-off-by: Federico Silva <[email protected]> Signed-off-by: Federico Silva <[email protected]> Co-authored-by: Ashwin P Chandran <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> Co-authored-by: Kawika Avilla <[email protected]> Co-authored-by: Daniel Rowe <[email protected]> Co-authored-by: Argus Li <[email protected]> Co-authored-by: Daniel Rowe <[email protected]> Co-authored-by: Qingyang(Abby) Hu <[email protected]> Co-authored-by: Suchit Sahoo <[email protected]> Co-authored-by: Justin Kim <[email protected]> Co-authored-by: Federico Silva <[email protected]> Co-authored-by: Federico Silva <[email protected]> Co-authored-by: Federico Silva <[email protected]> Co-authored-by: Sean Li <[email protected]> Co-authored-by: d rowe <[email protected]>
Description
Adds a Cypress test suite for filtering in the Discover page.
Issues Resolved
Closes #8945.
Screenshot
720-1.mov
720-2.mov
720-3.mov
720-4.mov
720-5.mov
720-6.mov
720-7.mov
720-8.mov
Testing the changes
With OSD running, run
yarn run cypress open
. In E2E specs, you will see a new test specfield_display_filter.spec.js
. Select it and run it.Changelog