diff --git a/tests/browsertester.nim b/tests/browsertester.nim index 0f4efe9..82bb5cb 100644 --- a/tests/browsertester.nim +++ b/tests/browsertester.nim @@ -43,7 +43,7 @@ template withBackend(body: untyped): untyped = body -import browsertests/[scenario1, threads, issue181] +import browsertests/[scenario1, threads, issue181, categories] when isMainModule: spawn runProcess("geckodriver -p 4444 --log config") @@ -64,6 +64,7 @@ when isMainModule: withBackend: scenario1.test(session, baseUrl) threads.test(session, baseUrl) + categories.test(session, baseUrl) issue181.test(session, baseUrl) session.close() diff --git a/tests/browsertests/categories.nim b/tests/browsertests/categories.nim new file mode 100644 index 0000000..6f91f9d --- /dev/null +++ b/tests/browsertests/categories.nim @@ -0,0 +1,52 @@ +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 categoriesTests(session: Session, baseUrl: string) = + let + title = "Category Test" + content = "Choosing category test" + + with session: + navigate baseUrl + wait() + login "user", "user" + + 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 test*(session: Session, baseUrl: string) = + session.navigate(baseUrl) + session.wait() + + categoriesTests(session, baseUrl) + + session.navigate(baseUrl) + session.wait() \ No newline at end of file