mirror of
https://github.com/aelve/guide.git
synced 2024-12-29 00:24:01 +03:00
[tests] Changing item name
This commit is contained in:
parent
243b728924
commit
45407fd96f
@ -62,20 +62,24 @@ HTML: item-info-controls
|
|||||||
{{> img-button
|
{{> img-button
|
||||||
src = "/arrow-thick-top.svg"
|
src = "/arrow-thick-top.svg"
|
||||||
title = "move item up"
|
title = "move item up"
|
||||||
|
class = "move-item-up"
|
||||||
action = [| moveItem("up", {{{%js item.uid}}}); |] }}
|
action = [| moveItem("up", {{{%js item.uid}}}); |] }}
|
||||||
{{> img-button
|
{{> img-button
|
||||||
src = "/arrow-thick-bottom.svg"
|
src = "/arrow-thick-bottom.svg"
|
||||||
title = "move item down"
|
title = "move item down"
|
||||||
|
class = "move-item-down"
|
||||||
action = [| moveItem("down", {{{%js item.uid}}}); |] }}
|
action = [| moveItem("down", {{{%js item.uid}}}); |] }}
|
||||||
{{> space em=1.5 }}
|
{{> space em=1.5 }}
|
||||||
{{> img-button
|
{{> img-button
|
||||||
src = "/pencil.svg"
|
src = "/pencil.svg"
|
||||||
title = "edit item info"
|
title = "edit item info"
|
||||||
|
class = "edit-item-info"
|
||||||
action = [| editItemInfo({{{%js item.uid}}}); |] }}
|
action = [| editItemInfo({{{%js item.uid}}}); |] }}
|
||||||
{{> space em=0.5 }}
|
{{> space em=0.5 }}
|
||||||
{{> img-button
|
{{> img-button
|
||||||
src = "/x.svg"
|
src = "/x.svg"
|
||||||
title = "delete item"
|
title = "delete item"
|
||||||
|
class = "delete-item"
|
||||||
action = [| deleteItem({{{%js item.uid}}}); |] }}
|
action = [| deleteItem({{{%js item.uid}}}); |] }}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ HTML
|
|||||||
<a href="{{item.link}}" class="item-name">{{item.name}}</a>
|
<a href="{{item.link}}" class="item-name">{{item.name}}</a>
|
||||||
{{/ item.link }}
|
{{/ item.link }}
|
||||||
{{^ item.link }}
|
{{^ item.link }}
|
||||||
<span class="item-name">{{item.name}}</a>
|
<span class="item-name">{{item.name}}</span>
|
||||||
{{/ item.link }}
|
{{/ item.link }}
|
||||||
|
|
||||||
{{! if the item is on Hackage, let's provide a link }}
|
{{! if the item is on Hackage, let's provide a link }}
|
||||||
|
@ -121,20 +121,14 @@ categoryTests = session "categories" $ using Firefox $ do
|
|||||||
fs <- fontSize e; fs `shouldBeInRange` (20, 26)
|
fs <- fontSize e; fs `shouldBeInRange` (20, 26)
|
||||||
wd "can be changed" $ do
|
wd "can be changed" $ do
|
||||||
form <- openCategoryEditForm
|
form <- openCategoryEditForm
|
||||||
do inp <- select (form :// "input[name=title]")
|
enterInput "Cat 1" (form :// "input[name=title]")
|
||||||
clearInput inp
|
|
||||||
sendKeys ("Cat 1" <> _enter) inp
|
|
||||||
checkNotPresent (form :& Displayed)
|
|
||||||
categoryTitle `shouldHaveText` "Cat 1"
|
categoryTitle `shouldHaveText` "Cat 1"
|
||||||
wd "changes page slug when changed" $ do
|
wd "changes page slug when changed" $ do
|
||||||
changesURL $ refresh
|
changesURL $ refresh
|
||||||
do (slug, _) <- parseCategoryURL . uriPath =<< getCurrentRelativeURL
|
do (slug, _) <- parseCategoryURL . uriPath =<< getCurrentRelativeURL
|
||||||
slug `shouldBe` "cat-1"
|
slug `shouldBe` "cat-1"
|
||||||
form <- openCategoryEditForm
|
form <- openCategoryEditForm
|
||||||
do inp <- select (form :// "input[name=title]")
|
enterInput "Cat 2" (form :// "input[name=title]")
|
||||||
clearInput inp
|
|
||||||
sendKeys ("Cat 2" <> _enter) inp
|
|
||||||
checkNotPresent (form :& Displayed)
|
|
||||||
changesURL $ refresh
|
changesURL $ refresh
|
||||||
do (slug, _) <- parseCategoryURL . uriPath =<< getCurrentRelativeURL
|
do (slug, _) <- parseCategoryURL . uriPath =<< getCurrentRelativeURL
|
||||||
slug `shouldBe` "cat-2"
|
slug `shouldBe` "cat-2"
|
||||||
@ -153,10 +147,7 @@ categoryTests = session "categories" $ using Firefox $ do
|
|||||||
fs <- fontSize group_; fs `shouldBeInRange` (12, 15)
|
fs <- fontSize group_; fs `shouldBeInRange` (12, 15)
|
||||||
wd "can be changed" $ do
|
wd "can be changed" $ do
|
||||||
form <- openCategoryEditForm
|
form <- openCategoryEditForm
|
||||||
do inp <- select (form :// "input[name=group]")
|
enterInput "Basics" (form :// "input[name=group]")
|
||||||
clearInput inp
|
|
||||||
sendKeys ("Basics" <> _enter) inp
|
|
||||||
checkNotPresent (form :& Displayed)
|
|
||||||
categoryGroup `shouldHaveText` "Basics"
|
categoryGroup `shouldHaveText` "Basics"
|
||||||
wd "is changed on the front page too" $ do
|
wd "is changed on the front page too" $ do
|
||||||
onAnotherPage "/" $ do
|
onAnotherPage "/" $ do
|
||||||
@ -251,14 +242,20 @@ itemTests = session "items" $ using Firefox $ do
|
|||||||
wd "add a new item" $ do
|
wd "add a new item" $ do
|
||||||
createItem "An item"
|
createItem "An item"
|
||||||
describe "item properties" $ do
|
describe "item properties" $ do
|
||||||
describe "title" $ do
|
describe "name" $ do
|
||||||
wd "is present" $ do
|
wd "is present" $ do
|
||||||
".item-name" `shouldHaveText` "An item"
|
name <- select ".item-name"
|
||||||
|
name `shouldHaveText` "An item"
|
||||||
|
fs <- fontSize name; fs `shouldBeInRange` (20,26)
|
||||||
wd "isn't a link" $ do
|
wd "isn't a link" $ do
|
||||||
urlBefore <- getCurrentURL
|
urlBefore <- getCurrentURL
|
||||||
click ".item-name"
|
click ".item-name"
|
||||||
urlAfter <- getCurrentURL
|
urlAfter <- getCurrentURL
|
||||||
urlAfter `shouldBe` urlBefore
|
urlAfter `shouldBe` urlBefore
|
||||||
|
wd "can be changed" $ do
|
||||||
|
form <- openItemEditForm ".item"
|
||||||
|
enterInput "New title" (form :// "[name='name']")
|
||||||
|
".item-name" `shouldHaveText` "New title"
|
||||||
|
|
||||||
markdownTests :: Spec
|
markdownTests :: Spec
|
||||||
markdownTests = session "markdown" $ using Firefox $ do
|
markdownTests = session "markdown" $ using Firefox $ do
|
||||||
@ -269,10 +266,7 @@ markdownTests = session "markdown" $ using Firefox $ do
|
|||||||
categoryTitle `shouldHaveText` "*foo*"
|
categoryTitle `shouldHaveText` "*foo*"
|
||||||
wd "when changing existing category's name" $ do
|
wd "when changing existing category's name" $ do
|
||||||
form <- openCategoryEditForm
|
form <- openCategoryEditForm
|
||||||
do inp <- select (form :// "input[name=title]")
|
enterInput "foo `bar`" (form :// "input[name=title]")
|
||||||
clearInput inp
|
|
||||||
sendKeys ("foo `bar`" <> _enter) inp
|
|
||||||
checkNotPresent (form :& Displayed)
|
|
||||||
categoryTitle `shouldHaveText` "foo `bar`"
|
categoryTitle `shouldHaveText` "foo `bar`"
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
@ -330,10 +324,22 @@ openCategoryEditForm = do
|
|||||||
click (".category h2" :// ByLinkText "edit")
|
click (".category h2" :// ByLinkText "edit")
|
||||||
select ".category-info form"
|
select ".category-info form"
|
||||||
|
|
||||||
|
openItemEditForm :: CanSelect s => s -> WD Element
|
||||||
|
openItemEditForm item = do
|
||||||
|
click (item :// ".edit-item-info")
|
||||||
|
select (item :// ".item-info form")
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- Utilities for webdriver
|
-- Utilities for webdriver
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
enterInput :: CanSelect s => Text -> s -> WD ()
|
||||||
|
enterInput x s = do
|
||||||
|
input <- select s
|
||||||
|
clearInput input
|
||||||
|
sendKeys (x <> _enter) input
|
||||||
|
checkNotPresent input
|
||||||
|
|
||||||
isAlive :: Element -> WD Bool
|
isAlive :: Element -> WD Bool
|
||||||
isAlive e = (isEnabled e >> return True) `onDead` return False
|
isAlive e = (isEnabled e >> return True) `onDead` return False
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user