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

Testing multiple date pickers #231

Open
lindyhopchris opened this issue Sep 11, 2019 · 2 comments · May be fixed by #379
Open

Testing multiple date pickers #231

lindyhopchris opened this issue Sep 11, 2019 · 2 comments · May be fixed by #379

Comments

@lindyhopchris
Copy link

So I ran into a bit of a gotcha today with testing multiple date-pickers. This is probably because I've been doing something wrong!

Basically my tests for a component with multiple date pickers didn't close the date picker between selecting dates on two different inputs. This worked fine in Ember 3.8, but when upgrading to Ember 3.12 it doesn't. The solution was to close the date picker after choosing the first date and before selecting the second date.

As I say, not really a bug with this addon because it makes sense that actually I should have closed the datepicker originally. But it made me think of two things...

Firstly, maybe the readme should be clear about this? I.e. say that the datepicker needs to be closed if testing with multiple dates? If so, I can do a PR to add that.

Secondly, a lot of my tests now look like this:

await click('input[name="start"]');
await Pikaday.selectDate(new Date(2019, 5, 1));
await closePikaday();

await click('input[name="expiry"]');
await Pikaday.selectDate(new Date(2019, 9, 1));
await closePikaday();

Is it worth having a test helper that does these three steps in one helper? Say it was called fillInDate (not bothered about the name), then the above code could be re-written to:

await fillInDate('input[name="start"]', new Date(2019, 5, 1));
await fillInDate('input[name="expiry"]', new Date(2019, 5, 1));

Just an idea, I'm happy to do a PR if you think something like that would be worth adding.

@jrjohnson
Copy link
Contributor

@lindyhopchris I ran into this today when migrating from the old test helpers. Thanks for pointing me to a solution!

I think adding the fillInDate helper would be a great addition here. Since my tests are now full of the same repetitive three step process.

I know it's been a while so if you're not interested in doing that work anymore let me know and I'll give it a shot.

@lindyhopchris
Copy link
Author

@jrjohnson glad me creating this issue helped you!

I'm just catching up with open source tasks this week, so have submitted a PR for the new test helper.

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 a pull request may close this issue.

2 participants