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

Rewrite E2E test suite #1075

Merged
merged 55 commits into from
Oct 26, 2022
Merged

Rewrite E2E test suite #1075

merged 55 commits into from
Oct 26, 2022

Conversation

klntsky
Copy link
Contributor

@klntsky klntsky commented Oct 1, 2022

Closes #1058 #989 #986

Pre-review checklist

  • All code has been formatted using our config (make format)
  • Any new API features or modification of existing behavior is covered as defined in our test plan
  • The changelog has been updated under the ## Unreleased header, using the appropriate sub-headings (### Added, ### Removed, ### Fixed), and the links to the appropriate issues/PRs have been included

@klntsky
Copy link
Contributor Author

klntsky commented Oct 4, 2022

Please share your suggestions on how to improve test coverage in a cheap way

@klntsky klntsky marked this pull request as ready for review October 4, 2022 15:12
@klntsky klntsky requested a review from jy14898 October 19, 2022 18:32
@amirmrad
Copy link
Collaborator

Puppeteer has a page.url() fn.
So there is no need for Aff. It might be a good idea to rewrite

findWalletPage :: Pattern -> Toppokki.Browser -> Aff (Maybe Toppokki.Page)
findWalletPage pattern browser = do
pages <- Toppokki.pages browser
walletPages <- fold <$> for pages \page -> do
try (pageUrl page) <#> hush >>> case _ of
Nothing -> []
Just url
| String.contains pattern url -> [ page ]
| otherwise -> []
into something like:

findWalletPage :: Pattern -> Toppokki.Browser -> Aff (Maybe Toppokki.Page)
findWalletPage pattern browser = do
  pages <- Toppokki.pages browser

  let walletPages = do
          page <- pages
          guard $ String.contains pattern (_url page)
          pure page
-- ...

where _url is foreign import _url :: Toppokki.Page -> String

@klntsky
Copy link
Contributor Author

klntsky commented Oct 21, 2022

It might be a good idea to rewrite

I don't agree, using a library function with the same purpose is better than using FFI.

@amirmrad
Copy link
Collaborator

Yes, but pageUrl is not a library function:

pageUrl :: Toppokki.Page -> Aff String
pageUrl page = do
  unsafeFromForeign <$> Toppokki.unsafeEvaluateStringFunction
    "document.location.href"
    page

Anyways, it's not a big deal, just something I noticed.

@@ -105,13 +74,13 @@ pageUrl page = do
-- | Wait until the wallet page pops up. Timout should be at least a few seconds.
-- | The 'String' param is the text of jQuery, which will be injected.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not relevant, there is no String param.

<> "; URL pattern: "
<> show (unwrap pattern)

foreign import pageUrl :: Toppokki.Page -> String
Copy link
Contributor

Choose a reason for hiding this comment

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

This should still be in Effect

@klntsky klntsky requested a review from jy14898 October 25, 2022 14:23
Copy link
Contributor

@jy14898 jy14898 left a comment

Choose a reason for hiding this comment

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

LGTM

@klntsky klntsky merged commit 886ac0a into develop Oct 26, 2022
klntsky added a commit that referenced this pull request Nov 16, 2022
@klntsky klntsky deleted the klntsky/rewrite-e2e branch February 1, 2023 11:16
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.

Develop a protocol for communications between E2E runner and the browser
4 participants