Skip to content
This repository has been archived by the owner on Oct 24, 2022. It is now read-only.

Commit

Permalink
Merge pull request #366 from MITLibraries/357_search_tests
Browse files Browse the repository at this point in the history
Adds additional search tests
  • Loading branch information
JPrevost committed Sep 24, 2015
2 parents a25bbb1 + 1fe6ec6 commit 8848006
Showing 1 changed file with 55 additions and 4 deletions.
59 changes: 55 additions & 4 deletions test/integration/SearchPagesSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ class SearchPagesSpec extends Specification {
browser.pageSource must contain("Search for stuff!")
}

"can search for items by scheme" in new WithBrowser(
"search for items by scheme" in new WithBrowser(
app = FakeApplication(additionalConfiguration = inMemoryDatabase())) {
item_factory(1)
val i = Item.make(1, 1, "location", "abc:123")
val s1 = Scheme.make("scheme_1_tag", "gentype", "cat", "scheme_1 description",
Some("link"), Some("logo"))
val s2 = Scheme.make("scheme_2_tag", "gentype", "cat", "scheme_2 description",
Some("link"), Some("logo"))
val s3 = Scheme.make("scheme_with_no_items", "gentype", "cat", "scheme_2 description",
val s3 = Scheme.make("scheme_with_no_items", "gentype", "cat", "scheme_3 description",
Some("link"), Some("logo"))
i.addMetadata("title", "I like popcorn")
val t1 = Topic.make(s1.id, "tag1", "name1")
Expand Down Expand Up @@ -87,13 +87,13 @@ class SearchPagesSpec extends Specification {
Thread sleep 500
}

"can search for topics" in new WithBrowser(
"search for topics" in new WithBrowser(
app = FakeApplication(additionalConfiguration = inMemoryDatabase())) {
val s1 = Scheme.make("scheme_1_tag", "gentype", "cat", "scheme_1 description",
Some("link"), Some("logo"))
val s2 = Scheme.make("scheme_2_tag", "gentype", "cat", "scheme_2 description",
Some("link"), Some("logo"))
val s3 = Scheme.make("scheme_with_no_items", "gentype", "cat", "scheme_2 description",
val s3 = Scheme.make("scheme_with_no_items", "gentype", "cat", "scheme_3 description",
Some("link"), Some("logo"))
val t1 = Topic.make(s1.id, "Some Institution, Anytown, ST 02140", "No Label")
val t2 = Topic.make(s2.id, "Dept. of Stuff, Some Institution, Anytown, ST 02140", "No Label")
Expand All @@ -116,5 +116,56 @@ class SearchPagesSpec extends Specification {
Indexer.deindex_all("topic")
Thread sleep 500
}

"return atom formatted item results" in new WithBrowser(
app = FakeApplication(additionalConfiguration = inMemoryDatabase())) {
item_factory(1)
val i = Item.make(1, 1, "location", "abc:123")
val s1 = Scheme.make("scheme_1_tag", "gentype", "cat", "scheme_1 description",
Some("link"), Some("logo"))
val s2 = Scheme.make("scheme_2_tag", "gentype", "cat", "scheme_2 description",
Some("link"), Some("logo"))
val s3 = Scheme.make("scheme_with_no_items", "gentype", "cat", "scheme_3 description",
Some("link"), Some("logo"))
i.addMetadata("title", "I like popcorn")
val t1 = Topic.make(s1.id, "tag1", "name1")
val t2 = Topic.make(s2.id, "tag2", "name2")
i.addTopic(t1)
i.addTopic(t2)
Indexer.deindex_all("topic")
Thread sleep 500
Indexer.reindex("item")
Thread sleep 500

browser.goTo("http://localhost:" + port + "/search/results?q=stuff&target=item&format=atom")
browser.pageSource must contain("opensearch:itemsPerPage")
browser.pageSource must contain("opensearch:totalResults")
browser.pageSource must contain("""<opensearch:Query role="request" searchTerms="stuff" startPage="0"/>""")

Indexer.deindex_all("topic")
Thread sleep 500
}

"handle invalid search scope" in new WithBrowser(
app = FakeApplication(additionalConfiguration = inMemoryDatabase())) {
browser.goTo("http://localhost:" + port + "/search/results?q=stuff&target=stuff")
browser.pageSource must contain("Reason: Only Topic or Item searching are supported.")
}

"provide an opensearch description" in {
"for Items" in new WithBrowser(
app = FakeApplication(additionalConfiguration = inMemoryDatabase())) {
browser.goTo("http://localhost:" + port + "/search/description/item")
browser.pageSource must contain("/search/results?q={searchTerms}&amp;page={startPage?}&amp;perpage={count?}&amp;target=item&amp;format=html")
browser.pageSource must contain("/search/results?q={searchTerms}&amp;page={startPage?}&amp;perpage={count?}&amp;target=item&amp;format=atom")
}

"for Topics" in new WithBrowser(
app = FakeApplication(additionalConfiguration = inMemoryDatabase())) {
browser.goTo("http://localhost:" + port + "/search/description/topic")
browser.pageSource must contain("/search/results?q={searchTerms}&amp;page={startPage?}&amp;perpage={count?}&amp;target=topic&amp;format=html")
browser.pageSource must contain("/search/results?q={searchTerms}&amp;page={startPage?}&amp;perpage={count?}&amp;target=topic&amp;format=atom")
}
}
}
}

0 comments on commit 8848006

Please sign in to comment.