Skip to content

Commit

Permalink
sandwich-webdriver: add introduceBrowserDependenciesViaNix'
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjm committed Aug 14, 2024
1 parent dcbffb0 commit bcaa4b0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions sandwich-webdriver/src/Test/Sandwich/WebDriver.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module Test.Sandwich.WebDriver (
, allocateWebDriver
, cleanupWebDriver
, introduceBrowserDependenciesViaNix
, introduceBrowserDependenciesViaNix'
, introduceWebDriver'
, addCommandLineOptionsToWdOptions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module Test.Sandwich.WebDriver.Internal.Dependencies (

, getBrowserDependencies
, introduceBrowserDependenciesViaNix
, introduceBrowserDependenciesViaNix'
, fillInCapabilitiesAndGetDriverArgs
) where

Expand Down Expand Up @@ -112,7 +113,7 @@ getBrowserDependencies (BrowserDependenciesSpecFirefox {..}) = do
geckoDriver <- exceptionOnLeft $ obtainGeckoDriver browserDependenciesSpecFirefoxGeckodriver
return $ BrowserDependenciesFirefox firefox geckoDriver

-- | Inroduce 'BrowserDependencies' via Nix, using the command line options.
-- | Introduce 'BrowserDependencies' via Nix, using the command line options.
-- This is useful to create the context for functions like 'allocateWebDriver'.
introduceBrowserDependenciesViaNix :: forall m context. (
MonadUnliftIO m, HasBaseContext context, HasNixContext context, HasSomeCommandLineOptions context
Expand All @@ -121,7 +122,18 @@ introduceBrowserDependenciesViaNix :: forall m context. (
=> SpecFree (LabelValue "browserDependencies" BrowserDependencies :> context) m ()
-- | Parent spec
-> SpecFree context m ()
introduceBrowserDependenciesViaNix = introduce "Introduce browser dependencies" browserDependencies alloc (const $ return ())
introduceBrowserDependenciesViaNix = introduceBrowserDependenciesViaNix' (defaultNodeOptions { nodeOptionsVisibilityThreshold = 100 })

-- | Same as 'introduceBrowserDependenciesViaNix', but allows passing custom 'NodeOptions'.
introduceBrowserDependenciesViaNix' :: forall m context. (
MonadUnliftIO m, HasBaseContext context, HasNixContext context, HasSomeCommandLineOptions context
)
=> NodeOptions
-- | Child spec
-> SpecFree (LabelValue "browserDependencies" BrowserDependencies :> context) m ()
-- | Parent spec
-> SpecFree context m ()
introduceBrowserDependenciesViaNix' nodeOptions = introduce' nodeOptions "Introduce browser dependencies" browserDependencies alloc (const $ return ())
where
alloc = do
SomeCommandLineOptions (CommandLineOptions {optWebdriverOptions=(CommandLineWebdriverOptions {..})}) <- getSomeCommandLineOptions
Expand Down

0 comments on commit bcaa4b0

Please sign in to comment.