Rewrite threads tests with new macro

This commit is contained in:
Joey Yakimowich-Payne 2018-07-16 14:51:21 +09:00
commit d7f3a038a9

View file

@ -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) =
let
titleStr = "This is a thread title!"
contentStr = "This is content"
suite "thread tests":
session.navigate(baseUrl) session.navigate(baseUrl)
waitForLoad(session) waitForLoad(session)
login(session, "admin", "admin") login(session, "admin", "admin")
setup:
session.navigate(baseUrl)
waitForLoad(session)
test "can create thread": test "can create thread":
let newThreadBtn = session.findElement("#new-thread-btn").get() with session:
newThreadBtn.click() click "#new-thread-btn"
wait()
waitForLoad(session) sendKeys "#thread-title", titleStr
sendKeys "#reply-textarea", contentStr
let newThread = session.findElement("#new-thread") click "#create-thread-btn"
check newThread.isSome() wait()
let createThreadBtn = session.findElement("#create-thread-btn") checkText "#thread-title", titleStr
check createThreadBtn.isSome() checkText ".original-post div.post-content", contentStr
test "try create duplicate thread":
with session:
click "#new-thread-btn"
wait()
ensureExists "#new-thread"
let threadTitle = session.findElement("#thread-title") sendKeys "#thread-title", titleStr
check threadTitle.isSome() sendKeys "#reply-textarea", contentStr
let replyBox = session.findElement("#reply-textarea") click "#create-thread-btn"
check replyBox.isSome()
threadTitle.get().sendKeys("This is a thread title!") wait()
replyBox.get().sendKeys("This is content.")
createThreadBtn.get().click() ensureExists "#new-thread p.text-error"
waitForLoad(session) test "can edit post":
let modificationText = " and I edited it!"
with session:
click titleStr, LinkTextSelector
wait()
let newThreadTitle = session.findElement("#thread-title") click ".post-buttons .edit-button"
check newThreadTitle.isSome() wait()
check newThreadTitle.get().getText() == "This is a thread title!" sendKeys ".original-post #reply-textarea", modificationText
click ".edit-buttons .save-button"
wait()
let content = session.findElement(".original-post div.post-content") checkText ".original-post div.post-content", contentStr & modificationText
check content.isSome()
check content.get().getText() == "This is content." logout(session)