mirror of
https://github.com/aelve/guide.git
synced 2024-11-23 12:15:06 +03:00
[tests] createCategory helper
This commit is contained in:
parent
fce8c71a5c
commit
368c8bcb18
@ -71,8 +71,7 @@ categoryTests :: Spec
|
||||
categoryTests = session "categories" $ using Firefox $ do
|
||||
openGuide "/"
|
||||
wd "add a new category" $ do
|
||||
changesURL $
|
||||
sendKeys ("Some category" <> _enter) =<< select ".add-category"
|
||||
createCategory "Some category"
|
||||
checkPresent ".category"
|
||||
url <- getCurrentRelativeURL
|
||||
uriPath url `shouldSatisfy`
|
||||
@ -96,8 +95,7 @@ markdownTests = session "markdown" $ using Firefox $ do
|
||||
openGuide "/"
|
||||
describe "Markdown isn't allowed in category names" $ do
|
||||
wd "when creating a category" $ do
|
||||
changesURL $
|
||||
sendKeys ("*foo*" <> _enter) =<< select ".add-category"
|
||||
createCategory "*foo*"
|
||||
e <- select ".category-title"
|
||||
e `shouldHaveText` "*foo*"
|
||||
wd "when changing existing category's name" $ do
|
||||
@ -112,7 +110,20 @@ markdownTests = session "markdown" $ using Firefox $ do
|
||||
e `shouldHaveText` "foo `bar`"
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Utilities
|
||||
-- Helpers dealing with guide specifically
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
openGuide :: String -> SpecWith (WdTestSession ())
|
||||
openGuide s = specify ("load " ++ s) $ runWD $
|
||||
openPage ("http://localhost:8080/haskell" ++ s)
|
||||
|
||||
-- Assumes that the main page is open
|
||||
createCategory :: Text -> WD ()
|
||||
createCategory t =
|
||||
changesURL $ sendKeys (t <> _enter) =<< select ".add-category"
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Utilities for webdriver
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
changesURL :: WD a -> WD a
|
||||
@ -205,10 +216,6 @@ run ts = do
|
||||
bracket prepare finalise $ \_ -> do
|
||||
hspec ts
|
||||
|
||||
openGuide :: String -> SpecWith (WdTestSession ())
|
||||
openGuide s = specify ("load " ++ s) $ runWD $
|
||||
openPage ("http://localhost:8080/haskell" ++ s)
|
||||
|
||||
expectationFailure :: MonadIO m => String -> m ()
|
||||
expectationFailure = liftIO . Hspec.expectationFailure
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user