phoenix_test icon indicating copy to clipboard operation
phoenix_test copied to clipboard

Feature request: `assert_checked/{2,3}` and `refute_checked/{2,3}`

Open s3cur3 opened this issue 8 months ago • 1 comments

Hi German!

I've been testing a bunch of complicated forms recently, where changing one control can affect the state of checkboxes elsewhere in the form. It'd be nice to have a assert_checked/refute_checked functions that use the same logic as check/{3,4} for going from the label of a checkbox to the checkbox input itself. The current workaround requires grabbing the ID or input name of the checkbox, which seems counter to the philosophy of the library.

I'm happy to submit a PR if this is something you'd like. ☺️

s3cur3 avatar Apr 29 '25 14:04 s3cur3

@s3cur3 sorry for taking so long to respond. Been busy.

Yes, I recently introduced the ability to assert a field's value in 515242d by pointing at the label. It abuses assert_has a little bit, but it doesn't require us to introduce a new helper.

I'm wondering if we should do the same in this case.

assert_has(session, ".user", checked: true, label: "Frodo")

I think my ultimate ideal for the library would be to do something like

assert_has(session, checkbox("Frodo", checked: true))

but maybe this gets us one step closer to that.

What do you think? Interested in opening that PR?

germsvel avatar May 26 '25 08:05 germsvel