-
Notifications
You must be signed in to change notification settings - Fork 4
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
[DT-777] Filter by participant count #2733
Conversation
# Conflicts: # src/components/data_search/DatasetFilterList.jsx
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.
Looks OK, just a few misc comments.
} else { | ||
if (filters[category]) { |
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 would combine an if
after an else
here
} else { | |
if (filters[category]) { | |
} else if (filters[category]) { |
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 like most of @pshapiro4broad 's suggestions! The only one I'm not sure about is the filterHandler
refactor.
import DatasetFilterList from '../../../src/components/data_search/DatasetFilterList'; | ||
|
||
const duosUser = { |
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.
unused
# Conflicts: # cypress/component/DataSearch/dataset_search_filters.spec.js
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.
Looks good, glad to see that the flaky tests have been fixed
const anyFiltersSelected = (filters) => { | ||
return Object.values(filters).some((filter) => { |
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.
For a single line lambda, you can omit the { return }
const anyFiltersSelected = (filters) => { | |
return Object.values(filters).some((filter) => { | |
const anyFiltersSelected = (filters) => | |
Object.values(filters).some((filter) => { |
I know in terra-ui this was the standard, not sure if duos-ui has an opinion about this.
cy.intercept( | ||
{method: 'POST', url: '**/search/index'}, (req) => { | ||
return handler(req, '{"range":{"participantCount":{"gte":null,"lte":50}}}'); | ||
}).as('searchIndex1'); |
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.
Is it required that searchIndex1
must be different than searchIndex2
in the other test? I would expect the alias names to be independent across tests so the same name could be used for both.
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.
good question, no I don't think so I just changed them to detangle as part of the debugging effort but I can change them back now
cy.wait('@searchIndex').then((response) => { | ||
expect(response.response.body[0]).to.equal('filtered'); | ||
}); | ||
cy.get('@searchIndex.all').should('have.length', 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.
I can see that this test does pass, but I'm confused as to what the .all
part of this alias selector is doing and where it is defined.
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 I found why it is undocumented:
- Document @alias.all and @alias.2 cypress-io/cypress-documentation#1573
- [WIP] Enable aliases names to contain the dot character cypress-io/cypress#3929 (comment)
Since .all
is experimental, I would recommend looking into a different approach to this specific 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.
Here's another approach, less concise, but uses documented cypress features:
let count = 0;
cy.wait('@searchIndex').then((response) => {
expect(response.response.body[0]).to.equal('filtered');
count++;
});
cy.get('@searchIndex').then(() => {
expect(count).to.equal(1);
});
}).as('searchIndex'); | ||
mount(<DatasetSearchTable {...props} />); | ||
// first clear the default value (100), without clearing first, type('50') would result in input of 10050 | ||
cy.get('#participantCountMax-range-input').clear().type('50'); |
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.
Cypress recommends not chaining calls after clear. It's a little more verbose, but safer to:
const range = cy.get('#participantCountMax-range-input');
range.clear();
range.type('50');
mount(<DatasetSearchTable {...props} />); | ||
// first clear the default value (100), without clearing first, type('50') would result in input of 10050 | ||
cy.get('#participantCountMax-range-input').clear().type('50'); | ||
cy.tick(150); |
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.
Cypress recommends that there be a clock
command that precedes the tick
command: https://docs.cypress.io/api/commands/tick
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 use the clock command in the before each method, but I could move it into each individual 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.
Thank you, I did miss that. No need if it's there, that should cover it.
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.
See comments inline, looks good, thank you 👍🏽
Addresses
Jira Ticket: https://broadworkbench.atlassian.net/browse/DT-777
Summary
Adds a filter for participant size
DatasetSearchTable:
DatasetFilterList
Testing
Unit tests
Note: cy.clock() is needed to mock the clock for debounced calls
Visual
Screen.Recording.2024-11-21.at.9.59.40.AM.mov
Have you read Terra's Contributing Guide lately? If not, do that first.