2023-09-29 05:14:09 +00:00
|
|
|
module Puppeteer.Spec where
|
|
|
|
|
|
|
|
import Prelude
|
|
|
|
|
2023-09-29 22:32:24 +00:00
|
|
|
import Data.Newtype (unwrap)
|
2023-09-29 05:14:09 +00:00
|
|
|
import Effect (Effect)
|
|
|
|
import Effect.Aff (Aff)
|
|
|
|
import Effect.Class (liftEffect)
|
|
|
|
import Puppeteer as Pup
|
|
|
|
import Puppeteer.Browser as Pup.Browser
|
2023-09-29 22:32:24 +00:00
|
|
|
import Puppeteer.Browser.Spec as Spec.Browser
|
2023-09-30 03:33:55 +00:00
|
|
|
import Puppeteer.Handle.Spec as Spec.Handle
|
2023-09-29 22:32:24 +00:00
|
|
|
import Puppeteer.Page.Spec as Spec.Page
|
2023-10-03 21:25:12 +00:00
|
|
|
import Puppeteer.Plugin.Spec as Spec.Plugin
|
2023-09-29 22:32:24 +00:00
|
|
|
import Puppeteer.Selector.Spec as Spec.Selector
|
2023-09-30 03:36:12 +00:00
|
|
|
import Test.Spec (SpecT, describe, mapSpecTree)
|
2023-09-29 05:14:09 +00:00
|
|
|
import Test.Spec.Assertions (shouldEqual)
|
|
|
|
import Test.Util (test)
|
|
|
|
|
|
|
|
spec :: SpecT Aff Unit Effect Unit
|
|
|
|
spec = describe "Puppeteer" do
|
|
|
|
test "launch" do
|
2023-10-03 21:25:12 +00:00
|
|
|
pup <- Pup.new
|
2023-09-29 05:14:09 +00:00
|
|
|
map void Pup.launch_ pup
|
|
|
|
|
|
|
|
test "connect" do
|
2023-10-03 21:25:12 +00:00
|
|
|
pup <- Pup.new
|
2023-09-29 05:14:09 +00:00
|
|
|
|
|
|
|
b1 <- Pup.launch_ pup
|
|
|
|
ws <- liftEffect $ Pup.Browser.websocketEndpoint b1
|
|
|
|
|
|
|
|
liftEffect do
|
|
|
|
shouldEqual true <=< Pup.Browser.connected $ b1
|
|
|
|
Pup.Browser.disconnect b1
|
|
|
|
shouldEqual false <=< Pup.Browser.connected $ b1
|
|
|
|
|
|
|
|
b2 <- Pup.connect (Pup.connectDefault $ Pup.BrowserWebsocket ws) pup
|
|
|
|
Pup.Browser.close b2
|
2023-09-29 22:32:24 +00:00
|
|
|
|
|
|
|
Spec.Browser.spec
|
|
|
|
Spec.Page.spec
|
2023-09-30 03:33:55 +00:00
|
|
|
Spec.Handle.spec
|
2023-10-03 21:25:12 +00:00
|
|
|
Spec.Plugin.spec
|
2023-09-29 22:32:24 +00:00
|
|
|
mapSpecTree (pure <<< unwrap) identity Spec.Selector.spec
|