Add test for banned user
This commit is contained in:
parent
8c16a776b6
commit
a6c0fe691c
5 changed files with 80 additions and 32 deletions
|
|
@ -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),
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,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,8 +69,22 @@ 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 logout*(session: Session) =
|
proc setUserRank*(session: Session, user, rank, baseUrl: string) =
|
||||||
with session:
|
with session:
|
||||||
|
navigate(baseUrl & "profile/" & user)
|
||||||
|
wait()
|
||||||
|
|
||||||
|
click "#settings-tab"
|
||||||
|
|
||||||
|
click "#rank-field"
|
||||||
|
click("#rank-field-" & rank.toLowerAscii)
|
||||||
|
|
||||||
|
click "#save-btn"
|
||||||
|
wait()
|
||||||
|
|
||||||
|
proc logout*(session: Session, baseUrl: string) =
|
||||||
|
with session:
|
||||||
|
navigate baseUrl
|
||||||
wait()
|
wait()
|
||||||
click "#profile-btn"
|
click "#profile-btn"
|
||||||
click "#profile-btn #logout-btn"
|
click "#profile-btn #logout-btn"
|
||||||
|
|
@ -79,8 +93,10 @@ proc logout*(session: Session) =
|
||||||
# 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"
|
||||||
|
|
||||||
proc login*(session: Session, user, password: string) =
|
proc login*(session: Session, baseUrl, user, password: string) =
|
||||||
with session:
|
with session:
|
||||||
|
navigate baseUrl
|
||||||
|
wait()
|
||||||
click "#login-btn"
|
click "#login-btn"
|
||||||
|
|
||||||
sendKeys "#login-form input[name='username']", user
|
sendKeys "#login-form input[name='username']", user
|
||||||
|
|
@ -138,3 +154,9 @@ proc changeRank*(session: Session, rank: string) =
|
||||||
|
|
||||||
# TODO: Getting an "element click intercepted" error here.
|
# TODO: Getting an "element click intercepted" error here.
|
||||||
click "#save-btn"
|
click "#save-btn"
|
||||||
|
|
||||||
|
proc banUser*(session: Session, baseUrl: string) =
|
||||||
|
with session:
|
||||||
|
login baseUrl, "admin", "admin"
|
||||||
|
setUserRank "user", "banned", baseUrl
|
||||||
|
logout baseUrl
|
||||||
|
|
|
||||||
|
|
@ -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(baseUrl)
|
||||||
session.wait()
|
|
||||||
logout(session)
|
|
||||||
|
|
|
||||||
|
|
@ -2,18 +2,17 @@ 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 userTests(session: Session, baseUrl: string) =
|
||||||
suite "user thread tests":
|
suite "user thread tests":
|
||||||
session.navigate(baseUrl)
|
session.login(baseUrl, "user", "user")
|
||||||
session.wait()
|
|
||||||
login(session, "user", "user")
|
|
||||||
|
|
||||||
setup:
|
setup:
|
||||||
session.navigate(baseUrl)
|
session.navigate(baseUrl)
|
||||||
|
|
@ -33,19 +32,39 @@ 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(baseUrl)
|
||||||
session.wait()
|
|
||||||
logout(session)
|
|
||||||
|
|
||||||
|
proc bannedTests(session: Session, baseUrl: string) =
|
||||||
|
suite "banned user thread tests":
|
||||||
|
session.login(baseUrl, "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(baseUrl)
|
||||||
|
|
||||||
|
proc adminTests(session: Session, baseUrl: string) =
|
||||||
suite "admin thread tests":
|
suite "admin thread tests":
|
||||||
session.navigate(baseUrl)
|
session.login(baseUrl, "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 +135,12 @@ 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.navigate(baseUrl)
|
session.logout(baseUrl)
|
||||||
session.wait()
|
|
||||||
logout(session)
|
proc test*(session: Session, baseUrl: string) =
|
||||||
|
userTests(session, baseUrl)
|
||||||
|
|
||||||
|
banUser(session, baseUrl)
|
||||||
|
|
||||||
|
bannedTests(session, baseUrl)
|
||||||
|
adminTests(session, baseUrl)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue