Skip to content

Commit 35e0de7

Browse files
authored
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
1 parent 7954a38 commit 35e0de7

File tree

2 files changed

+41
-4
lines changed

2 files changed

+41
-4
lines changed

src/frontend/postbutton.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ when defined(js):
190190
else: ""
191191

192192
result = buildHtml():
193-
button(class="btn btn-secondary",
193+
button(class="btn btn-secondary", id="lock-btn",
194194
onClick=(e: Event, n: VNode) =>
195195
onLockClick(e, n, state, thread),
196196
"data-tooltip"=tooltip,

tests/browsertests/threads.nim

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import unittest, common
2-
32
import webdriver
43

54
let
@@ -71,6 +70,19 @@ proc userTests(session: Session, baseUrl: string) =
7170

7271
checkIsNone "#pin-btn"
7372

73+
test "cannot lock threads":
74+
with session:
75+
navigate(baseUrl)
76+
77+
click "#new-thread-btn"
78+
79+
sendKeys "#thread-title", "Locking"
80+
sendkeys "#reply-textarea", "Cannot lock as an user"
81+
82+
click "#create-thread-btn"
83+
84+
checkIsNone "#lock-btn"
85+
7486
session.logout()
7587

7688
proc anonymousTests(session: Session, baseUrl: string) =
@@ -173,7 +185,7 @@ proc adminTests(session: Session, baseUrl: string) =
173185
# Make sure the forum post is gone
174186
checkIsNone adminTitleStr, LinkTextSelector
175187

176-
test "Can pin a thread":
188+
test "can pin a thread":
177189
with session:
178190
click "#new-thread-btn"
179191
sendKeys "#thread-title", "Pinned post"
@@ -199,7 +211,7 @@ proc adminTests(session: Session, baseUrl: string) =
199211
checkText "#threads-list .thread-1 .thread-title a", "Pinned post"
200212
checkText "#threads-list .thread-2 .thread-title a", "Normal post"
201213

202-
test "Can unpin a thread":
214+
test "can unpin a thread":
203215
with session:
204216
click "Pinned post", LinkTextSelector
205217
click "#pin-btn"
@@ -212,6 +224,31 @@ proc adminTests(session: Session, baseUrl: string) =
212224
checkText "#threads-list .thread-1 .thread-title a", "Normal post"
213225
checkText "#threads-list .thread-2 .thread-title a", "Pinned post"
214226

227+
test "can lock a thread":
228+
with session:
229+
click "Locking", LinkTextSelector
230+
click "#lock-btn"
231+
232+
ensureExists "#thread-title i.fas.fa-lock.fa-xs"
233+
234+
test "locked thread appears on frontpage":
235+
with session:
236+
click "#new-thread-btn"
237+
sendKeys "#thread-title", "A new locked thread"
238+
sendKeys "#reply-textarea", "This thread should appear locked on the frontpage"
239+
click "#create-thread-btn"
240+
click "#lock-btn"
241+
242+
navigate(baseUrl)
243+
ensureExists "#threads-list .thread-1 .thread-title i.fas.fa-lock.fa-xs"
244+
245+
test "can unlock a thread":
246+
with session:
247+
click "Locking", LinkTextSelector
248+
click "#lock-btn"
249+
250+
checkIsNone "#thread-title i.fas.fa-lock.fa-xs"
251+
215252
session.logout()
216253

217254
proc test*(session: Session, baseUrl: string) =

0 commit comments

Comments
 (0)