Skip to content
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

Extend set_value for use on check boxes, radio buttons and drop-down options #237

Closed
wants to merge 17 commits into from

Conversation

graeme-defty
Copy link
Contributor

No description provided.

@graeme-defty
Copy link
Contributor Author

graeme-defty commented May 13, 2017

Sorry for the clumsy gitting. (I tend to use BZR). I will try to do better in future. ;-)

@graeme-defty graeme-defty reopened this May 13, 2017
@PragTob
Copy link
Collaborator

PragTob commented May 13, 2017

@graeme-defty don't worrty about the git-ing too much, we usually squash commits which means that all of this will end up as a single commit on master 👍

@graeme-defty
Copy link
Contributor Author

graeme-defty commented May 13, 2017 via email

Copy link
Collaborator

@PragTob PragTob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me overall, I like the test coverage! I had some style comments, which is mostly due to us not having setup credo or some sort of linter yet. Sorry

Thank you very much for your contribution. I'd also wait for a review by @keathley as API vision et. al. still sit better with him, I'm rather new around this block her =D

I asked Nala though, and she likes your PR.

nala_yum_yum

.gitignore Outdated
@@ -3,6 +3,7 @@
/deps
erl_crash.dump
*.ez
mix.lock
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't wanna ignore mix.lock :)

In the Ruby world it's common and I used to do it, but I argued with José once and he had (of course!) very valid points, e.g. a common experience for maintainers etc. - so we'd wanna keep this around :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just read some of the discussions on this. Thanks for the pointer. (I should have guessed that it was needed by the fact that nobody ignored it yet - duh!)


assert page
|> find(Query.text_field("email"))
|> has_value?("c@keathley.io")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test confuses me a bit, it doesn't seem to call set_value at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I addressed this in response to your other point. Should I just remove this test or try to make it fit set_value?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think just removing it should be fien

describe "set_value/3" do
test "accepts a query", %{page: page} do
page
|> send_keys(Query.text_field("Name"), ["Chris", :tab, "c@keathley.io"])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there something specific here that we'd wanna use send_keys over fill_in for filling in the form fields?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied the test code from sends_keys and seem to have left this in as a hangover from that. To be honest, I would not have a test for "accepts a query", as I could not see what it was doing over and above the other tests. I kept it to stay consistent, but did not tailor it to set_value. Mea culpa.


assert page
|> find(Query.text_field("Name"))
|> has_value?("Chris")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry we don't have a code linter setup yet, but I think indentation wise we'd like this rather to be:

assert page
       |> call
       |> call

(goes for all stuff here) :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK - thanks. Noted for the future.

|> set_value(Query.option("Select Option 2"), :selected)
|> find(Query.option("Select Option 1"))
|> selected?()
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good amount of test coverage imo, thanks! 👍


assert page
|> find(Query.text_field("Name"))
|> has_value?("Chris")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also makes me think that maybe we should have a value option for queries (if we don't have that already) so that this could just be: assert_has(parent, Query.text_field("Name", value: "Chris")) but that's for another time :)

@graeme-defty
Copy link
Contributor Author

Thanks for the comments. Most importantly, if Nala likes it them I am happy!

What is the procedure now - do I make changes addressing your comments and re-submit the PR?

@PragTob
Copy link
Collaborator

PragTob commented May 14, 2017

@graeme-defty you make the changes addressing the comments, then you make a new commit with them and just push them to the branch again. We'll get them here and everything should be fine :)

@graeme-defty
Copy link
Contributor Author

OK - done!

# IO.warn "set_value/2 has been deprecated. Please use Element.set_value/2"
#
# Element.set_value(element, value)
# end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the commented out code be removed now?

@keathley, @PragTob Should this change be on Element.set_value instead Browser.set_value?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to keep this in the Browser module since it accepts queries. We will want to remove the commented out code.

Copy link
Member

@keathley keathley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We just need to update the docs and remove the commented out code and this should be good!

@@ -392,12 +392,37 @@ defmodule Wallaby.Browser do
@doc """
Sets the value of an element.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're explicitly looking for :selected and :unselected we'll want to call that out in the documentation.

@graeme-defty
Copy link
Contributor Author

graeme-defty commented May 15, 2017 via email

@graeme-defty
Copy link
Contributor Author

Documentation updated as requested

@PragTob
Copy link
Collaborator

PragTob commented May 15, 2017

I think this clashed with a merge to master now where selected? was removed from Browser #240 - so best to merge that inrebase against it and fix the tests relying on it :)

Sorry for the trouble @graeme-defty if you can't get to it one of us probably will :)

@graeme-defty
Copy link
Contributor Author

Let me try - my gitting skills could use the workout :-s

keathley and others added 2 commits May 16, 2017 08:04
* Remove select and selected?/1 from Browser module.

* Add negative tests for selected?/2 and selected?/1
@graeme-defty
Copy link
Contributor Author

Done! I still officially loathe git though. How on earth has it won over BZR? (Though I have to admit --rebase is pretty cool. Once I eventually got the incantation right, it just ... well ... worked! Maybe I will get used to it. ;-)

@keathley
Copy link
Member

keathley commented May 16, 2017

@graeme-defty No worries on the git stuff. I cleaned up your branch and merged everything here: e9f4e1a

Thanks 🎉

@keathley keathley closed this May 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants