-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[FEATURE] ember-testing-checkbox-helpers #10287
[FEATURE] ember-testing-checkbox-helpers #10287
Conversation
@tomdale addresses #9798 (comment) |
@seanpdoyle Seems legit, would you mind writing down somewhere the answer to the other question? I want to make sure we all have the same mental model.
|
$el.prop('checked', true).change(); | ||
}); | ||
if (!$el.prop('checked')) { | ||
run('click', app, selector, context); |
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.
This needs to run through app.testHelpers.click
. Something like app.testHelpers.click(selector, context)
.
fixes emberjs#9798 (emberjs#9798 (comment)) When test driving, `click` and `unclick` are useful for ensuring the state of a form. ```javascript export default DS.Model.extend({ title: DS.attr(), body: DS.attr(), isDraft: DS.attr("boolean", defaultValue: false) }); test("doesn't publish posts in draft mode", function() { fillIn("#title", "this post is hidden"); fillIn("#body", "this won't be displayed"); check("#is-draft"); click("#submit"); andThen(function() { equal(find(".post:contains('this post is hidden')").length, 0); }); }); ``` `check` and `uncheck` allow the test to remain unchanged if the `defaultValue` of `isDraft` changes from `false` to `true`. The test only cares that: * when `click("#submit")` executes, the `#is-draft` checkbox is `checked` * `isDraft` is true
45efdf3
to
f21d70f
Compare
@tomdale I've updated the commit message and PR body to provide an example use case |
[FEATURE] ember-testing-checkbox-helpers
@seanpdoyle - Thanks for updating, we'll review this feature again for go/no-go (and potentially more work) at the next core team meeting. |
This feature has ended up being surprisingly controversial at the core team meetings. ;) After a lengthy discussion, we reached consensus that, in the example you gave ( We did reach consensus that we would like the
We believe that the above implementation strikes the best balance between explicitness and clarity, and expressiveness. What do you think? |
@tomdale I like it. Does this mean that the |
@seanpdoyle - Yes, assert that it is unchecked before |
emberjs#10287 (comment) > We did reach consensus that we would like the check() and uncheck() > helpers to be a combination of setting the value and asserting it > becomes a specific value. In the case of check(): > > Before mutating the value, assert that the checkbox is unchecked. > Simulate a click event on the checkbox. > Assert that the checkbox has been checked (to catch, for example, > the disabled case). > -- tomdale
Address concerns that helpers could behave differently than real users.
fixes #9798 (#9798 (comment))
When test driving,
click
andunclick
are useful for ensuring thestate of a form.
check
anduncheck
allow the test to remain unchanged if thedefaultValue
ofisDraft
changes fromfalse
totrue
.The test only cares that:
click("#submit")
executes, the#is-draft
checkbox ischecked
isDraft
is true