Separate user and admin tests
This commit is contained in:
parent
80558b6bfb
commit
b405f63a32
2 changed files with 50 additions and 25 deletions
|
|
@ -54,4 +54,6 @@ proc test*(session: Session, baseUrl: string) =
|
|||
# close menu
|
||||
click "#profile-btn"
|
||||
|
||||
session.navigate(baseUrl)
|
||||
session.wait()
|
||||
logout(session)
|
||||
|
|
|
|||
|
|
@ -4,31 +4,61 @@ import webdriver
|
|||
|
||||
proc test*(session: Session, baseUrl: string) =
|
||||
let
|
||||
titleStr = "This is a thread title!"
|
||||
contentStr = "This is content"
|
||||
userTitleStr = "This is a user thread!"
|
||||
userContentStr = "A user has filled this out"
|
||||
|
||||
suite "thread tests":
|
||||
adminTitleStr = "This is a thread title!"
|
||||
adminContentStr = "This is content"
|
||||
|
||||
suite "user thread tests":
|
||||
session.navigate(baseUrl)
|
||||
waitForLoad(session)
|
||||
login(session, "admin", "admin")
|
||||
session.wait()
|
||||
login(session, "user", "user")
|
||||
|
||||
setup:
|
||||
session.navigate(baseUrl)
|
||||
waitForLoad(session)
|
||||
session.wait()
|
||||
|
||||
test "can create thread":
|
||||
with session:
|
||||
click "#new-thread-btn"
|
||||
wait()
|
||||
|
||||
sendKeys "#thread-title", titleStr
|
||||
sendKeys "#reply-textarea", contentStr
|
||||
sendKeys "#thread-title", userTitleStr
|
||||
sendKeys "#reply-textarea", userContentStr
|
||||
|
||||
click "#create-thread-btn"
|
||||
wait()
|
||||
|
||||
checkText "#thread-title", titleStr
|
||||
checkText ".original-post div.post-content", contentStr
|
||||
checkText "#thread-title", userTitleStr
|
||||
checkText ".original-post div.post-content", userContentStr
|
||||
|
||||
session.navigate(baseUrl)
|
||||
session.wait()
|
||||
logout(session)
|
||||
|
||||
suite "admin thread tests":
|
||||
session.navigate(baseUrl)
|
||||
session.wait()
|
||||
login(session, "admin", "admin")
|
||||
|
||||
setup:
|
||||
session.navigate(baseUrl)
|
||||
session.wait()
|
||||
|
||||
test "can create thread":
|
||||
with session:
|
||||
click "#new-thread-btn"
|
||||
wait()
|
||||
|
||||
sendKeys "#thread-title", adminTitleStr
|
||||
sendKeys "#reply-textarea", adminContentStr
|
||||
|
||||
click "#create-thread-btn"
|
||||
wait()
|
||||
|
||||
checkText "#thread-title", adminTitleStr
|
||||
checkText ".original-post div.post-content", adminContentStr
|
||||
|
||||
test "try create duplicate thread":
|
||||
with session:
|
||||
|
|
@ -36,8 +66,8 @@ proc test*(session: Session, baseUrl: string) =
|
|||
wait()
|
||||
ensureExists "#new-thread"
|
||||
|
||||
sendKeys "#thread-title", titleStr
|
||||
sendKeys "#reply-textarea", contentStr
|
||||
sendKeys "#thread-title", adminTitleStr
|
||||
sendKeys "#reply-textarea", adminContentStr
|
||||
|
||||
click "#create-thread-btn"
|
||||
|
||||
|
|
@ -48,7 +78,7 @@ proc test*(session: Session, baseUrl: string) =
|
|||
test "can edit post":
|
||||
let modificationText = " and I edited it!"
|
||||
with session:
|
||||
click titleStr, LinkTextSelector
|
||||
click adminTitleStr, LinkTextSelector
|
||||
wait()
|
||||
|
||||
click ".post-buttons .edit-button"
|
||||
|
|
@ -58,29 +88,22 @@ proc test*(session: Session, baseUrl: string) =
|
|||
click ".edit-buttons .save-button"
|
||||
wait()
|
||||
|
||||
checkText ".original-post div.post-content", contentStr & modificationText
|
||||
checkText ".original-post div.post-content", adminContentStr & modificationText
|
||||
|
||||
test "can like thread":
|
||||
# logout admin and login to regular user
|
||||
logout(session)
|
||||
login(session, "user", "user")
|
||||
# Try to like the user thread above
|
||||
|
||||
with session:
|
||||
click titleStr, LinkTextSelector
|
||||
click userTitleStr, LinkTextSelector
|
||||
wait()
|
||||
|
||||
click ".post-buttons .like-button"
|
||||
|
||||
checkText ".post-buttons .like-button .like-count", "1"
|
||||
|
||||
logout(session)
|
||||
session.navigate(baseUrl)
|
||||
waitForLoad(session)
|
||||
login(session, "admin", "admin")
|
||||
|
||||
test "can delete thread":
|
||||
with session:
|
||||
click titleStr, LinkTextSelector
|
||||
click adminTitleStr, LinkTextSelector
|
||||
wait()
|
||||
|
||||
click ".post-buttons .delete-button"
|
||||
|
|
@ -91,7 +114,7 @@ proc test*(session: Session, baseUrl: string) =
|
|||
wait()
|
||||
|
||||
# Make sure the forum post is gone
|
||||
checkIsNone titleStr, LinkTextSelector
|
||||
checkIsNone adminTitleStr, LinkTextSelector
|
||||
|
||||
session.navigate(baseUrl)
|
||||
session.wait()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue