-
-
Notifications
You must be signed in to change notification settings - Fork 294
Correct how the tags helper gets the text for tags #3398
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
Conversation
It was getting the `label` attribute of `.tagify__tag` elements before but so far as I can see `.tagify__tag` elements do not have a label. Because of that the tags helper was always returning an array of `nil` values (one for each tag). Instead I've changed them to get the text of the tag, which is what the `wait_for_tag_to_appear` and `wait_for_tag_to_disappear` helpers do. This correctly returns the text of the tag. It looks like this was not spotted before because the only test in the avo test suite that uses the tags helper just checks that an empty array of tags is returned.
Code Climate has analyzed commit c51917a and detected 0 issues on this pull request. View more on Code Climate. |
spec/system/avo/test_helpers_spec.rb
Outdated
it "verify tags" do | ||
visit avo.edit_resources_post_path(post) | ||
|
||
expect(tags(field: :tags)).to eq ["test", "five", "seven"] |
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.
It looks like in the test this is coming out as [“seven”, “five”, “test”]
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.
True, it was passing locally, but the tags field on the post has enforced suggestions so it's flaky... Just changed it to ["one", "two"]
should work as expected not
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.
I'm not sure why this wasn't causing the avo test suite to fail before, as there is a test for this helper and the other tags helpers (which return the result of the tags helper)
The test case wasn't covering it enough, thanks for this contribution @iainbeeston .
I've committed a test for it.
@iainbeeston this helper seems a bit unpredictable, it returns tags in different orders each time. Any ideas why? |
The other option would be to use the |
That was it, thanks for looking into this @iainbeeston ! |
Description
Fixes the tags test helper so it returns the text of each visible tag.
The tags helper was getting the
label
attribute of.tagify__tag
elements before but so far as I can see.tagify__tag
elements do not have a label. Because of that the tags helper was always returning an array ofnil
values (one for each tag). Instead I've changed them to get the text of the tag.I'm not sure why this wasn't causing the avo test suite to fail before, as there is a test for this helper and the other tags helpers (which return the result of the tags helper) but this seems to work for both the avo test suite and my own code (and matches what I can see when I try avo myself in the browser). It also matches what the
wait_for_tag_to_appear
helper does (ie. looks for tag text, not label).Fixes # (issue)
The tags test helper was always returning an array of
nil
values (one for each tag).Checklist:
Screenshots & recording
Manual review steps
So long as the avo test suite still passes this should be ok.
Manual reviewer: please leave a comment with output from the test if that's the case.