mirror of
https://github.com/klntsky/purescript-playwright.git
synced 2024-11-22 13:23:01 +03:00
prettier, purs, explicit imports, format ci
This commit is contained in:
parent
6d0aba0f34
commit
eecec566f5
34
.github/workflows/ci.yml
vendored
34
.github/workflows/ci.yml
vendored
@ -11,11 +11,29 @@ jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Run tests
|
||||
run: |
|
||||
PATH="$PATH:./node_modules/.bin/"
|
||||
npm install
|
||||
npm install spago@next purescript
|
||||
npx playwright install --with-deps chromium
|
||||
spago test
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ github.head_ref }}
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "18.x"
|
||||
- run: npm install
|
||||
- run: npm install purescript
|
||||
- run: npx playwright install --with-deps chromium
|
||||
- run: npx spago@next test
|
||||
|
||||
format:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ github.head_ref }}
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "18.x"
|
||||
- run: npm run format
|
||||
- name: Commit changes
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
commit_message: Apply formatting changes
|
||||
branch: ${{ github.head_ref }}
|
||||
|
@ -10,7 +10,8 @@
|
||||
"playwright": "^1.45.1"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "pulp test"
|
||||
"test": "npx spago@next test",
|
||||
"format": "npx prettier --write src/**/*.js test/**/*.js; npx purs-tidy format-in-place src/**/*.purs test/**/*.purs"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -1,19 +1,19 @@
|
||||
/* global exports */
|
||||
|
||||
export const exposeBinding_ = x => name => cb => opts => () => {
|
||||
export const exposeBinding_ = (x) => (name) => (cb) => (opts) => () => {
|
||||
return x.exposeBinding(
|
||||
name,
|
||||
function (info, arg) {
|
||||
return cb(info)(arg)()
|
||||
return cb(info)(arg)();
|
||||
},
|
||||
opts
|
||||
)
|
||||
}
|
||||
opts,
|
||||
);
|
||||
};
|
||||
|
||||
export const onResponse = function (page) {
|
||||
return function (cb) {
|
||||
return function () {
|
||||
page.on('response', function (response) {
|
||||
page.on("response", function (response) {
|
||||
cb(response)();
|
||||
});
|
||||
};
|
||||
|
@ -47,11 +47,9 @@ module Playwright
|
||||
, fill
|
||||
, focus
|
||||
, onResponse
|
||||
, connect
|
||||
, module Playwright.Data
|
||||
, module Playwright.Options
|
||||
)
|
||||
where
|
||||
) where
|
||||
|
||||
import Playwright.Options
|
||||
|
||||
@ -60,14 +58,14 @@ import Data.String.Regex (Regex)
|
||||
import Data.Unit (unit)
|
||||
import Effect (Effect)
|
||||
import Effect.Aff (Aff)
|
||||
import Foreign (Foreign, unsafeToForeign)
|
||||
import Foreign (Foreign)
|
||||
import Literals.Null (Null)
|
||||
import Node.Buffer (Buffer)
|
||||
import Playwright.Data (Browser, BrowserContext, BrowserType, ConsoleMessage, Dialog, Download, ElementHandle, ElementState, FileChooser, Frame, JSHandle, Keyboard, Modifier, Mouse, MouseButton, Page, Raf, Request, Response, Route, ScreenshotType, Selector(..), Selectors, URL(..), WaitUntil, Worker, alt, attached, chromium, control, detached, domcontentloaded, firefox, hidden, jpg, left, load, meta, middle, networkidle, png, raf, right, shift, visible, webkit)
|
||||
import Playwright.Internal (effCall, effProp, affCall)
|
||||
import Prelude (Unit, ($))
|
||||
import Untagged.Castable (class Castable)
|
||||
import Untagged.Union (type (|+|), UndefinedOr)
|
||||
import Untagged.Union (type (|+|))
|
||||
import Playwright.Types (Cookie)
|
||||
|
||||
foreign import onResponse :: Page -> (Response -> Effect Unit) -> Effect Unit
|
||||
@ -75,19 +73,28 @@ foreign import onResponse :: Page -> (Response -> Effect Unit) -> Effect Unit
|
||||
fill
|
||||
:: forall o
|
||||
. Castable o FillOptions
|
||||
=> Page -> Selector -> String -> o -> Aff Unit
|
||||
=> Page
|
||||
-> Selector
|
||||
-> String
|
||||
-> o
|
||||
-> Aff Unit
|
||||
fill = affCall "fill" \_ -> fill
|
||||
|
||||
focus
|
||||
:: forall o
|
||||
. Castable o FocusOptions
|
||||
=> Page -> Selector -> o -> Aff Unit
|
||||
=> Page
|
||||
-> Selector
|
||||
-> o
|
||||
-> Aff Unit
|
||||
focus = affCall "focus" \_ -> focus
|
||||
|
||||
launch
|
||||
:: forall o
|
||||
. Castable o LaunchOptions
|
||||
=> BrowserType -> o -> Aff Browser
|
||||
=> BrowserType
|
||||
-> o
|
||||
-> Aff Browser
|
||||
launch =
|
||||
affCall "launch" \_ -> launch
|
||||
|
||||
@ -102,10 +109,6 @@ connect
|
||||
-> Aff Browser
|
||||
connect = affCall "connect" \_ -> connect
|
||||
|
||||
type ConnectOptions =
|
||||
{ timeout :: UndefinedOr Number
|
||||
}
|
||||
|
||||
connectOverCDP
|
||||
:: forall o
|
||||
. Castable o ConnectOverCDPOptions
|
||||
@ -116,14 +119,11 @@ connectOverCDP
|
||||
connectOverCDP =
|
||||
affCall "connectOverCDP" \_ -> connectOverCDP
|
||||
|
||||
type ConnectOverCDPOptions =
|
||||
{ timeout :: UndefinedOr Number
|
||||
}
|
||||
|
||||
close
|
||||
:: forall x
|
||||
. Castable x (Browser |+| BrowserContext |+| Page)
|
||||
=> x -> Aff Unit
|
||||
=> x
|
||||
-> Aff Unit
|
||||
close =
|
||||
affCall "close" \_ -> close
|
||||
|
||||
@ -143,21 +143,27 @@ newPage
|
||||
:: forall x o
|
||||
. Castable x (Browser |+| BrowserContext)
|
||||
=> Castable o NewpageOptions
|
||||
=> x -> o -> Aff Page
|
||||
=> x
|
||||
-> o
|
||||
-> Aff Page
|
||||
newPage =
|
||||
affCall "newPage" \_ -> newPage
|
||||
|
||||
goForward
|
||||
:: forall o
|
||||
. Castable o GoOptions
|
||||
=> Page -> o -> Aff (Null |+| Response)
|
||||
=> Page
|
||||
-> o
|
||||
-> Aff (Null |+| Response)
|
||||
goForward =
|
||||
affCall "goForward" \_ -> goForward
|
||||
|
||||
goBack
|
||||
:: forall o
|
||||
. Castable o GoOptions
|
||||
=> Page -> o -> Aff (Null |+| Response)
|
||||
=> Page
|
||||
-> o
|
||||
-> Aff (Null |+| Response)
|
||||
goBack =
|
||||
affCall "goBack" \_ -> goBack
|
||||
|
||||
@ -165,7 +171,10 @@ goto
|
||||
:: forall x o
|
||||
. Castable x (Page |+| Frame)
|
||||
=> Castable o GotoOptions
|
||||
=> x -> URL -> o -> Aff (Null |+| Response)
|
||||
=> x
|
||||
-> URL
|
||||
-> o
|
||||
-> Aff (Null |+| Response)
|
||||
goto =
|
||||
affCall "goto" \_ -> goto
|
||||
|
||||
@ -189,7 +198,9 @@ hover
|
||||
:: forall x o
|
||||
. Castable x (Page |+| Frame |+| ElementHandle)
|
||||
=> Castable o HoverOptions
|
||||
=> x -> o -> Aff Unit
|
||||
=> x
|
||||
-> o
|
||||
-> Aff Unit
|
||||
hover =
|
||||
affCall "hover" \_ -> hover
|
||||
|
||||
@ -197,7 +208,10 @@ innerHTML
|
||||
:: forall x o
|
||||
. Castable x (Page |+| Frame)
|
||||
=> Castable o InnerHTMLOptions
|
||||
=> x -> Selector -> o -> Aff String
|
||||
=> x
|
||||
-> Selector
|
||||
-> o
|
||||
-> Aff String
|
||||
innerHTML =
|
||||
affCall "innerHTML" \_ -> innerHTML
|
||||
|
||||
@ -228,7 +242,9 @@ name = effCall "name" \_ -> name
|
||||
query
|
||||
:: forall x
|
||||
. Castable x (ElementHandle |+| Page |+| Frame)
|
||||
=> x -> Selector -> Aff (Null |+| ElementHandle)
|
||||
=> x
|
||||
-> Selector
|
||||
-> Aff (Null |+| ElementHandle)
|
||||
query =
|
||||
affCall "$" \_ -> query
|
||||
|
||||
@ -236,7 +252,9 @@ query =
|
||||
queryMany
|
||||
:: forall x
|
||||
. Castable x (ElementHandle |+| Page |+| Frame)
|
||||
=> x -> Selector -> Aff (Array ElementHandle)
|
||||
=> x
|
||||
-> Selector
|
||||
-> Aff (Array ElementHandle)
|
||||
queryMany =
|
||||
affCall "$$" \_ -> queryMany
|
||||
|
||||
@ -244,14 +262,18 @@ screenshot
|
||||
:: forall x o
|
||||
. Castable x (ElementHandle |+| Page)
|
||||
=> Castable o ScreenshotOptions
|
||||
=> x -> o -> Aff Buffer
|
||||
=> x
|
||||
-> o
|
||||
-> Aff Buffer
|
||||
screenshot =
|
||||
affCall "screenshot" \_ -> screenshot
|
||||
|
||||
textContent
|
||||
:: forall x
|
||||
. Castable x (Page |+| Frame |+| ElementHandle)
|
||||
=> x -> Selector -> Aff (Null |+| String)
|
||||
=> x
|
||||
-> Selector
|
||||
-> Aff (Null |+| String)
|
||||
textContent =
|
||||
affCall "textContent" \_ -> textContent
|
||||
|
||||
@ -413,11 +435,13 @@ setInputFiles
|
||||
=> Castable f
|
||||
( String
|
||||
|+| Array String
|
||||
|+| { name :: String
|
||||
|+|
|
||||
{ name :: String
|
||||
, mimeType :: String
|
||||
, buffer :: Buffer
|
||||
}
|
||||
|+| Array { name :: String
|
||||
|+| Array
|
||||
{ name :: String
|
||||
, mimeType :: String
|
||||
, buffer :: Buffer
|
||||
}
|
||||
@ -450,9 +474,7 @@ exposeBinding
|
||||
=> x
|
||||
-> String
|
||||
-- ^ Name of the function on the window object.
|
||||
->
|
||||
(
|
||||
{ browserContext :: BrowserContext
|
||||
-> ( { browserContext :: BrowserContext
|
||||
, page :: Page
|
||||
, frame :: Frame
|
||||
}
|
||||
@ -467,9 +489,7 @@ foreign import exposeBinding_
|
||||
:: forall x a b
|
||||
. x
|
||||
-> String
|
||||
->
|
||||
(
|
||||
{ browserContext :: BrowserContext
|
||||
-> ( { browserContext :: BrowserContext
|
||||
, page :: Page
|
||||
, frame :: Frame
|
||||
}
|
||||
|
@ -15,9 +15,24 @@ type ConsoleMessageLocation =
|
||||
}
|
||||
|
||||
data ConsoleMessageType
|
||||
= Log | Debug | Info | Error | Warning | Dir | Dirxml | Table | Trace | Clear
|
||||
| StartGroup | StartGroupCollapsed | EndGroup | Assert | Profile | ProfileEnd
|
||||
| Count | TimeEnd
|
||||
= Log
|
||||
| Debug
|
||||
| Info
|
||||
| Error
|
||||
| Warning
|
||||
| Dir
|
||||
| Dirxml
|
||||
| Table
|
||||
| Trace
|
||||
| Clear
|
||||
| StartGroup
|
||||
| StartGroupCollapsed
|
||||
| EndGroup
|
||||
| Assert
|
||||
| Profile
|
||||
| ProfileEnd
|
||||
| Count
|
||||
| TimeEnd
|
||||
|
||||
derive instance genericConsoleMessageType :: Generic ConsoleMessageType _
|
||||
derive instance eqConsoleMessageType :: Eq ConsoleMessageType
|
||||
|
@ -1,5 +1,9 @@
|
||||
/* global require exports */
|
||||
import { chromium as pwChromium, firefox as pwFirefox, webkit as pwWebkit } from 'playwright';
|
||||
import {
|
||||
chromium as pwChromium,
|
||||
firefox as pwFirefox,
|
||||
webkit as pwWebkit,
|
||||
} from "playwright";
|
||||
|
||||
export const png = "png";
|
||||
export const jpg = "jpg";
|
||||
|
@ -1,8 +1,6 @@
|
||||
module Playwright.Data where
|
||||
|
||||
import Prelude
|
||||
import Untagged.TypeCheck (class HasRuntimeType)
|
||||
import Foreign (Foreign)
|
||||
|
||||
foreign import data BrowserType :: Type
|
||||
foreign import data Browser :: Type
|
||||
@ -29,11 +27,13 @@ foreign import png :: ScreenshotType
|
||||
foreign import jpg :: ScreenshotType
|
||||
|
||||
newtype Selector = Selector String
|
||||
|
||||
derive newtype instance eqSelector :: Eq Selector
|
||||
derive newtype instance showSelector :: Show Selector
|
||||
derive newtype instance ordSelector :: Ord Selector
|
||||
|
||||
newtype URL = URL String
|
||||
|
||||
derive newtype instance eqURL :: Eq URL
|
||||
derive newtype instance showURL :: Show URL
|
||||
derive newtype instance ordURL :: Ord URL
|
||||
|
@ -1,10 +1,10 @@
|
||||
/* global exports */
|
||||
|
||||
export const createReadStream_ = Nothing => Just => Download => () =>
|
||||
Download.createReadStream().then(result => {
|
||||
export const createReadStream_ = (Nothing) => (Just) => (Download) => () =>
|
||||
Download.createReadStream().then((result) => {
|
||||
if (result === null) {
|
||||
return Nothing
|
||||
return Nothing;
|
||||
} else {
|
||||
return Just(result)
|
||||
return Just(result);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
@ -6,8 +6,7 @@ module Playwright.Download
|
||||
, url
|
||||
, failure
|
||||
, delete
|
||||
)
|
||||
where
|
||||
) where
|
||||
|
||||
import Control.Promise (Promise, toAffE)
|
||||
import Data.Maybe (Maybe(..))
|
||||
|
@ -2,6 +2,6 @@
|
||||
|
||||
export const onForeign = (obj) => (eventName) => (effCallback) => () => {
|
||||
obj.on(eventName, (argument) => {
|
||||
effCallback(argument)()
|
||||
})
|
||||
}
|
||||
effCallback(argument)();
|
||||
});
|
||||
};
|
||||
|
@ -1,5 +1,4 @@
|
||||
module Playwright.Event
|
||||
where
|
||||
module Playwright.Event where
|
||||
|
||||
import Type.Proxy (Proxy(..))
|
||||
import Effect (Effect)
|
||||
@ -8,112 +7,167 @@ import Playwright.Data (Browser, BrowserContext, ConsoleMessage)
|
||||
import Playwright.Data as Data
|
||||
import Effect.Exception (Error)
|
||||
|
||||
class Event :: forall k. k -> Constraint
|
||||
class Event e where
|
||||
getEventName :: Proxy e -> String
|
||||
|
||||
class OnEvent :: forall k1 k2 k3. k1 -> k2 -> k3 -> Constraint
|
||||
class Event e <= OnEvent x e a | x e -> a
|
||||
|
||||
-- | Our own `Proxy` for event names.
|
||||
data EventName :: forall k. k -> Type
|
||||
data EventName a = EventName
|
||||
|
||||
foreign import data Close :: Type
|
||||
instance eventClose :: Event Close where getEventName _ = "close"
|
||||
|
||||
instance eventClose :: Event Close where
|
||||
getEventName _ = "close"
|
||||
|
||||
instance eventPageClose :: OnEvent Data.Page Close Unit
|
||||
instance eventBrowserContextClose :: OnEvent BrowserContext Close Unit
|
||||
instance eventBrowserClose :: OnEvent Browser Close Unit
|
||||
instance eventWorkerClose :: OnEvent Worker Close Unit
|
||||
|
||||
close :: EventName Close
|
||||
close = EventName
|
||||
|
||||
foreign import data Console :: Type
|
||||
instance eventConsole :: Event Console where getEventName _ = "console"
|
||||
|
||||
instance eventConsole :: Event Console where
|
||||
getEventName _ = "console"
|
||||
|
||||
instance eventPageConsole :: OnEvent Data.Page Console ConsoleMessage
|
||||
|
||||
console :: EventName Console
|
||||
console = EventName
|
||||
|
||||
foreign import data Crash :: Type
|
||||
instance eventCrash :: Event Crash where getEventName _ = "crash"
|
||||
|
||||
instance eventCrash :: Event Crash where
|
||||
getEventName _ = "crash"
|
||||
|
||||
instance eventPageCrash :: OnEvent Data.Page Crash Unit
|
||||
|
||||
crash :: EventName Crash
|
||||
crash = EventName
|
||||
|
||||
foreign import data Dialog :: Type
|
||||
instance eventDialog :: Event Dialog where getEventName _ = "dialog"
|
||||
|
||||
instance eventDialog :: Event Dialog where
|
||||
getEventName _ = "dialog"
|
||||
|
||||
instance eventPageDialog :: OnEvent Data.Page Dialog Data.Dialog
|
||||
|
||||
dialog :: EventName Dialog
|
||||
dialog = EventName
|
||||
|
||||
foreign import data DomContentLoaded :: Type
|
||||
|
||||
instance eventDomContentLoaded :: Event DomContentLoaded where
|
||||
getEventName _ = "domcontentloaded"
|
||||
|
||||
instance eventPageDomContentLoaded :: OnEvent Data.Page DomContentLoaded Unit
|
||||
|
||||
domcontentloaded :: EventName DomContentLoaded
|
||||
domcontentloaded = EventName
|
||||
|
||||
foreign import data Download :: Type
|
||||
|
||||
instance eventDownload :: Event Download where
|
||||
getEventName _ = "download"
|
||||
|
||||
instance eventPageDownload :: OnEvent Data.Page Download Data.Download
|
||||
|
||||
download :: EventName Download
|
||||
download = EventName
|
||||
|
||||
foreign import data FileChooser :: Type
|
||||
|
||||
instance eventFileChooser :: Event FileChooser where
|
||||
getEventName _ = "filechooser"
|
||||
|
||||
instance eventPageFileChooser :: OnEvent Data.Page FileChooser Data.FileChooser
|
||||
|
||||
filechooser :: EventName FileChooser
|
||||
filechooser = EventName
|
||||
|
||||
foreign import data PageError :: Type
|
||||
instance eventPageError :: Event PageError where getEventName _ = "pageerror"
|
||||
|
||||
instance eventPageError :: Event PageError where
|
||||
getEventName _ = "pageerror"
|
||||
|
||||
instance eventPagePageError :: OnEvent Data.Page PageError Error
|
||||
|
||||
pageerror :: EventName PageError
|
||||
pageerror = EventName
|
||||
|
||||
foreign import data Popup :: Type
|
||||
instance eventPopup :: Event Popup where getEventName _ = "popup"
|
||||
|
||||
instance eventPopup :: Event Popup where
|
||||
getEventName _ = "popup"
|
||||
|
||||
instance eventPagePopup :: OnEvent Data.Page Popup Page
|
||||
|
||||
popup :: EventName Popup
|
||||
popup = EventName
|
||||
|
||||
foreign import data Request :: Type
|
||||
instance eventRequest :: Event Request where getEventName _ = "request"
|
||||
|
||||
instance eventRequest :: Event Request where
|
||||
getEventName _ = "request"
|
||||
|
||||
instance eventPageRequest :: OnEvent Data.Page Request Data.Request
|
||||
|
||||
request :: EventName Request
|
||||
request = EventName
|
||||
|
||||
foreign import data RequestFailed :: Type
|
||||
|
||||
instance eventRequestFailed :: Event RequestFailed where
|
||||
getEventName _ = "requestfailed"
|
||||
|
||||
instance eventPageRequestFailed :: OnEvent Data.Page RequestFailed Data.Request
|
||||
|
||||
requestfailed :: EventName RequestFailed
|
||||
requestfailed = EventName
|
||||
|
||||
foreign import data RequestFinished :: Type
|
||||
|
||||
instance eventRequestFinished :: Event RequestFinished where
|
||||
getEventName _ = "requestfinished"
|
||||
|
||||
instance eventPageRequestFinished :: OnEvent Data.Page RequestFinished Data.Request
|
||||
|
||||
requestfinished :: EventName RequestFinished
|
||||
requestfinished = EventName
|
||||
|
||||
foreign import data Response :: Type
|
||||
|
||||
instance eventResponse :: Event Response where
|
||||
getEventName _ = "response"
|
||||
|
||||
instance eventPageResponse :: OnEvent Data.Page Response Data.Response
|
||||
|
||||
response :: EventName Response
|
||||
response = EventName
|
||||
|
||||
foreign import data Worker :: Type
|
||||
|
||||
instance eventWorker :: Event Worker where
|
||||
getEventName _ = "worker"
|
||||
|
||||
instance eventPageWorker :: OnEvent Data.Page Worker Data.Worker
|
||||
|
||||
worker :: EventName Worker
|
||||
worker = EventName
|
||||
|
||||
foreign import data Page :: Type
|
||||
|
||||
instance eventPage :: Event Page where
|
||||
getEventName _ = "page"
|
||||
|
||||
instance eventPagePage :: OnEvent BrowserContext Page Data.Page
|
||||
|
||||
page :: EventName Page
|
||||
page = EventName
|
||||
|
||||
@ -124,6 +178,6 @@ on
|
||||
-> x
|
||||
-> (a -> Effect r)
|
||||
-> Effect Unit
|
||||
on event obj callback = onForeign obj (getEventName (Proxy :: Proxy e)) callback
|
||||
on _ obj callback = onForeign obj (getEventName (Proxy :: Proxy e)) callback
|
||||
|
||||
foreign import onForeign :: forall x a r. x -> String -> (a -> Effect r) -> Effect Unit
|
||||
|
@ -25,11 +25,13 @@ setFiles
|
||||
=> Castable f
|
||||
( String
|
||||
|+| Array String
|
||||
|+| { name :: String
|
||||
|+|
|
||||
{ name :: String
|
||||
, mimeType :: String
|
||||
, buffer :: Buffer
|
||||
}
|
||||
|+| Array { name :: String
|
||||
|+| Array
|
||||
{ name :: String
|
||||
, mimeType :: String
|
||||
, buffer :: Buffer
|
||||
}
|
||||
|
@ -25,13 +25,13 @@ function effectfulGetter (property, argsCount, effectRunnerWrapper) {
|
||||
if (counter === 0) {
|
||||
const [object, ...rest] = argsNew;
|
||||
|
||||
return effectRunnerWrapper(() => object[property].apply(object, rest))
|
||||
return effectRunnerWrapper(() => object[property].apply(object, rest));
|
||||
} else {
|
||||
return (a) => consume(a, argsNew, counter - 1)
|
||||
return (a) => consume(a, argsNew, counter - 1);
|
||||
}
|
||||
}
|
||||
|
||||
return (object) => consume(object, [], argsCount)
|
||||
return (object) => consume(object, [], argsCount);
|
||||
}
|
||||
|
||||
function identity(x) {
|
||||
@ -39,13 +39,13 @@ function identity (x) {
|
||||
}
|
||||
|
||||
export function unsafeEffCall(method) {
|
||||
return argsCount => effectfulGetter(method, argsCount, identity);
|
||||
return (argsCount) => effectfulGetter(method, argsCount, identity);
|
||||
}
|
||||
|
||||
export function unsafeAffCall(toAffE) {
|
||||
return method => argsCount => effectfulGetter(method, argsCount, toAffE);
|
||||
return (method) => (argsCount) => effectfulGetter(method, argsCount, toAffE);
|
||||
}
|
||||
|
||||
export function effProp(prop) {
|
||||
return object => () => object[prop];
|
||||
return (object) => () => object[prop];
|
||||
}
|
@ -4,15 +4,15 @@ module Playwright.Internal
|
||||
, effCall
|
||||
, effProp
|
||||
, affCall
|
||||
)
|
||||
where
|
||||
) where
|
||||
|
||||
import Type.Proxy
|
||||
import Prelude
|
||||
import Effect
|
||||
import Effect.Aff
|
||||
import Control.Promise
|
||||
import Type.Proxy (Proxy(..))
|
||||
import Prelude ((+), (-))
|
||||
import Effect (Effect)
|
||||
import Effect.Aff (Aff)
|
||||
import Control.Promise (Promise, toAffE)
|
||||
|
||||
class NumberOfArgs :: forall k. k -> Constraint
|
||||
class NumberOfArgs x where
|
||||
numberOfArgs :: Proxy x -> Int
|
||||
|
||||
@ -25,8 +25,8 @@ else instance numberOfArgsFunction0 :: NumberOfArgs a where
|
||||
countArgs :: forall a. NumberOfArgs a => (forall x. x -> a) -> Int
|
||||
countArgs f = numberOfArgs (proxyOf f) - 2
|
||||
where
|
||||
proxyOf :: forall a. a -> Proxy a
|
||||
proxyOf _ = Proxy :: Proxy a
|
||||
proxyOf :: forall b. b -> Proxy b
|
||||
proxyOf _ = Proxy :: Proxy b
|
||||
|
||||
foreign import unsafeEffCall
|
||||
:: forall r
|
||||
|
@ -1,9 +1,10 @@
|
||||
/* global exports */
|
||||
|
||||
export function getProperties_(insert) {
|
||||
return emptyMap => jsHandle => () => jsHandle.getProperties().then(props => {
|
||||
return (emptyMap) => (jsHandle) => () =>
|
||||
jsHandle.getProperties().then((props) => {
|
||||
let acc = emptyMap;
|
||||
props.entries().forEach(pair => {
|
||||
props.entries().forEach((pair) => {
|
||||
acc = insert(pair[0])(pair[1])(acc);
|
||||
});
|
||||
return acc;
|
||||
|
@ -1,12 +1,11 @@
|
||||
module Playwright.Keyboard where
|
||||
|
||||
import Prelude
|
||||
import Playwright.Internal (effCall, affCall)
|
||||
import Prelude (Unit)
|
||||
import Playwright.Internal (affCall)
|
||||
import Playwright.Data (Keyboard)
|
||||
import Playwright.Options (KeyboardPressOptions)
|
||||
import Effect.Aff (Aff)
|
||||
import Control.Promise (toAffE)
|
||||
import Untagged.Castable (class Castable, cast)
|
||||
import Untagged.Castable (class Castable)
|
||||
|
||||
type Key = String
|
||||
|
||||
@ -21,14 +20,20 @@ insertText =
|
||||
press
|
||||
:: forall o
|
||||
. Castable o KeyboardPressOptions
|
||||
=> Keyboard -> Key -> o -> Aff Unit
|
||||
=> Keyboard
|
||||
-> Key
|
||||
-> o
|
||||
-> Aff Unit
|
||||
press =
|
||||
affCall "press" \_ -> press
|
||||
|
||||
type'
|
||||
:: forall o
|
||||
. Castable o KeyboardPressOptions
|
||||
=> Keyboard -> String -> o -> Aff Unit
|
||||
=> Keyboard
|
||||
-> String
|
||||
-> o
|
||||
-> Aff Unit
|
||||
type' =
|
||||
affCall "type" \_ -> type'
|
||||
|
||||
|
@ -1,12 +1,11 @@
|
||||
module Playwright.Mouse where
|
||||
|
||||
import Effect.Aff
|
||||
import Playwright.Data
|
||||
import Playwright.Internal
|
||||
import Playwright.Options
|
||||
import Prelude
|
||||
import Effect.Aff (Aff)
|
||||
import Playwright.Data (Mouse)
|
||||
import Playwright.Internal (affCall)
|
||||
import Playwright.Options (MouseClickOptions, MouseDblClickOptions, MouseMoveOptions, MouseUpDownOptions)
|
||||
import Prelude (Unit)
|
||||
import Untagged.Castable (class Castable)
|
||||
import Untagged.Union
|
||||
|
||||
click
|
||||
:: Mouse
|
||||
|
@ -3,7 +3,7 @@ module Playwright.Options where
|
||||
import Playwright.Data
|
||||
|
||||
import Data.String.Regex (Regex)
|
||||
import Data.Time.Duration (Milliseconds(..))
|
||||
import Data.Time.Duration (Milliseconds)
|
||||
import Foreign (Foreign)
|
||||
import Foreign.Object (Object)
|
||||
import Literals.Null (Null)
|
||||
@ -49,6 +49,9 @@ type ConnectOptions =
|
||||
, timeout :: Opt Number
|
||||
}
|
||||
|
||||
type ConnectOverCDPOptions =
|
||||
{ timeout :: UndefinedOr Number }
|
||||
|
||||
type ProxyOptions =
|
||||
{ server :: Opt String
|
||||
, bypass :: Opt String
|
||||
|
@ -1,10 +1,10 @@
|
||||
/* global exports */
|
||||
|
||||
export const finished_ = Nothing => Just => Response => () =>
|
||||
export const finished_ = (Nothing) => (Just) => (Response) => () =>
|
||||
Response.finished().then((result) => {
|
||||
if (result === null) {
|
||||
return Nothing
|
||||
return Nothing;
|
||||
} else {
|
||||
return Just(result)
|
||||
return Just(result);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
@ -10,8 +10,7 @@ module Playwright.Response
|
||||
, statusText
|
||||
, text
|
||||
, url
|
||||
)
|
||||
where
|
||||
) where
|
||||
|
||||
import Control.Promise (Promise, toAffE)
|
||||
import Data.Argonaut.Core (Json)
|
||||
|
@ -13,14 +13,14 @@ import Foreign as Foreign
|
||||
import Node.Encoding as Encoding
|
||||
import Node.FS.Aff as FS
|
||||
import Node.Stream as Stream
|
||||
import Playwright
|
||||
import Playwright (Selector(..), URL(..), chromium, click, close, dblclick, evaluate, exposeBinding, isClosed, launch, mainFrame, name, screenshot, textContent, url, version, waitForFunction, waitForSelector, waitForTimeout)
|
||||
import Node.EventEmitter (on_)
|
||||
import Playwright.ConsoleMessage as ConsoleMessage
|
||||
import Playwright.Dialog as Dialog
|
||||
import Playwright.Download as Download
|
||||
import Playwright.Event (on)
|
||||
import Playwright.Event as Event
|
||||
import Prelude
|
||||
import Prelude (Unit, bind, discard, pure, void, (#), ($), (/=), (<$>), (<<<), (<>), (=<<), (==))
|
||||
import Test.Unit (suite, test)
|
||||
import Test.Unit.Assert as Assert
|
||||
import Test.Unit.Main (runTest)
|
||||
@ -98,8 +98,7 @@ main = runTest do
|
||||
ref <- liftEffect $ Ref.new Nothing
|
||||
frgnRef <- liftEffect $ Ref.new Nothing
|
||||
exposeBinding page "hi_ffi"
|
||||
(
|
||||
\({frame}) frgn -> do
|
||||
( \({ frame }) frgn -> do
|
||||
url <- liftEffect $ url frame
|
||||
liftEffect do
|
||||
Console.log "hi"
|
||||
@ -111,8 +110,9 @@ main = runTest do
|
||||
mbUrl <- liftEffect $ Ref.read ref
|
||||
mbForeign <- liftEffect $ Ref.read frgnRef
|
||||
Assert.equal (Just hello) mbUrl
|
||||
Assert.assert "exposeBinding is not able to accept an argument" $
|
||||
pure (pure 12) == (runExcept <<< Foreign.readInt <$> mbForeign)
|
||||
Assert.assert "exposeBinding is not able to accept an argument"
|
||||
$ pure (pure 12)
|
||||
== (runExcept <<< Foreign.readInt <$> mbForeign)
|
||||
suite "events" do
|
||||
test "console" do
|
||||
withBrowserPage hello
|
||||
|
@ -2,4 +2,4 @@
|
||||
|
||||
export const cwd = process.cwd();
|
||||
|
||||
export const isNull = sth => sth === null;
|
||||
export const isNull = (sth) => sth === null;
|
||||
|
@ -5,8 +5,7 @@ module TestUtils
|
||||
, testClickEvent
|
||||
, cwd
|
||||
, isNull
|
||||
)
|
||||
where
|
||||
) where
|
||||
|
||||
import Test.Unit.Assert as Assert
|
||||
import Foreign (Foreign, readBoolean)
|
||||
|
Loading…
Reference in New Issue
Block a user