-
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
Add class to Select component when in Async mode for testing #343
Conversation
src/components/Select.js
Outdated
@@ -19,6 +21,7 @@ class Select extends React.Component { | |||
}; | |||
|
|||
static defaultProps = { | |||
className: '', |
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 using classNames I think you can skip the default value of ''
src/components/Select.js
Outdated
@@ -51,6 +54,8 @@ class Select extends React.Component { | |||
const { value, ...props } = this.props; |
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.
You can instead do:
const { className, value, ...props } = this.props;
and remove the delete
below
src/components/Select.js
Outdated
@@ -51,6 +54,8 @@ class Select extends React.Component { | |||
const { value, ...props } = this.props; | |||
delete props.onChange; // don't pass onChange prop to react-select | |||
const SelectElement = this.props.loadOptions ? ReactSelect.Async : ReactSelect; | |||
const className = classNames(this.props.className, {'js-SelectAsync': this.props.loadOptions}); |
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.
could we rename something more generic like select-async
, etc as this will help if we rewrite or replace with React Select
src/components/Select.js
Outdated
@@ -51,6 +54,8 @@ class Select extends React.Component { | |||
const { value, ...props } = this.props; | |||
delete props.onChange; // don't pass onChange prop to react-select | |||
const SelectElement = this.props.loadOptions ? ReactSelect.Async : ReactSelect; | |||
const className = classNames(this.props.className, {'js-SelectAsync': this.props.loadOptions}); | |||
delete props.className; |
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 above
This would simplify testing when this component is used in selenium tests. We can wait for the result set to be loaded, but doing so would require that change to made in every place this is being used in tests. Adding this class would allow the page object to be able to check itself and every test would benefit automatically.
fcd7110
to
47d963d
Compare
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 would simplify testing when this component is used in selenium tests. We can wait for the result set to be loaded, but doing so would require that change to made in every place this is being used in tests. Adding this class would allow the page object to be able to check itself and every test would benefit automatically.