You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The within/2 helper in that case would resolve into a CSS selector: #user .likes-count.
That means the underlying assert_has/3 functionality still relies on CSS selectors for assertions. I like that. It leaves the option open and flexible for people to use.
For some helpers, we'd can do something a bit more complex by adjusting assert_has to also take data structures that can then be transformed into strings.
For example, if we want to handle case #44 where we're targeting inputs by their label, I tested the following in. my prototype:
That input/1 helper would first find a label with text "Name", look for its for attribute (suppose it's user-name) and then generate a CSS selector like this: input#user-name[value="Jeff"]
What should we cover?
And I'd also love to know if we should be covering. So far, I'm thinking:
within: helpful for generating descendant selectors
If we introduce these helpers, it would be nice if they worked with other PhoenixTest helpers besides assert_has/refute_has. For example, it'd be nice to do click_button(within(...), "Save"). But I haven't tested that out in my prototype yet.
I'm open to suggestions/thoughts on what people think about the feel or ergonomics of the approach outlined above.
The text was updated successfully, but these errors were encountered:
This has now been superseded by improvements to assert_has and refute_has that take :count, :at as options. We still need to figure out how to target elements by label but that can be tracked on #44
I've been thinking of adding a set of CSS Selector helpers (for lack of a better word) that help in cases like #44 and #27.
Now I have a working prototype, but I'd like to make sure I'm covering all the existing cases.
It would work something like this:
The
within/2
helper in that case would resolve into a CSS selector:#user .likes-count
.That means the underlying
assert_has/3
functionality still relies on CSS selectors for assertions. I like that. It leaves the option open and flexible for people to use.For some helpers, we'd can do something a bit more complex by adjusting
assert_has
to also take data structures that can then be transformed into strings.For example, if we want to handle case #44 where we're targeting inputs by their label, I tested the following in. my prototype:
That
input/1
helper would first find alabel
with text "Name", look for itsfor
attribute (suppose it'suser-name
) and then generate a CSS selector like this:input#user-name[value="Jeff"]
What should we cover?
And I'd also love to know if we should be covering. So far, I'm thinking:
within
: helpful for generating descendant selectorsinput
: covers Devise a way to find form inputs by their associated labels #44 and is helpful when trying to test the contents of an inputdata
: easier to writedata-role
ordata-testid
when needednth_child
: covers Add an assertion helper for checking an element's children #27 and helpful if you care about the order of the children (e.g.nth_child("#table", "tr", 2)
or maybechild("#table, "tr", n: 2)
Open questions
assert_has
/refute_has
. For example, it'd be nice to doclick_button(within(...), "Save")
. But I haven't tested that out in my prototype yet.I'm open to suggestions/thoughts on what people think about the feel or ergonomics of the approach outlined above.
The text was updated successfully, but these errors were encountered: