105 lines
No EOL
2.3 KiB
Nim
105 lines
No EOL
2.3 KiB
Nim
import unittest, options, os, common
|
|
|
|
import webdriver
|
|
|
|
proc selectCategory(session: Session, name: string) =
|
|
with session:
|
|
click "#category-selection .dropdown-toggle"
|
|
|
|
click "#category-selection ." & name
|
|
|
|
|
|
proc categoriesUserTests(session: Session, baseUrl: string) =
|
|
let
|
|
title = "Category Test"
|
|
content = "Choosing category test"
|
|
|
|
suite "user tests":
|
|
|
|
with session:
|
|
navigate baseUrl
|
|
wait()
|
|
login "user", "user"
|
|
|
|
setup:
|
|
with session:
|
|
navigate baseUrl
|
|
wait()
|
|
|
|
test "no category add available":
|
|
with session:
|
|
click "#new-thread-btn"
|
|
wait()
|
|
|
|
checkIsNone "#add-category"
|
|
|
|
test "can create category thread":
|
|
with session:
|
|
click "#new-thread-btn"
|
|
wait()
|
|
|
|
sendKeys "#thread-title", title
|
|
|
|
selectCategory "fun"
|
|
|
|
sendKeys "#reply-textarea", content
|
|
|
|
click "#create-thread-btn"
|
|
wait()
|
|
|
|
checkText "#thread-title .category", "Fun"
|
|
|
|
navigate baseUrl
|
|
wait()
|
|
|
|
ensureExists title, LinkTextSelector
|
|
|
|
session.logout()
|
|
|
|
proc categoriesAdminTests(session: Session, baseUrl: string) =
|
|
let
|
|
name = "Category Test"
|
|
color = "Creating category test"
|
|
description = "This is a description"
|
|
|
|
suite "admin tests":
|
|
with session:
|
|
navigate baseUrl
|
|
wait()
|
|
login "admin", "admin"
|
|
|
|
test "can create category":
|
|
with session:
|
|
click "#new-thread-btn"
|
|
wait()
|
|
|
|
ensureExists "#add-category"
|
|
|
|
click "#add-category .plus-btn"
|
|
wait()
|
|
|
|
clear "#add-category input[name='name']"
|
|
clear "#add-category input[name='color']"
|
|
clear "#add-category input[name='description']"
|
|
|
|
|
|
sendKeys "#add-category input[name='name']", name
|
|
sendKeys "#add-category input[name='color']", color
|
|
sendKeys "#add-category input[name='description']", description
|
|
|
|
click "#add-category #add-category-btn"
|
|
wait()
|
|
|
|
checkText "#category-selection .selected-category", name
|
|
|
|
session.logout()
|
|
|
|
proc test*(session: Session, baseUrl: string) =
|
|
session.navigate(baseUrl)
|
|
session.wait()
|
|
|
|
categoriesUserTests(session, baseUrl)
|
|
categoriesAdminTests(session, baseUrl)
|
|
|
|
session.navigate(baseUrl)
|
|
session.wait() |