Skip to content

add clickOn function (closes #1405)#1408

Merged
MaxGabriel merged 5 commits intoyesodweb:masterfrom
mwotton:master
Jun 21, 2017
Merged

add clickOn function (closes #1405)#1408
MaxGabriel merged 5 commits intoyesodweb:masterfrom
mwotton:master

Conversation

@mwotton
Copy link
Copy Markdown
Contributor

@mwotton mwotton commented Jun 14, 2017

No description provided.

, rbdGets = rbdGets rbd ++ H.parseQuery (TE.encodeUtf8 urlQuery)
}

clickOn :: Yesod site => Query -> YesodExample site ()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you add documentation for this, and an @since Haddock annotation? Ideally the documentation would include a small example like most of the rest of yesod-test has (You could just copy an example from your tests and that would be fine)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Whichever Github user @since is, I bet they get a lot of spurious notifications 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good catch, forgot about that one :)

yit "can follow a link via clickOn" $ do
get ("/htmlWithLink" :: Text)
clickOn "a#thelink"
statusIs 200
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this test that the actual new page is returned after the link is clicked?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Probably. Would be nice to just check URL of the last response, but i can't seem to do that - i'll check the content instead.

@@ -1,3 +1,7 @@
## 1.5.7

* Add clickOn
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you link to this PR in the changelog so people can get further details? Just line for 1.5.4

@mwotton
Copy link
Copy Markdown
Contributor Author

mwotton commented Jun 21, 2017

this seems to be failing because of a CI timeout. @MaxGabriel - could you poke travis?

-- ==== __ Examples__
--
-- > get "/foobar"
-- > clickOn "a#idofthelink"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you add an @since annotation here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

@MaxGabriel
Copy link
Copy Markdown
Member

Yes, poked. I made one more comment about a missing @since annotation

case findAttributeBySelector (simpleBody res) query "href" of
Left err -> failure $ query <> " did not parse: " <> T.pack (show err)
Right [[match]] -> get match
Right matches -> failure $ "Expected exactly one match for clickOn: got " <> T.pack (show matches)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I really like this implementation, very clean pattern matching.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thanks :)

@MaxGabriel MaxGabriel merged commit 0223c0a into yesodweb:master Jun 21, 2017
@MaxGabriel
Copy link
Copy Markdown
Member

Great PR!

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.

2 participants