Rewrite threads tests with new macro
This commit is contained in:
parent
1b55aec5d2
commit
d7f3a038a9
1 changed files with 44 additions and 27 deletions
|
|
@ -3,44 +3,61 @@ import unittest, options, os, common
|
||||||
import webdriver
|
import webdriver
|
||||||
|
|
||||||
proc test*(session: Session, baseUrl: string) =
|
proc test*(session: Session, baseUrl: string) =
|
||||||
session.navigate(baseUrl)
|
let
|
||||||
|
titleStr = "This is a thread title!"
|
||||||
waitForLoad(session)
|
contentStr = "This is content"
|
||||||
|
|
||||||
login(session, "admin", "admin")
|
|
||||||
|
|
||||||
test "can create thread":
|
|
||||||
let newThreadBtn = session.findElement("#new-thread-btn").get()
|
|
||||||
newThreadBtn.click()
|
|
||||||
|
|
||||||
|
suite "thread tests":
|
||||||
|
session.navigate(baseUrl)
|
||||||
waitForLoad(session)
|
waitForLoad(session)
|
||||||
|
login(session, "admin", "admin")
|
||||||
|
|
||||||
let newThread = session.findElement("#new-thread")
|
setup:
|
||||||
check newThread.isSome()
|
session.navigate(baseUrl)
|
||||||
|
waitForLoad(session)
|
||||||
|
|
||||||
let createThreadBtn = session.findElement("#create-thread-btn")
|
test "can create thread":
|
||||||
check createThreadBtn.isSome()
|
with session:
|
||||||
|
click "#new-thread-btn"
|
||||||
|
wait()
|
||||||
|
|
||||||
|
sendKeys "#thread-title", titleStr
|
||||||
|
sendKeys "#reply-textarea", contentStr
|
||||||
|
|
||||||
let threadTitle = session.findElement("#thread-title")
|
click "#create-thread-btn"
|
||||||
check threadTitle.isSome()
|
wait()
|
||||||
|
|
||||||
let replyBox = session.findElement("#reply-textarea")
|
checkText "#thread-title", titleStr
|
||||||
check replyBox.isSome()
|
checkText ".original-post div.post-content", contentStr
|
||||||
|
|
||||||
threadTitle.get().sendKeys("This is a thread title!")
|
test "try create duplicate thread":
|
||||||
replyBox.get().sendKeys("This is content.")
|
with session:
|
||||||
|
click "#new-thread-btn"
|
||||||
|
wait()
|
||||||
|
ensureExists "#new-thread"
|
||||||
|
|
||||||
createThreadBtn.get().click()
|
sendKeys "#thread-title", titleStr
|
||||||
|
sendKeys "#reply-textarea", contentStr
|
||||||
|
|
||||||
waitForLoad(session)
|
click "#create-thread-btn"
|
||||||
|
|
||||||
let newThreadTitle = session.findElement("#thread-title")
|
wait()
|
||||||
check newThreadTitle.isSome()
|
|
||||||
|
|
||||||
check newThreadTitle.get().getText() == "This is a thread title!"
|
ensureExists "#new-thread p.text-error"
|
||||||
|
|
||||||
let content = session.findElement(".original-post div.post-content")
|
test "can edit post":
|
||||||
check content.isSome()
|
let modificationText = " and I edited it!"
|
||||||
|
with session:
|
||||||
|
click titleStr, LinkTextSelector
|
||||||
|
wait()
|
||||||
|
|
||||||
check content.get().getText() == "This is content."
|
click ".post-buttons .edit-button"
|
||||||
|
wait()
|
||||||
|
|
||||||
|
sendKeys ".original-post #reply-textarea", modificationText
|
||||||
|
click ".edit-buttons .save-button"
|
||||||
|
wait()
|
||||||
|
|
||||||
|
checkText ".original-post div.post-content", contentStr & modificationText
|
||||||
|
|
||||||
|
logout(session)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue