From 0af291dc102969da8d230a7d23202f972d9caf1f Mon Sep 17 00:00:00 2001 From: Joey Yakimowich-Payne Date: Wed, 8 Aug 2018 19:12:28 +0900 Subject: [PATCH] Add test for category adding --- tests/browsertests/categories.nim | 99 ++++++++++++++++++++++++------- 1 file changed, 76 insertions(+), 23 deletions(-) diff --git a/tests/browsertests/categories.nim b/tests/browsertests/categories.nim index 6f91f9d..7924ac4 100644 --- a/tests/browsertests/categories.nim +++ b/tests/browsertests/categories.nim @@ -9,44 +9,97 @@ proc selectCategory(session: Session, name: string) = click "#category-selection ." & name -proc categoriesTests(session: Session, baseUrl: string) = +proc categoriesUserTests(session: Session, baseUrl: string) = let title = "Category Test" content = "Choosing category test" - with session: - navigate baseUrl - wait() - login "user", "user" + suite "user tests": - 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() + login "user", "user" - ensureExists title, LinkTextSelector + setup: + with session: + navigate baseUrl + wait() - session.logout() + 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() - categoriesTests(session, baseUrl) + categoriesUserTests(session, baseUrl) + categoriesAdminTests(session, baseUrl) session.navigate(baseUrl) session.wait() \ No newline at end of file