Should Checkbox `checked` filter also exclude any indeterminate checkboxes
Checkbox has two different flags checked and indeterminate both can be in two states
-
checked=falseandindeterminate=false
-
checked=trueandindeterminate=false
-
checked=falseandindeterminate=true
-
checked=trueandindeterminate=true
As you can see the indeterminate has higher priority for UI view. And it doesn't matter if a checkbox has checked or not when indeterminate is true. User sees only a checkbox in an indeterminate state.
For now, Checkbox interactor doesn't check the indeterminate state for the checked filter. And if user has the checkbox in forth case the Checkbox({ checked: true }).exists() doesn't throw an exception. But for a real user, who works in a browser, the view will be different, he sees only a checkbox in an indeterminate state.
Should we change Checkbox interactor's checked filter API?
There are possible variants:
- 👀
checked: (element) => element.checked && !element.indeterminate - 👍
checked: (element) => element.indeterminate ? 'indeterminate' : element.checked
I'm generally in favor of the idea that the filter should be not just a reflection of the DOM values, but of what the user sees. It feels like option (2) is the right API.
My biggest question though is will this introduce awkwardness into tests written in TypeScript because the type is now essentially boolean | 'indeterminate' which is not something you see every day. The only thing I can really see it being weird is that you would no longer be able to use it with boolean matchers. But does such a thing exist?
We can add a special enum for that. But it requires to do a few of changes to matchers and output formaters