Tests for locking threads (#284)
* Initial try at locking threads tests * Uncomment tests * Consist casing * Add correct query * Remove redundant navigate call and add frontpage check * Improve locked thread on frontpage test
This commit is contained in:
parent
7954a38601
commit
35e0de7b91
2 changed files with 41 additions and 4 deletions
|
|
@ -190,7 +190,7 @@ when defined(js):
|
||||||
else: ""
|
else: ""
|
||||||
|
|
||||||
result = buildHtml():
|
result = buildHtml():
|
||||||
button(class="btn btn-secondary",
|
button(class="btn btn-secondary", id="lock-btn",
|
||||||
onClick=(e: Event, n: VNode) =>
|
onClick=(e: Event, n: VNode) =>
|
||||||
onLockClick(e, n, state, thread),
|
onLockClick(e, n, state, thread),
|
||||||
"data-tooltip"=tooltip,
|
"data-tooltip"=tooltip,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import unittest, common
|
import unittest, common
|
||||||
|
|
||||||
import webdriver
|
import webdriver
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
@ -71,6 +70,19 @@ proc userTests(session: Session, baseUrl: string) =
|
||||||
|
|
||||||
checkIsNone "#pin-btn"
|
checkIsNone "#pin-btn"
|
||||||
|
|
||||||
|
test "cannot lock threads":
|
||||||
|
with session:
|
||||||
|
navigate(baseUrl)
|
||||||
|
|
||||||
|
click "#new-thread-btn"
|
||||||
|
|
||||||
|
sendKeys "#thread-title", "Locking"
|
||||||
|
sendkeys "#reply-textarea", "Cannot lock as an user"
|
||||||
|
|
||||||
|
click "#create-thread-btn"
|
||||||
|
|
||||||
|
checkIsNone "#lock-btn"
|
||||||
|
|
||||||
session.logout()
|
session.logout()
|
||||||
|
|
||||||
proc anonymousTests(session: Session, baseUrl: string) =
|
proc anonymousTests(session: Session, baseUrl: string) =
|
||||||
|
|
@ -173,7 +185,7 @@ proc adminTests(session: Session, baseUrl: string) =
|
||||||
# Make sure the forum post is gone
|
# Make sure the forum post is gone
|
||||||
checkIsNone adminTitleStr, LinkTextSelector
|
checkIsNone adminTitleStr, LinkTextSelector
|
||||||
|
|
||||||
test "Can pin a thread":
|
test "can pin a thread":
|
||||||
with session:
|
with session:
|
||||||
click "#new-thread-btn"
|
click "#new-thread-btn"
|
||||||
sendKeys "#thread-title", "Pinned post"
|
sendKeys "#thread-title", "Pinned post"
|
||||||
|
|
@ -199,7 +211,7 @@ proc adminTests(session: Session, baseUrl: string) =
|
||||||
checkText "#threads-list .thread-1 .thread-title a", "Pinned post"
|
checkText "#threads-list .thread-1 .thread-title a", "Pinned post"
|
||||||
checkText "#threads-list .thread-2 .thread-title a", "Normal post"
|
checkText "#threads-list .thread-2 .thread-title a", "Normal post"
|
||||||
|
|
||||||
test "Can unpin a thread":
|
test "can unpin a thread":
|
||||||
with session:
|
with session:
|
||||||
click "Pinned post", LinkTextSelector
|
click "Pinned post", LinkTextSelector
|
||||||
click "#pin-btn"
|
click "#pin-btn"
|
||||||
|
|
@ -212,6 +224,31 @@ proc adminTests(session: Session, baseUrl: string) =
|
||||||
checkText "#threads-list .thread-1 .thread-title a", "Normal post"
|
checkText "#threads-list .thread-1 .thread-title a", "Normal post"
|
||||||
checkText "#threads-list .thread-2 .thread-title a", "Pinned post"
|
checkText "#threads-list .thread-2 .thread-title a", "Pinned post"
|
||||||
|
|
||||||
|
test "can lock a thread":
|
||||||
|
with session:
|
||||||
|
click "Locking", LinkTextSelector
|
||||||
|
click "#lock-btn"
|
||||||
|
|
||||||
|
ensureExists "#thread-title i.fas.fa-lock.fa-xs"
|
||||||
|
|
||||||
|
test "locked thread appears on frontpage":
|
||||||
|
with session:
|
||||||
|
click "#new-thread-btn"
|
||||||
|
sendKeys "#thread-title", "A new locked thread"
|
||||||
|
sendKeys "#reply-textarea", "This thread should appear locked on the frontpage"
|
||||||
|
click "#create-thread-btn"
|
||||||
|
click "#lock-btn"
|
||||||
|
|
||||||
|
navigate(baseUrl)
|
||||||
|
ensureExists "#threads-list .thread-1 .thread-title i.fas.fa-lock.fa-xs"
|
||||||
|
|
||||||
|
test "can unlock a thread":
|
||||||
|
with session:
|
||||||
|
click "Locking", LinkTextSelector
|
||||||
|
click "#lock-btn"
|
||||||
|
|
||||||
|
checkIsNone "#thread-title i.fas.fa-lock.fa-xs"
|
||||||
|
|
||||||
session.logout()
|
session.logout()
|
||||||
|
|
||||||
proc test*(session: Session, baseUrl: string) =
|
proc test*(session: Session, baseUrl: string) =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue