Fix tests and merge
This commit is contained in:
parent
a6c0fe691c
commit
465ba1e024
5 changed files with 36 additions and 43 deletions
|
|
@ -64,8 +64,7 @@ when isMainModule:
|
|||
withBackend:
|
||||
scenario1.test(session, baseUrl)
|
||||
threads.test(session, baseUrl)
|
||||
# TODO: Fix the issue181 test.
|
||||
# issue181.test(session, baseUrl)
|
||||
issue181.test(session, baseUrl)
|
||||
|
||||
session.close()
|
||||
except:
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ proc waitForLoad*(session: Session, timeout=20000) =
|
|||
proc wait*(session: Session, msTimeout: int = 5000) =
|
||||
session.waitForLoad(msTimeout)
|
||||
|
||||
proc setUserRank*(session: Session, user, rank, baseUrl: string) =
|
||||
proc setUserRank*(session: Session, baseUrl, user, rank: string) =
|
||||
with session:
|
||||
navigate(baseUrl & "profile/" & user)
|
||||
wait()
|
||||
|
|
@ -77,7 +77,7 @@ proc setUserRank*(session: Session, user, rank, baseUrl: string) =
|
|||
click "#settings-tab"
|
||||
|
||||
click "#rank-field"
|
||||
click("#rank-field-" & rank.toLowerAscii)
|
||||
click("#rank-field option#rank-" & rank.toLowerAscii)
|
||||
|
||||
click "#save-btn"
|
||||
wait()
|
||||
|
|
@ -141,22 +141,3 @@ proc createThread*(session: Session, title, content: string) =
|
|||
|
||||
checkText "#thread-title", title
|
||||
checkText ".original-post div.post-content", content
|
||||
|
||||
proc changeRank*(session: Session, rank: string) =
|
||||
with session:
|
||||
# Make sure the "Settings" tab is selected.
|
||||
click ".profile-tabs li:nth-child(2)"
|
||||
|
||||
click "#rank-field"
|
||||
click "#rank-field option#rank-" & rank.toLowerAscii()
|
||||
|
||||
wait()
|
||||
|
||||
# TODO: Getting an "element click intercepted" error here.
|
||||
click "#save-btn"
|
||||
|
||||
proc banUser*(session: Session, baseUrl: string) =
|
||||
with session:
|
||||
login baseUrl, "admin", "admin"
|
||||
setUserRank "user", "banned", baseUrl
|
||||
logout baseUrl
|
||||
|
|
|
|||
|
|
@ -10,37 +10,29 @@ proc test*(session: Session, baseUrl: string) =
|
|||
test "can see banned posts":
|
||||
with session:
|
||||
register("issue181", "issue181")
|
||||
logout()
|
||||
logout(baseUrl)
|
||||
|
||||
# Change rank to `user` so they can post.
|
||||
login("admin", "admin")
|
||||
login(baseUrl, "admin", "admin")
|
||||
setUserRank(baseUrl, "issue181", "user")
|
||||
logout(baseUrl)
|
||||
|
||||
navigate(baseUrl & "profile/user")
|
||||
wait()
|
||||
changeRank("user")
|
||||
logout()
|
||||
|
||||
login("issue181", "issue181")
|
||||
login(baseUrl, "issue181", "issue181")
|
||||
|
||||
const title = "Testing issue 181."
|
||||
createThread(title, "Test for issue #181")
|
||||
|
||||
logout()
|
||||
wait()
|
||||
logout(baseUrl)
|
||||
|
||||
login("admin", "admin")
|
||||
login(baseUrl, "admin", "admin")
|
||||
|
||||
# Ban our user.
|
||||
navigate(baseUrl & "profile/issue181")
|
||||
changeRank("banned")
|
||||
setUserRank(baseUrl, "issue181", "banned")
|
||||
|
||||
# Make sure the banned user's thread is still visible.
|
||||
navigate(baseUrl)
|
||||
wait()
|
||||
ensureExists("tr.banned")
|
||||
checkText("tr.banned .thread-title > a", title)
|
||||
logout()
|
||||
logout(baseUrl)
|
||||
checkText("tr.banned .thread-title > a", title)
|
||||
|
||||
session.navigate(baseUrl)
|
||||
session.wait()
|
||||
logout(session)
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@ proc test*(session: Session, baseUrl: string) =
|
|||
# Logging in
|
||||
test "can login/logout":
|
||||
with session:
|
||||
login("admin", "admin")
|
||||
login(baseUrl, "admin", "admin")
|
||||
|
||||
# Check whether we can log out.
|
||||
logout()
|
||||
logout(baseUrl)
|
||||
# Verify we have logged out by looking for the log in button.
|
||||
ensureExists "#login-btn"
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,11 @@ let
|
|||
adminTitleStr = "This is a thread title!"
|
||||
adminContentStr = "This is content"
|
||||
|
||||
proc banUser(session: Session, baseUrl: string) =
|
||||
with session:
|
||||
login baseUrl, "admin", "admin"
|
||||
setUserRank baseUrl, "user", "banned"
|
||||
logout baseUrl
|
||||
|
||||
proc userTests(session: Session, baseUrl: string) =
|
||||
suite "user thread tests":
|
||||
|
|
@ -34,6 +39,21 @@ proc userTests(session: Session, baseUrl: string) =
|
|||
|
||||
session.logout(baseUrl)
|
||||
|
||||
proc anonymousTests(session: Session, baseUrl: string) =
|
||||
|
||||
suite "anonymous user tests":
|
||||
with session:
|
||||
navigate baseUrl
|
||||
wait()
|
||||
|
||||
test "can view banned thread":
|
||||
with session:
|
||||
ensureExists userTitleStr, LinkTextSelector
|
||||
|
||||
with session:
|
||||
navigate baseUrl
|
||||
wait()
|
||||
|
||||
proc bannedTests(session: Session, baseUrl: string) =
|
||||
suite "banned user thread tests":
|
||||
session.login(baseUrl, "banned", "banned")
|
||||
|
|
@ -143,4 +163,5 @@ proc test*(session: Session, baseUrl: string) =
|
|||
banUser(session, baseUrl)
|
||||
|
||||
bannedTests(session, baseUrl)
|
||||
anonymousTests(session, baseUrl)
|
||||
adminTests(session, baseUrl)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue