Separate user and admin tests

This commit is contained in:
Joey Yakimowich-Payne 2018-07-17 22:51:01 +09:00
commit b405f63a32
2 changed files with 50 additions and 25 deletions

View file

@ -54,4 +54,6 @@ proc test*(session: Session, baseUrl: string) =
# close menu # close menu
click "#profile-btn" click "#profile-btn"
session.navigate(baseUrl)
session.wait()
logout(session) logout(session)

View file

@ -4,31 +4,61 @@ import webdriver
proc test*(session: Session, baseUrl: string) = proc test*(session: Session, baseUrl: string) =
let let
titleStr = "This is a thread title!" userTitleStr = "This is a user thread!"
contentStr = "This is content" 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) session.navigate(baseUrl)
waitForLoad(session) session.wait()
login(session, "admin", "admin") login(session, "user", "user")
setup: setup:
session.navigate(baseUrl) session.navigate(baseUrl)
waitForLoad(session) session.wait()
test "can create thread": test "can create thread":
with session: with session:
click "#new-thread-btn" click "#new-thread-btn"
wait() wait()
sendKeys "#thread-title", titleStr sendKeys "#thread-title", userTitleStr
sendKeys "#reply-textarea", contentStr sendKeys "#reply-textarea", userContentStr
click "#create-thread-btn" click "#create-thread-btn"
wait() wait()
checkText "#thread-title", titleStr checkText "#thread-title", userTitleStr
checkText ".original-post div.post-content", contentStr 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": test "try create duplicate thread":
with session: with session:
@ -36,8 +66,8 @@ proc test*(session: Session, baseUrl: string) =
wait() wait()
ensureExists "#new-thread" ensureExists "#new-thread"
sendKeys "#thread-title", titleStr sendKeys "#thread-title", adminTitleStr
sendKeys "#reply-textarea", contentStr sendKeys "#reply-textarea", adminContentStr
click "#create-thread-btn" click "#create-thread-btn"
@ -48,7 +78,7 @@ proc test*(session: Session, baseUrl: string) =
test "can edit post": test "can edit post":
let modificationText = " and I edited it!" let modificationText = " and I edited it!"
with session: with session:
click titleStr, LinkTextSelector click adminTitleStr, LinkTextSelector
wait() wait()
click ".post-buttons .edit-button" click ".post-buttons .edit-button"
@ -58,29 +88,22 @@ proc test*(session: Session, baseUrl: string) =
click ".edit-buttons .save-button" click ".edit-buttons .save-button"
wait() wait()
checkText ".original-post div.post-content", contentStr & modificationText checkText ".original-post div.post-content", adminContentStr & modificationText
test "can like thread": test "can like thread":
# logout admin and login to regular user # Try to like the user thread above
logout(session)
login(session, "user", "user")
with session: with session:
click titleStr, LinkTextSelector click userTitleStr, LinkTextSelector
wait() wait()
click ".post-buttons .like-button" click ".post-buttons .like-button"
checkText ".post-buttons .like-button .like-count", "1" checkText ".post-buttons .like-button .like-count", "1"
logout(session)
session.navigate(baseUrl)
waitForLoad(session)
login(session, "admin", "admin")
test "can delete thread": test "can delete thread":
with session: with session:
click titleStr, LinkTextSelector click adminTitleStr, LinkTextSelector
wait() wait()
click ".post-buttons .delete-button" click ".post-buttons .delete-button"
@ -91,7 +114,7 @@ proc test*(session: Session, baseUrl: string) =
wait() wait()
# Make sure the forum post is gone # Make sure the forum post is gone
checkIsNone titleStr, LinkTextSelector checkIsNone adminTitleStr, LinkTextSelector
session.navigate(baseUrl) session.navigate(baseUrl)
session.wait() session.wait()