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

Acceptance Testing with Async Content #78

Open
alexlafroscia opened this issue Mar 25, 2015 · 7 comments
Open

Acceptance Testing with Async Content #78

alexlafroscia opened this issue Mar 25, 2015 · 7 comments

Comments

@alexlafroscia
Copy link

I've been trying to acceptance test part of my app that uses a Promise to populate the multi-select. However, I can't seem to get it all working; it seems like when using click and fillIn, the dropdown with the selection options doesn't appear. Do you have any suggestions on how to get this working? I looked through all the test examples in the repo, but couldn't find anything that really matched my use case.

@lan0
Copy link

lan0 commented Apr 19, 2015

+1, have you found a solution yet?

@alexlafroscia
Copy link
Author

Nope, still haven't worked out a way to do this 😦

@lan0
Copy link

lan0 commented Apr 19, 2015

We think about switching to miguelcobain/ember-cli-selectize. Tests are a big deal!

@alexlafroscia
Copy link
Author

Oh cool, that does look good. Does it support testing in an easier way?

@lan0
Copy link

lan0 commented Apr 19, 2015

Yes, a test now looks like this:

visit('/select');
andThen(function() {
  find('.selectize-control').click();
  equal(find('.selectize-dropdown-content div:eq(0)').text(), 'Item 1');
  equal(find('.selectize-dropdown-content div:eq(1)').text(), 'Item 2');
});

And ember-select-2 uses a very similar API to ember-cli-selectize, so integration was straightforward.

@alexlafroscia
Copy link
Author

That's great, I'll definitely look into that then. Thanks!

@jniechcial
Copy link
Contributor

I managed to test in acceptance most of used behaviour. However, I did not used multiple option. Maybe these snippets will help you somehow.

Opening a dropdown with search input:

click(".select2-choice")
andThen ->
  # ready to go

Entering some content to search query:

searchInput = Ember.$(".select2-search:last input")
triggerEvent(searchInput, 'keydown')
fillIn(searchInput, "Some query")
triggerEvent(searchInput, 'keyup')
andThen ->
  # ready to go

Of coure, it is worth to wrap this code in some kind of helpers to reuse. The results from async API are obtainer by mocking the backend with proper payloads. Hope that helps.

@alexlafroscia alexlafroscia changed the title Acceptance Testing with Asynch Content Acceptance Testing with Async Content May 27, 2015
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

No branches or pull requests

3 participants