Add create category test
This commit is contained in:
parent
9127bc4c88
commit
31d3b2701d
3 changed files with 52 additions and 19 deletions
|
|
@ -1 +1,2 @@
|
|||
--threads:on
|
||||
--threads:on
|
||||
--path:"../src/frontend"
|
||||
|
|
@ -1,12 +1,33 @@
|
|||
import unittest, options, common, os
|
||||
|
||||
import webdriver
|
||||
|
||||
import karaxutils
|
||||
|
||||
proc selectCategory(session: Session, name: string) =
|
||||
with session:
|
||||
click "#category-selection .dropdown-toggle"
|
||||
click "#category-selection ." & name
|
||||
|
||||
proc createCategory(session: Session, baseUrl, name, color, description: string) =
|
||||
with session:
|
||||
navigate baseUrl
|
||||
click "#categories-btn"
|
||||
|
||||
ensureExists "#add-category"
|
||||
|
||||
click "#add-category .plus-btn"
|
||||
|
||||
clear "#add-category input[name='name']"
|
||||
clear "#add-category input[name='description']"
|
||||
|
||||
sendKeys "#add-category input[name='name']", name
|
||||
setColor "#add-category input[name='color']", color
|
||||
sendKeys "#add-category input[name='description']", description
|
||||
|
||||
click "#add-category #add-category-btn"
|
||||
|
||||
checkText "#category-" & name.slug(), name
|
||||
|
||||
proc categoriesUserTests(session: Session, baseUrl: string) =
|
||||
let
|
||||
title = "Category Test"
|
||||
|
|
@ -105,17 +126,17 @@ proc categoriesUserTests(session: Session, baseUrl: string) =
|
|||
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
|
||||
login "admin", "admin"
|
||||
|
||||
test "can create category":
|
||||
test "can create category via dropdown":
|
||||
let
|
||||
name = "Category Test"
|
||||
color = "#720904"
|
||||
description = "This is a description"
|
||||
|
||||
with session:
|
||||
click "#new-thread-btn"
|
||||
|
||||
|
|
@ -124,27 +145,35 @@ proc categoriesAdminTests(session: Session, baseUrl: string) =
|
|||
click "#add-category .plus-btn"
|
||||
|
||||
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
|
||||
setColor "#add-category input[name='color']", color
|
||||
sendKeys "#add-category input[name='description']", description
|
||||
|
||||
click "#add-category #add-category-btn"
|
||||
|
||||
checkText "#category-selection .selected-category", name
|
||||
|
||||
test "category adding disabled on admin logout":
|
||||
with session:
|
||||
navigate(baseUrl & "c/0")
|
||||
ensureExists "#add-category"
|
||||
logout()
|
||||
test "can create category on category page":
|
||||
let
|
||||
name = "Category Test Page"
|
||||
color = "#70B4D4"
|
||||
description = "This is a description on category page"
|
||||
|
||||
checkIsNone "#add-category"
|
||||
navigate baseUrl
|
||||
with session:
|
||||
createCategory baseUrl, name, color, description
|
||||
|
||||
login "admin", "admin"
|
||||
test "category adding disabled on admin logout":
|
||||
with session:
|
||||
navigate(baseUrl & "c/0")
|
||||
ensureExists "#add-category"
|
||||
logout()
|
||||
|
||||
checkIsNone "#add-category"
|
||||
navigate baseUrl
|
||||
|
||||
login "admin", "admin"
|
||||
|
||||
session.logout()
|
||||
|
||||
|
|
|
|||
|
|
@ -64,6 +64,10 @@ template check*(session: Session, element: string,
|
|||
let el = session.waitForElement(element, strategy)
|
||||
check function(el)
|
||||
|
||||
proc setColor*(session: Session, element, color: string, strategy=CssSelector) =
|
||||
let el = session.waitForElement(element, strategy)
|
||||
discard session.execute("arguments[0].setAttribute('value', '" & color & "')", el.get())
|
||||
|
||||
template checkIsNone*(session: Session, element: string, strategy=CssSelector) =
|
||||
discard session.waitForElement(element, strategy, waitCondition=elementIsNone)
|
||||
|
||||
|
|
@ -105,7 +109,6 @@ proc waitForElements*(
|
|||
|
||||
while true:
|
||||
let loading = session.findElements(selector, strategy)
|
||||
echo loading
|
||||
if loading.len > 0:
|
||||
return loading
|
||||
sleep(pollTime)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue