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:
|
withBackend:
|
||||||
scenario1.test(session, baseUrl)
|
scenario1.test(session, baseUrl)
|
||||||
threads.test(session, baseUrl)
|
threads.test(session, baseUrl)
|
||||||
# TODO: Fix the issue181 test.
|
issue181.test(session, baseUrl)
|
||||||
# issue181.test(session, baseUrl)
|
|
||||||
|
|
||||||
session.close()
|
session.close()
|
||||||
except:
|
except:
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ proc waitForLoad*(session: Session, timeout=20000) =
|
||||||
proc wait*(session: Session, msTimeout: int = 5000) =
|
proc wait*(session: Session, msTimeout: int = 5000) =
|
||||||
session.waitForLoad(msTimeout)
|
session.waitForLoad(msTimeout)
|
||||||
|
|
||||||
proc setUserRank*(session: Session, user, rank, baseUrl: string) =
|
proc setUserRank*(session: Session, baseUrl, user, rank: string) =
|
||||||
with session:
|
with session:
|
||||||
navigate(baseUrl & "profile/" & user)
|
navigate(baseUrl & "profile/" & user)
|
||||||
wait()
|
wait()
|
||||||
|
|
@ -77,7 +77,7 @@ proc setUserRank*(session: Session, user, rank, baseUrl: string) =
|
||||||
click "#settings-tab"
|
click "#settings-tab"
|
||||||
|
|
||||||
click "#rank-field"
|
click "#rank-field"
|
||||||
click("#rank-field-" & rank.toLowerAscii)
|
click("#rank-field option#rank-" & rank.toLowerAscii)
|
||||||
|
|
||||||
click "#save-btn"
|
click "#save-btn"
|
||||||
wait()
|
wait()
|
||||||
|
|
@ -141,22 +141,3 @@ proc createThread*(session: Session, title, content: string) =
|
||||||
|
|
||||||
checkText "#thread-title", title
|
checkText "#thread-title", title
|
||||||
checkText ".original-post div.post-content", content
|
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":
|
test "can see banned posts":
|
||||||
with session:
|
with session:
|
||||||
register("issue181", "issue181")
|
register("issue181", "issue181")
|
||||||
logout()
|
logout(baseUrl)
|
||||||
|
|
||||||
# Change rank to `user` so they can post.
|
# 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")
|
login(baseUrl, "issue181", "issue181")
|
||||||
wait()
|
|
||||||
changeRank("user")
|
|
||||||
logout()
|
|
||||||
|
|
||||||
login("issue181", "issue181")
|
|
||||||
|
|
||||||
const title = "Testing issue 181."
|
const title = "Testing issue 181."
|
||||||
createThread(title, "Test for issue #181")
|
createThread(title, "Test for issue #181")
|
||||||
|
|
||||||
logout()
|
logout(baseUrl)
|
||||||
wait()
|
|
||||||
|
|
||||||
login("admin", "admin")
|
login(baseUrl, "admin", "admin")
|
||||||
|
|
||||||
# Ban our user.
|
# Ban our user.
|
||||||
navigate(baseUrl & "profile/issue181")
|
setUserRank(baseUrl, "issue181", "banned")
|
||||||
changeRank("banned")
|
|
||||||
|
|
||||||
# Make sure the banned user's thread is still visible.
|
# Make sure the banned user's thread is still visible.
|
||||||
navigate(baseUrl)
|
navigate(baseUrl)
|
||||||
|
wait()
|
||||||
ensureExists("tr.banned")
|
ensureExists("tr.banned")
|
||||||
checkText("tr.banned .thread-title > a", title)
|
checkText("tr.banned .thread-title > a", title)
|
||||||
logout()
|
logout(baseUrl)
|
||||||
checkText("tr.banned .thread-title > a", title)
|
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
|
# Logging in
|
||||||
test "can login/logout":
|
test "can login/logout":
|
||||||
with session:
|
with session:
|
||||||
login("admin", "admin")
|
login(baseUrl, "admin", "admin")
|
||||||
|
|
||||||
# Check whether we can log out.
|
# Check whether we can log out.
|
||||||
logout()
|
logout(baseUrl)
|
||||||
# Verify we have logged out by looking for the log in button.
|
# Verify we have logged out by looking for the log in button.
|
||||||
ensureExists "#login-btn"
|
ensureExists "#login-btn"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,11 @@ let
|
||||||
adminTitleStr = "This is a thread title!"
|
adminTitleStr = "This is a thread title!"
|
||||||
adminContentStr = "This is content"
|
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) =
|
proc userTests(session: Session, baseUrl: string) =
|
||||||
suite "user thread tests":
|
suite "user thread tests":
|
||||||
|
|
@ -34,6 +39,21 @@ proc userTests(session: Session, baseUrl: string) =
|
||||||
|
|
||||||
session.logout(baseUrl)
|
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) =
|
proc bannedTests(session: Session, baseUrl: string) =
|
||||||
suite "banned user thread tests":
|
suite "banned user thread tests":
|
||||||
session.login(baseUrl, "banned", "banned")
|
session.login(baseUrl, "banned", "banned")
|
||||||
|
|
@ -143,4 +163,5 @@ proc test*(session: Session, baseUrl: string) =
|
||||||
banUser(session, baseUrl)
|
banUser(session, baseUrl)
|
||||||
|
|
||||||
bannedTests(session, baseUrl)
|
bannedTests(session, baseUrl)
|
||||||
|
anonymousTests(session, baseUrl)
|
||||||
adminTests(session, baseUrl)
|
adminTests(session, baseUrl)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue