commit
ee3324cfb7
8 changed files with 118 additions and 58 deletions
|
|
@ -21,7 +21,7 @@ requires "sass#649e0701fa5c"
|
||||||
|
|
||||||
requires "karax#d8df257dd"
|
requires "karax#d8df257dd"
|
||||||
|
|
||||||
requires "webdriver#a2be578"
|
requires "webdriver#20f3c1b"
|
||||||
|
|
||||||
# Tasks
|
# Tasks
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ when defined(js):
|
||||||
),
|
),
|
||||||
onClick=(e: Event, n: VNode) => (state.currentTab = Overview)
|
onClick=(e: Event, n: VNode) => (state.currentTab = Overview)
|
||||||
):
|
):
|
||||||
a(class="c-hand"):
|
a(id="overview-tab", class="c-hand"):
|
||||||
text "Overview"
|
text "Overview"
|
||||||
li(class=class(
|
li(class=class(
|
||||||
{"active": state.currentTab == Settings},
|
{"active": state.currentTab == Settings},
|
||||||
|
|
@ -127,7 +127,7 @@ when defined(js):
|
||||||
),
|
),
|
||||||
onClick=(e: Event, n: VNode) => (state.currentTab = Settings)
|
onClick=(e: Event, n: VNode) => (state.currentTab = Settings)
|
||||||
):
|
):
|
||||||
a(class="c-hand"):
|
a(id="settings-tab", class="c-hand"):
|
||||||
italic(class="fas fa-cog")
|
italic(class="fas fa-cog")
|
||||||
text " Settings"
|
text " Settings"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,8 @@ when defined(js):
|
||||||
label(class="form-label"):
|
label(class="form-label"):
|
||||||
text "Account"
|
text "Account"
|
||||||
tdiv(class="col-9 col-sm-12"):
|
tdiv(class="col-9 col-sm-12"):
|
||||||
button(class="btn btn-secondary", `type`="button",
|
button(id="delete-account-btn",
|
||||||
|
class="btn btn-secondary", `type`="button",
|
||||||
onClick=(e: Event, n: VNode) =>
|
onClick=(e: Event, n: VNode) =>
|
||||||
(state.deleteModal.show(state.profile.user))):
|
(state.deleteModal.show(state.profile.user))):
|
||||||
italic(class="fas fa-times")
|
italic(class="fas fa-times")
|
||||||
|
|
@ -176,13 +177,15 @@ when defined(js):
|
||||||
span(class="text-error"):
|
span(class="text-error"):
|
||||||
text state.error.get().message
|
text state.error.get().message
|
||||||
|
|
||||||
button(class=class(
|
button(id="cancel-btn",
|
||||||
|
class=class(
|
||||||
{"disabled": not needsSave(state)}, "btn btn-link"
|
{"disabled": not needsSave(state)}, "btn btn-link"
|
||||||
),
|
),
|
||||||
onClick=(e: Event, n: VNode) => (resetSettings(state))):
|
onClick=(e: Event, n: VNode) => (resetSettings(state))):
|
||||||
text "Cancel"
|
text "Cancel"
|
||||||
|
|
||||||
button(class=class(
|
button(id="save-btn",
|
||||||
|
class=class(
|
||||||
{"disabled": not needsSave(state)}, "btn btn-primary"
|
{"disabled": not needsSave(state)}, "btn btn-primary"
|
||||||
),
|
),
|
||||||
onClick=(e: Event, n: VNode) => save(state),
|
onClick=(e: Event, n: VNode) => save(state),
|
||||||
|
|
|
||||||
|
|
@ -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:
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,11 @@ template sendKeys*(session: Session, element, keys: string) =
|
||||||
check el.isSome()
|
check el.isSome()
|
||||||
el.get().sendKeys(keys)
|
el.get().sendKeys(keys)
|
||||||
|
|
||||||
|
template clear*(session: Session, element: string) =
|
||||||
|
let el = session.findElement(element)
|
||||||
|
check el.isSome()
|
||||||
|
el.get().clear()
|
||||||
|
|
||||||
template sendKeys*(session: Session, element: string, keys: varargs[Key]) =
|
template sendKeys*(session: Session, element: string, keys: varargs[Key]) =
|
||||||
let el = session.findElement(element)
|
let el = session.findElement(element)
|
||||||
check el.isSome()
|
check el.isSome()
|
||||||
|
|
@ -31,8 +36,8 @@ template sendKeys*(session: Session, element: string, keys: varargs[Key]) =
|
||||||
for key in keys:
|
for key in keys:
|
||||||
session.press(key)
|
session.press(key)
|
||||||
|
|
||||||
template ensureExists*(session: Session, element: string) =
|
template ensureExists*(session: Session, element: string, strategy=CssSelector) =
|
||||||
let el = session.findElement(element)
|
let el = session.findElement(element, strategy)
|
||||||
check el.isSome()
|
check el.isSome()
|
||||||
|
|
||||||
template check*(session: Session, element: string, function: untyped) =
|
template check*(session: Session, element: string, function: untyped) =
|
||||||
|
|
@ -69,9 +74,21 @@ 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, baseUrl, user, rank: string) =
|
||||||
|
with session:
|
||||||
|
navigate(baseUrl & "profile/" & user)
|
||||||
|
wait()
|
||||||
|
|
||||||
|
click "#settings-tab"
|
||||||
|
|
||||||
|
click "#rank-field"
|
||||||
|
click("#rank-field option#rank-" & rank.toLowerAscii)
|
||||||
|
|
||||||
|
click "#save-btn"
|
||||||
|
wait()
|
||||||
|
|
||||||
proc logout*(session: Session) =
|
proc logout*(session: Session) =
|
||||||
with session:
|
with session:
|
||||||
wait()
|
|
||||||
click "#profile-btn"
|
click "#profile-btn"
|
||||||
click "#profile-btn #logout-btn"
|
click "#profile-btn #logout-btn"
|
||||||
wait()
|
wait()
|
||||||
|
|
@ -83,6 +100,9 @@ proc login*(session: Session, user, password: string) =
|
||||||
with session:
|
with session:
|
||||||
click "#login-btn"
|
click "#login-btn"
|
||||||
|
|
||||||
|
clear "#login-form input[name='username']"
|
||||||
|
clear "#login-form input[name='password']"
|
||||||
|
|
||||||
sendKeys "#login-form input[name='username']", user
|
sendKeys "#login-form input[name='username']", user
|
||||||
sendKeys "#login-form input[name='password']", password
|
sendKeys "#login-form input[name='password']", password
|
||||||
|
|
||||||
|
|
@ -99,6 +119,10 @@ proc register*(session: Session, user, password: string) =
|
||||||
with session:
|
with session:
|
||||||
click "#signup-btn"
|
click "#signup-btn"
|
||||||
|
|
||||||
|
clear "#signup-form input[name='email']"
|
||||||
|
clear "#signup-form input[name='username']"
|
||||||
|
clear "#signup-form input[name='password']"
|
||||||
|
|
||||||
sendKeys "#signup-form input[name='email']", user & "@" & user & ".com"
|
sendKeys "#signup-form input[name='email']", user & "@" & user & ".com"
|
||||||
sendKeys "#signup-form input[name='username']", user
|
sendKeys "#signup-form input[name='username']", user
|
||||||
sendKeys "#signup-form input[name='password']", password
|
sendKeys "#signup-form input[name='password']", password
|
||||||
|
|
@ -125,16 +149,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"
|
|
||||||
|
|
|
||||||
|
|
@ -14,33 +14,27 @@ proc test*(session: Session, baseUrl: string) =
|
||||||
|
|
||||||
# Change rank to `user` so they can post.
|
# Change rank to `user` so they can post.
|
||||||
login("admin", "admin")
|
login("admin", "admin")
|
||||||
|
setUserRank(baseUrl, "issue181", "user")
|
||||||
navigate(baseUrl & "profile/user")
|
|
||||||
wait()
|
|
||||||
changeRank("user")
|
|
||||||
logout()
|
logout()
|
||||||
|
|
||||||
login("issue181", "issue181")
|
login("issue181", "issue181")
|
||||||
|
navigate(baseUrl)
|
||||||
|
wait()
|
||||||
|
|
||||||
const title = "Testing issue 181."
|
const title = "Testing issue 181."
|
||||||
createThread(title, "Test for issue #181")
|
createThread(title, "Test for issue #181")
|
||||||
|
|
||||||
logout()
|
logout()
|
||||||
wait()
|
|
||||||
|
|
||||||
login("admin", "admin")
|
login("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()
|
||||||
checkText("tr.banned .thread-title > a", title)
|
checkText("tr.banned .thread-title > a", title)
|
||||||
|
|
||||||
session.navigate(baseUrl)
|
|
||||||
session.wait()
|
|
||||||
logout(session)
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,4 @@ proc test*(session: Session, baseUrl: string) =
|
||||||
with session:
|
with session:
|
||||||
register("test", "test")
|
register("test", "test")
|
||||||
|
|
||||||
session.navigate(baseUrl)
|
session.logout()
|
||||||
session.wait()
|
|
||||||
logout(session)
|
|
||||||
|
|
|
||||||
|
|
@ -2,18 +2,22 @@ import unittest, options, os, common
|
||||||
|
|
||||||
import webdriver
|
import webdriver
|
||||||
|
|
||||||
proc test*(session: Session, baseUrl: string) =
|
let
|
||||||
let
|
|
||||||
userTitleStr = "This is a user thread!"
|
userTitleStr = "This is a user thread!"
|
||||||
userContentStr = "A user has filled this out"
|
userContentStr = "A user has filled this out"
|
||||||
|
|
||||||
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 "admin", "admin"
|
||||||
|
setUserRank baseUrl, "user", "banned"
|
||||||
|
logout()
|
||||||
|
|
||||||
|
proc userTests(session: Session, baseUrl: string) =
|
||||||
suite "user thread tests":
|
suite "user thread tests":
|
||||||
session.navigate(baseUrl)
|
session.login("user", "user")
|
||||||
session.wait()
|
|
||||||
login(session, "user", "user")
|
|
||||||
|
|
||||||
setup:
|
setup:
|
||||||
session.navigate(baseUrl)
|
session.navigate(baseUrl)
|
||||||
|
|
@ -33,19 +37,57 @@ proc test*(session: Session, baseUrl: string) =
|
||||||
checkText "#thread-title", userTitleStr
|
checkText "#thread-title", userTitleStr
|
||||||
checkText ".original-post div.post-content", userContentStr
|
checkText ".original-post div.post-content", userContentStr
|
||||||
|
|
||||||
session.navigate(baseUrl)
|
session.logout()
|
||||||
session.wait()
|
|
||||||
logout(session)
|
|
||||||
|
|
||||||
|
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":
|
||||||
|
with session:
|
||||||
|
navigate baseUrl
|
||||||
|
wait()
|
||||||
|
login "banned", "banned"
|
||||||
|
|
||||||
|
test "can't start thread":
|
||||||
|
with session:
|
||||||
|
click "#new-thread-btn"
|
||||||
|
wait()
|
||||||
|
|
||||||
|
sendKeys "#thread-title", "test"
|
||||||
|
sendKeys "#reply-textarea", "test"
|
||||||
|
|
||||||
|
click "#create-thread-btn"
|
||||||
|
wait()
|
||||||
|
|
||||||
|
ensureExists "#new-thread p.text-error"
|
||||||
|
|
||||||
|
session.logout()
|
||||||
|
|
||||||
|
proc adminTests(session: Session, baseUrl: string) =
|
||||||
suite "admin thread tests":
|
suite "admin thread tests":
|
||||||
session.navigate(baseUrl)
|
session.login("admin", "admin")
|
||||||
session.wait()
|
|
||||||
login(session, "admin", "admin")
|
|
||||||
|
|
||||||
setup:
|
setup:
|
||||||
session.navigate(baseUrl)
|
session.navigate(baseUrl)
|
||||||
session.wait()
|
session.wait()
|
||||||
|
|
||||||
|
test "can view banned thread":
|
||||||
|
with session:
|
||||||
|
ensureExists userTitleStr, LinkTextSelector
|
||||||
|
|
||||||
test "can create thread":
|
test "can create thread":
|
||||||
with session:
|
with session:
|
||||||
click "#new-thread-btn"
|
click "#new-thread-btn"
|
||||||
|
|
@ -116,6 +158,19 @@ proc test*(session: Session, baseUrl: string) =
|
||||||
# Make sure the forum post is gone
|
# Make sure the forum post is gone
|
||||||
checkIsNone adminTitleStr, LinkTextSelector
|
checkIsNone adminTitleStr, LinkTextSelector
|
||||||
|
|
||||||
|
session.logout()
|
||||||
|
|
||||||
|
proc test*(session: Session, baseUrl: string) =
|
||||||
|
session.navigate(baseUrl)
|
||||||
|
session.wait()
|
||||||
|
|
||||||
|
userTests(session, baseUrl)
|
||||||
|
|
||||||
|
banUser(session, baseUrl)
|
||||||
|
|
||||||
|
bannedTests(session, baseUrl)
|
||||||
|
anonymousTests(session, baseUrl)
|
||||||
|
adminTests(session, baseUrl)
|
||||||
|
|
||||||
session.navigate(baseUrl)
|
session.navigate(baseUrl)
|
||||||
session.wait()
|
session.wait()
|
||||||
logout(session)
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue