bug fixes: async, markup, Poltergeist (plus methods for checking state)#15
Open
eostrom wants to merge 4 commits into
Open
bug fixes: async, markup, Poltergeist (plus methods for checking state)#15eostrom wants to merge 4 commits into
eostrom wants to merge 4 commits into
Conversation
The scenario: press a button that (perhaps via AJAX) causes a select2
with a label to appear asynchronously. This test would fail:
click_button('Make a Select2')
select2('My Choice', from: 'The Newly Created Select2')
because the label isn't present immediately, and `first("label", ...)`
doesn't wait for the label to appear. `find` does.
This change will cause an error to be raised if there's more than one label
with the given text. The solution here is to limit the scope using
`within`, and/or use a selector instead of text to find the select2.
The previous code expected the select2 to be inside the innermost div containing the label. That won't necessarily hold for all scenarios (for example, the "Inline Labels" markup for Zurb Foundation). So now we use the label to find the element that it gives focus to, and then search up the DOM to find the select2-container.
In the single-select scenario, we clicked the "choice" element (to open the dropdown), then clicked it again during the "values" loop. This probably works on some Capybara drivers, but Poltergeist noticed that the second time we tried to click, the choice element was obscured by select2's dropdown mask. There's no reason to click the choice element twice in the single-select UI. But we do need to click it once for each value in the multiple-select UI. So now we just check which UI is in use, and act appropriately. BTW, we do the single-select click *before* we enter the search term. I suspect search doesn't work in the multiple-select UI, but it didn't work before this change, either.
Useful for examining the select2's current state.
It would probably be better to have a single method
expect_select2('Expected Value(s)', from: 'My Select')
but I haven't done that yet.
|
👍 This makes capybara-select2 work with poltergeist. Thank You |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See the respective commits. Sorry these aren't all separate pull requests; I just had to get this all working for my project, so it's all in one branch.