-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(material-experimental): add test harness for radio-group #16609
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
feat(material-experimental): add test harness for radio-group #16609
Conversation
9fd3e0c
to
3903848
Compare
@@ -6,6 +6,11 @@ | |||
* found in the LICENSE file at https://angular.io/license | |||
*/ | |||
|
|||
export type RadioGroupHarnessFilters = { |
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 kind of feels like id
and name
should just be things you can do with normal selectors and shouldn't need a special filter option, e.g.
const myIdLoader = await loader.getChildLoader('#my-id')
const harness = myIdLoader.getHarness(RadioGroupHarness);
There is a problem with this currently though, which is that getHarness
searches for the harness on an element under the root of the loader. So if my-id
is the id of your radio group, it won't check that element, just the ones under it. Maybe getHarness
should check the given element and anything under it? That would eliminate the need for these filters I think
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.
For this case it is a bit more special though because the name
or id
is not necessarily set on the radio-group
or radio-button
element, but rather on the underlying input.
So if someone queries a radio-group by name, we check if it has a DOM attribute or find the right group by respecting the name
attribute for child radio-buttons in groups.
Another pain point here is that if someone sets the radio-group name through an input binding, the name
attribute will not be set. There is no host-binding for that. That's why we need to respect the inputs of child radio-button's.
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.
Ah I see that's a good point, I wonder if I should add similar ones for checkbox. It will probably have the same issue if people want to search by name...
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.
Good point. I will double-check on that and make a note.
Follow-up for 583af19. This commit introduces a new test harness for the `mat-radio-group` implementation. Note that we can't provide harness methods for getting the selected value because the selected value or the value of a radio-button are part of the component-internal state (no way to determine from DOM)
Currently a `mat-radio-button` does not respect the value binding that has been set on the radio-button. This is not ideal because in most cases the value is a primitive that can be set as `value` for the underlying input element in order to ensure that proper `FormData` can be retrieved when the form gets submitted. Currently the form data will always have `on` as value because the selected radio-button does not pass-through the value to the underlying input.
3903848
to
6aa4ac2
Compare
Caretaker note: we should preserve both commits in this PR.. as one commit changes the radio-button template to properly pass-through the |
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.
LGTM
…by name Adds an option to the checkbox harnesses that allows developers to filter harnesses by checkbox names. This is helpful because developers can not filter checkboxes by name using CSS selectors because the `name` input binding is not bound to the host DOM element. Similar to angular#16609 (comment)
…by name Adds an option to the checkbox harnesses that allows developers to filter harnesses by checkbox names. This is helpful because developers can not filter checkboxes by name using CSS selectors because the `name` input binding is not bound to the host DOM element. Similar to angular#16609 (comment)
…by name Adds an option to the checkbox harnesses that allows developers to filter harnesses by checkbox names. This is helpful because developers can not filter checkboxes by name using CSS selectors because the `name` input binding is not bound to the host DOM element. Similar to angular#16609 (comment)
…by name Adds an option to the checkbox harnesses that allows developers to filter harnesses by checkbox names. This is helpful because developers can not filter checkboxes by name using CSS selectors because the `name` input binding is not bound to the host DOM element. Similar to angular#16609 (comment)
Adds an option to the checkbox harnesses that allows developers to filter harnesses by checkbox names. This is helpful because developers can not filter checkboxes by name using CSS selectors because the `name` input binding is not bound to the host DOM element. Similar to #16609 (comment)
Adds an option to the checkbox harnesses that allows developers to filter harnesses by checkbox names. This is helpful because developers can not filter checkboxes by name using CSS selectors because the `name` input binding is not bound to the host DOM element. Similar to #16609 (comment) (cherry picked from commit 2cbabf0)
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Follow-up for 583af19. This PR introduces a new test
harness for the
mat-radio-group
implementation.Note that we can't provide harness methods for getting the selected
value because the selected value or the value of a radio-button are
part of the component-internal state (no way to determine from DOM)