From 48a26de4b49ff9f8e307666fa765e518f32abeb9 Mon Sep 17 00:00:00 2001 From: Alexandre Esteves Date: Fri, 12 Apr 2024 02:05:34 +0100 Subject: [PATCH] Fix build of reflex-dom-test-selenium --- reflex-dom-core/test/hydration.hs | 17 ++++++++++------- .../src/Reflex/Dom/Test/Selenium.hs | 13 ++++++++----- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/reflex-dom-core/test/hydration.hs b/reflex-dom-core/test/hydration.hs index 16269a73..1f861c4d 100644 --- a/reflex-dom-core/test/hydration.hs +++ b/reflex-dom-core/test/hydration.hs @@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} @@ -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") @@ -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 @@ -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 @@ -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 = @@ -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 diff --git a/reflex-dom-test-selenium/src/Reflex/Dom/Test/Selenium.hs b/reflex-dom-test-selenium/src/Reflex/Dom/Test/Selenium.hs index b0c14cf2..be7ead10 100644 --- a/reflex-dom-test-selenium/src/Reflex/Dom/Test/Selenium.hs +++ b/reflex-dom-test-selenium/src/Reflex/Dom/Test/Selenium.hs @@ -1,4 +1,5 @@ {-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE OverloadedStrings #-} @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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