From 8c10936a23d0b6e1289e38f85c09c0ce62d82672 Mon Sep 17 00:00:00 2001
From: Nikhil Tanwar <2002nikhiltanwar@gmail.com>
Date: Fri, 24 Feb 2023 00:59:52 +0530
Subject: [PATCH] Tests for /nojs
Adds 2 tests for /nojs endpoint
Test 1: no_js_default - Without any filters
Test 2: no_js_eng_lang - With lang=eng as filter
---
static/templates/no_js.html | 4 +-
test/library_server.cpp | 178 ++++++++++++++++++++++++++++++++++++
2 files changed, 180 insertions(+), 2 deletions(-)
diff --git a/static/templates/no_js.html b/static/templates/no_js.html
index d98d2d8a3..1aa3ea780 100644
--- a/static/templates/no_js.html
+++ b/static/templates/no_js.html
@@ -40,7 +40,7 @@
.book__wrapper:hover {
transform: scale(1.0);
}
-
+
.book__link__wrapper {
grid-column: 1 / 3;
grid-row: 1 / 3;
@@ -67,7 +67,7 @@
diff --git a/test/library_server.cpp b/test/library_server.cpp
index 723d0c60c..c47759d9b 100644
--- a/test/library_server.cpp
+++ b/test/library_server.cpp
@@ -941,6 +941,184 @@ TEST_F(LibraryServerTest, no_name_mapper_catalog_v2_individual_entry_access)
EXPECT_EQ(r1->status, 404);
}
+#define HTML_PREAMBLE \
+ "\n" \
+ "\n" \
+ "
\n" \
+ " \n"
+
+#define RAY_CHARLES_BOOK_HTML \
+ "
\n" \
+ "
\n" \
+ "
fra
\n" \
+ "
\n" \
+ "
\n"
+#define CHARLES_RAY_BOOK_HTML \
+ "
\n" \
+ "
\n" \
+ "
eng
\n" \
+ "
\n" \
+ "
\n"
+#define RAY_CHARLES_UNCTZ \
+ "
\n" \
+ "
\n" \
+ "
rus
\n" \
+ "
\n" \
+ "
\n"
+
+#define FINAL_HTML_TEXT \
+ "
\n" \
+ " \n" \
+ " \n" \
+ " \n" \
+ "\n"
+
+
+#define FILTERS_HTML(SELECTED_ENG) \
+ " \n" \
+ "
\n" \
+ " \n" \
+ "
\n" \
+ "
\n" \
+ " \n" \
+ "
\n" \
+ "
\n" \
+ " \n" \
+ "
\n" \
+ "
" X " book(s)
\n"
+
+TEST_F(LibraryServerTest, no_js_default)
+{
+ const auto r = zfs1_->GET("/ROOT%23%3F/nojs");
+ EXPECT_EQ(r->status, 200);
+ EXPECT_EQ(maskVariableOPDSFeedData(r->body),
+ HTML_PREAMBLE
+ FILTERS_HTML("")
+ HOME_BODY_TEXT("3")
+ RAY_CHARLES_BOOK_HTML
+ CHARLES_RAY_BOOK_HTML
+ RAY_CHARLES_UNCTZ
+ FINAL_HTML_TEXT);
+}
+TEST_F(LibraryServerTest, no_js_eng_lang)
+{
+ const auto r = zfs1_->GET("/ROOT%23%3F/nojs?lang=eng");
+ EXPECT_EQ(r->status, 200);
+ EXPECT_EQ(maskVariableOPDSFeedData(r->body),
+ HTML_PREAMBLE
+ FILTERS_HTML(" selected ")
+ HOME_BODY_TEXT("1")
+ CHARLES_RAY_BOOK_HTML
+ FINAL_HTML_TEXT);
+}
#undef EXPECT_SEARCH_RESULTS