Skip to content
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

Merged
merged 1 commit into from
Dec 11, 2017

Conversation

zldavis
Copy link
Contributor

@zldavis zldavis commented Dec 8, 2017

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.

@@ -19,6 +21,7 @@ class Select extends React.Component {
};

static defaultProps = {
className: '',
Copy link
Contributor

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 ''

@@ -51,6 +54,8 @@ class Select extends React.Component {
const { value, ...props } = this.props;
Copy link
Contributor

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

@@ -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});
Copy link
Contributor

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

@@ -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;
Copy link
Contributor

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.
@zldavis zldavis force-pushed the zdAddSelectAsyncClass branch from fcd7110 to 47d963d Compare December 11, 2017 19:53
Copy link
Contributor

@gthomas-appfolio gthomas-appfolio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@gthomas-appfolio gthomas-appfolio merged commit f5e6d77 into master Dec 11, 2017
@gthomas-appfolio gthomas-appfolio deleted the zdAddSelectAsyncClass branch December 11, 2017 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants