mirror of
https://github.com/aelve/guide.git
synced 2024-12-23 12:52:31 +03:00
[tests] Category notes editing
This commit is contained in:
parent
9ba0ab19fe
commit
563b3efd3d
@ -1164,10 +1164,10 @@ markdownEditor attr (view mdText -> s) submit cancel instr = do
|
||||
onEscape (JS.assign val s <> cancel) ]
|
||||
++ attr) $
|
||||
toHtml s
|
||||
button "Save" [] $
|
||||
button "Save" [class_ " save "] $
|
||||
submit val
|
||||
emptySpan "6px"
|
||||
button "Cancel" [] $
|
||||
button "Cancel" [class_ " cancel "] $
|
||||
JS.assign val s <>
|
||||
cancel
|
||||
emptySpan "6px"
|
||||
|
@ -31,6 +31,8 @@ module Selenium
|
||||
getLink,
|
||||
getText,
|
||||
getValue,
|
||||
sendKeys,
|
||||
clearInput,
|
||||
|
||||
-- * Expectations
|
||||
changesURL,
|
||||
@ -70,7 +72,8 @@ import Data.Text.All (Text)
|
||||
import qualified Data.Text.All as T
|
||||
-- Testing
|
||||
import Test.Hspec.WebDriver hiding
|
||||
(getText, shouldHaveAttr, shouldHaveText, click, cssProp, attr)
|
||||
(getText, shouldHaveAttr, shouldHaveText, click, cssProp, attr,
|
||||
sendKeys, clearInput)
|
||||
import qualified Test.Hspec.WebDriver as WD
|
||||
import Test.WebDriver.Commands.Wait
|
||||
import Test.WebDriver.Exceptions
|
||||
@ -104,6 +107,18 @@ getText s = do
|
||||
getValue :: CanSelect s => s -> WD Text
|
||||
getValue x = fromMaybe "" <$> attr x "value"
|
||||
|
||||
clearInput :: CanSelect s => s -> WD ()
|
||||
clearInput s = do
|
||||
-- TODO: Note [staleness]
|
||||
input <- select s
|
||||
WD.clearInput input
|
||||
|
||||
sendKeys :: CanSelect s => Text -> s -> WD ()
|
||||
sendKeys t s = do
|
||||
-- TODO: Note [staleness]
|
||||
input <- select s
|
||||
WD.sendKeys t input
|
||||
|
||||
enterInput :: CanSelect s => Text -> s -> WD ()
|
||||
enterInput x s = do
|
||||
input <- select s
|
||||
|
@ -210,13 +210,19 @@ categoryTests = session "categories" $ using Firefox $ do
|
||||
click ".category-feed"
|
||||
checkPresent (".item-name" :& HasText "some item")
|
||||
checkPresent (".item-name" :& HasText "another item")
|
||||
describe "description" $ do
|
||||
describe "notes" $ do
|
||||
wd "has a default template" $ do
|
||||
click (ByLinkText "edit description")
|
||||
contents <- T.lines <$> getValue ".category-notes textarea"
|
||||
form <- openCategoryNotesEditForm
|
||||
contents <- T.lines <$> getValue (form :// "textarea")
|
||||
contents `shouldSatisfy`
|
||||
("have “# Recommendations”", ("# Recommendations" `elem`))
|
||||
-- TODO: editing works
|
||||
click (form :// ".cancel")
|
||||
wd "can be edited" $ do
|
||||
form <- openCategoryNotesEditForm
|
||||
clearInput (form :// "textarea")
|
||||
sendKeys "Blah blah" (form :// "textarea")
|
||||
click (form :// ".save")
|
||||
".category-notes .notes-like" `shouldHaveText` "Blah blah"
|
||||
describe "deleting a category" $ do
|
||||
wd "dismissing the alert doesn't do anything" $ do
|
||||
click (".category h2" :// ByLinkText "delete")
|
||||
@ -440,6 +446,11 @@ openCategoryEditForm = do
|
||||
click (".category h2" :// ByLinkText "edit")
|
||||
select ".category-info form"
|
||||
|
||||
openCategoryNotesEditForm :: WD Element
|
||||
openCategoryNotesEditForm = do
|
||||
click (".category-notes" :// ByLinkText "edit description")
|
||||
select ".category-notes .editing"
|
||||
|
||||
openItemEditForm :: CanSelect s => s -> WD Element
|
||||
openItemEditForm item = do
|
||||
click (item :// ".edit-item-info")
|
||||
|
Loading…
Reference in New Issue
Block a user