Adds attempt to test issue #181. Moves procs to common too.
Sadly the attempt wasn't a success. I decided to commit what I've got so far and come back to it later. Out of time for this now.
This commit is contained in:
parent
9f9d16467f
commit
5714ad0c6a
5 changed files with 108 additions and 31 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import os, options, unittest
|
||||
import os, options, unittest, strutils
|
||||
import webdriver
|
||||
import macros
|
||||
|
||||
|
|
@ -76,6 +76,9 @@ proc logout*(session: Session) =
|
|||
click "#profile-btn #logout-btn"
|
||||
wait()
|
||||
|
||||
# Verify we have logged out by looking for the log in button.
|
||||
ensureExists "#login-btn"
|
||||
|
||||
proc login*(session: Session, user, password: string) =
|
||||
with session:
|
||||
click "#login-btn"
|
||||
|
|
@ -86,3 +89,52 @@ proc login*(session: Session, user, password: string) =
|
|||
sendKeys "#login-form input[name='password']", Key.Enter
|
||||
|
||||
wait()
|
||||
|
||||
# Verify that the user menu has been initialised properly.
|
||||
click "#profile-btn"
|
||||
checkText "#profile-btn #profile-name", user
|
||||
click "#profile-btn"
|
||||
|
||||
proc register*(session: Session, user, password: string) =
|
||||
with session:
|
||||
click "#signup-btn"
|
||||
|
||||
sendKeys "#signup-form input[name='email']", user & "@" & user & ".com"
|
||||
sendKeys "#signup-form input[name='username']", user
|
||||
sendKeys "#signup-form input[name='password']", password
|
||||
|
||||
click "#signup-modal .create-account-btn"
|
||||
wait()
|
||||
|
||||
# Verify that the user menu has been initialised properly.
|
||||
click "#profile-btn"
|
||||
checkText "#profile-btn #profile-name", user
|
||||
# close menu
|
||||
click "#profile-btn"
|
||||
|
||||
proc createThread*(session: Session, title, content: string) =
|
||||
with session:
|
||||
click "#new-thread-btn"
|
||||
wait()
|
||||
|
||||
sendKeys "#thread-title", title
|
||||
sendKeys "#reply-textarea", content
|
||||
|
||||
click "#create-thread-btn"
|
||||
wait()
|
||||
|
||||
checkText "#thread-title", title
|
||||
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"
|
||||
|
|
|
|||
46
tests/browsertests/issue181.nim
Normal file
46
tests/browsertests/issue181.nim
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
import unittest, options, os, common
|
||||
|
||||
import webdriver
|
||||
|
||||
proc test*(session: Session, baseUrl: string) =
|
||||
session.navigate(baseUrl)
|
||||
|
||||
waitForLoad(session)
|
||||
|
||||
test "can see banned posts":
|
||||
with session:
|
||||
register("issue181", "issue181")
|
||||
logout()
|
||||
|
||||
# Change rank to `user` so they can post.
|
||||
login("admin", "admin")
|
||||
|
||||
navigate(baseUrl & "profile/user")
|
||||
wait()
|
||||
changeRank("user")
|
||||
logout()
|
||||
|
||||
login("issue181", "issue181")
|
||||
|
||||
const title = "Testing issue 181."
|
||||
createThread(title, "Test for issue #181")
|
||||
|
||||
logout()
|
||||
wait()
|
||||
|
||||
login("admin", "admin")
|
||||
|
||||
# Ban our user.
|
||||
navigate(baseUrl & "profile/issue181")
|
||||
changeRank("banned")
|
||||
|
||||
# Make sure the banned user's thread is still visible.
|
||||
navigate(baseUrl)
|
||||
ensureExists("tr.banned")
|
||||
checkText("tr.banned .thread-title > a", title)
|
||||
logout()
|
||||
checkText("tr.banned .thread-title > a", title)
|
||||
|
||||
session.navigate(baseUrl)
|
||||
session.wait()
|
||||
logout(session)
|
||||
|
|
@ -20,39 +20,16 @@ proc test*(session: Session, baseUrl: string) =
|
|||
# Logging in
|
||||
test "can login/logout":
|
||||
with session:
|
||||
click "#login-btn"
|
||||
|
||||
sendKeys "#login-form input[name='username']", "admin"
|
||||
sendKeys "#login-form input[name='password']", "admin"
|
||||
|
||||
sendKeys "#login-form input[name='password']", Key.Enter
|
||||
wait()
|
||||
|
||||
# Verify that the user menu has been initialised properly.
|
||||
click "#profile-btn"
|
||||
checkText "#profile-btn #profile-name", "admin"
|
||||
login("admin", "admin")
|
||||
|
||||
# Check whether we can log out.
|
||||
click "#logout-btn"
|
||||
logout()
|
||||
# Verify we have logged out by looking for the log in button.
|
||||
ensureExists "#login-btn"
|
||||
|
||||
test "can register":
|
||||
with session:
|
||||
click "#signup-btn"
|
||||
|
||||
sendKeys "#signup-form input[name='email']", "test@test.com"
|
||||
sendKeys "#signup-form input[name='username']", "test"
|
||||
sendKeys "#signup-form input[name='password']", "test"
|
||||
|
||||
click "#signup-modal .create-account-btn"
|
||||
wait()
|
||||
|
||||
# Verify that the user menu has been initialised properly.
|
||||
click "#profile-btn"
|
||||
checkText "#profile-btn #profile-name", "test"
|
||||
# close menu
|
||||
click "#profile-btn"
|
||||
register("test", "test")
|
||||
|
||||
session.navigate(baseUrl)
|
||||
session.wait()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue