Skip to content

Commit

Permalink
Fix build of reflex-dom-test-selenium
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfmpe committed Apr 12, 2024
1 parent 5d1dbde commit 48a26de
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
17 changes: 10 additions & 7 deletions reflex-dom-core/test/hydration.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
Expand Down Expand Up @@ -89,8 +90,10 @@ import qualified Test.WebDriver.Capabilities as WD
import Test.Util.ChromeFlags
import Test.Util.UnshareNetwork

-- ORPHAN: https://github.com/kallisti-dev/hs-webdriver/pull/167

#if !MIN_VERSION_webdriver(0,10,0)
deriving instance MonadMask WD
#endif

chromium :: FilePath
chromium = $(staticWhich "chromium")
Expand Down Expand Up @@ -166,11 +169,11 @@ tests withDebugging wdConfig caps _selenium = do
r <- m
putStrLnDebug "after"
return r
testWidgetStatic :: WD b -> (forall m js. TestWidget (SpiderTimeline Global) m => m ()) -> WD b
testWidgetStatic :: WD b -> (forall m. TestWidget (SpiderTimeline Global) m => m ()) -> WD b
testWidgetStatic = testWidgetStaticDebug withDebugging
testWidget :: WD () -> WD b -> (forall m js. TestWidget (SpiderTimeline Global) m => m ()) -> WD b
testWidget :: WD () -> WD b -> (forall m. TestWidget (SpiderTimeline Global) m => m ()) -> WD b
testWidget = testWidgetDebug True withDebugging
testWidget' :: WD a -> (a -> WD b) -> (forall m js. TestWidget (SpiderTimeline Global) m => m ()) -> WD b
testWidget' :: WD a -> (a -> WD b) -> (forall m. TestWidget (SpiderTimeline Global) m => m ()) -> WD b
testWidget' = testWidgetDebug' True withDebugging
session' "text" $ do
it "works" $ runWD $ do
Expand Down Expand Up @@ -1722,7 +1725,7 @@ testWidgetStaticDebug
:: Bool
-> WD b
-- ^ Webdriver commands to run before JS runs and after hydration switchover
-> (forall m js. TestWidget (SpiderTimeline Global) m => m ())
-> (forall m. TestWidget (SpiderTimeline Global) m => m ())
-- ^ Widget we are testing
-> WD b
testWidgetStaticDebug withDebugging w = testWidgetDebug True withDebugging (void w) w
Expand All @@ -1735,7 +1738,7 @@ testWidgetDebug
-- ^ Webdriver commands to run before the JS runs (i.e. on the statically rendered page)
-> WD b
-- ^ Webdriver commands to run after hydration switchover
-> (forall m js. TestWidget (SpiderTimeline Global) m => m ())
-> (forall m. TestWidget (SpiderTimeline Global) m => m ())
-- ^ Widget we are testing
-> WD b
testWidgetDebug hardFailure withDebugging beforeJS afterSwitchover =
Expand All @@ -1752,7 +1755,7 @@ testWidgetDebug'
-- ^ Webdriver commands to run before the JS runs (i.e. on the statically rendered page)
-> (a -> WD b)
-- ^ Webdriver commands to run after hydration switchover
-> (forall m js. TestWidget (SpiderTimeline Global) m => m ())
-> (forall m. TestWidget (SpiderTimeline Global) m => m ())
-- ^ Widget we are testing (contents of body)
-> WD b
testWidgetDebug' hardFailure withDebugging beforeJS afterSwitchover bodyWidget = do
Expand Down
13 changes: 8 additions & 5 deletions reflex-dom-test-selenium/src/Reflex/Dom/Test/Selenium.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
Expand Down Expand Up @@ -54,7 +55,9 @@ import qualified Test.Hspec.Core.Spec as Hspec
import qualified Test.WebDriver as WD
import qualified Test.WebDriver.Capabilities as WD

#if !MIN_VERSION_webdriver(0,10,0)
deriving instance MonadMask WD
#endif

data SeleniumSetupConfig = SeleniumSetupConfig
{ _seleniumSetupConfig_chromiumPath :: FilePath
Expand Down Expand Up @@ -116,7 +119,7 @@ type TestWidget t m =
data TestWidgetConfig = TestWidgetConfig
{ _testWidgetConfig_debug :: Bool
-- ^ If this flag is set to True, during the test we will emit debug messages
, _testWidgetConfig_headWidget :: (forall m js. TestWidget js (SpiderTimeline Global) m => m ())
, _testWidgetConfig_headWidget :: (forall m. TestWidget (SpiderTimeline Global) m => m ())
-- ^ We can add widgets here that will be included in the head of the page
-- (useful for example to include external js libraries in the tests)
, _testWidgetConfig_jsaddlePort :: PortNumber
Expand All @@ -131,7 +134,7 @@ testWidget
-- ^ Webdriver commands to run before the JS runs (i.e. on the statically rendered page)
-> WD b
-- ^ Webdriver commands to run after hydration switchover
-> (forall m js. TestWidget js (SpiderTimeline Global) m => m ())
-> (forall m. TestWidget (SpiderTimeline Global) m => m ())
-- ^ Widget we are testing (contents of body)
-> WD b
testWidget cfg before after widget = testWidget' cfg before (const after) widget
Expand All @@ -142,7 +145,7 @@ testWidgetStatic
:: TestWidgetConfig
-> WD a
-- ^ Webdriver commands to run before the JS runs (i.e. on the statically rendered page)
-> (forall m js. TestWidget js (SpiderTimeline Global) m => m ())
-> (forall m. TestWidget (SpiderTimeline Global) m => m ())
-- ^ Widget we are testing (contents of body)
-> WD a
testWidgetStatic cfg before widget = testWidget' cfg before pure widget
Expand All @@ -152,7 +155,7 @@ testWidgetHydrated
:: TestWidgetConfig
-> WD b
-- ^ Webdriver commands to run after hydration switchover
-> (forall m js. TestWidget js (SpiderTimeline Global) m => m ())
-> (forall m . TestWidget (SpiderTimeline Global) m => m ())
-- ^ Widget we are testing (contents of body)
-> WD b
testWidgetHydrated cfg after widget = testWidget' cfg (pure ()) (const after) widget
Expand All @@ -166,7 +169,7 @@ testWidget'
-- ^ Webdriver commands to run before the JS runs (i.e. on the statically rendered page)
-> (a -> WD b)
-- ^ Webdriver commands to run after hydration switchover
-> (forall m js. TestWidget js (SpiderTimeline Global) m => m ())
-> (forall m. TestWidget (SpiderTimeline Global) m => m ())
-- ^ Widget we are testing (contents of body)
-> WD b
testWidget' (TestWidgetConfig withDebugging headWidget jsaddlePort) beforeJS afterSwitchover bodyWidget = do
Expand Down

0 comments on commit 48a26de

Please sign in to comment.