Encourage login on zero matches (fixes #67)
Change-Id: Ic7805d2286de9fc24d06ca94c71b7ab4890f7973
diff --git a/t/fixtures/response_query_paum_o0_c25.json b/t/fixtures/response_query_paum_o0_c25.json
new file mode 100644
index 0000000..ca9ebba
--- /dev/null
+++ b/t/fixtures/response_query_paum_o0_c25.json
@@ -0,0 +1,41 @@
+{
+ "status" : 200,
+ "json" : {
+ "@context" : "http://korap.ids-mannheim.de/ns/KoralQuery/v0.3/context.jsonld",
+ "meta" : {
+ "count" : 25,
+ "startIndex" : 0,
+ "authorized" : null,
+ "timeout" : 120000,
+ "context" : {
+ "left" : ["token",40],
+ "right" : ["token",40]
+ },
+ "fields" : ["pubDate","subTitle","author","pubPlace","title","textSigle","UID","ID","layerInfos","corpusSigle","docSigle","corpusID","textClass"],
+ "version" : "0.55.7",
+ "benchmark" : "0.120577834 s",
+ "totalResults" : 0,
+ "serialQuery" : "tokens:s:Paum",
+ "itemsPerPage" : 25
+ },
+ "query" : {
+ "@type" : "koral:token",
+ "wrap" : {
+ "@type" : "koral:term",
+ "layer" : "orth",
+ "key" : "Baum",
+ "match" : "match:eq",
+ "foundry" : "opennlp",
+ "rewrites" : [
+ {
+ "@type" : "koral:rewrite",
+ "src" : "Kustvakt",
+ "operation" : "operation:injection",
+ "scope" : "foundry"
+ }
+ ]
+ }
+ },
+ "matches" : []
+ }
+}
diff --git a/t/plugin/auth-oauth.t b/t/plugin/auth-oauth.t
index b211eab..802f9d2 100644
--- a/t/plugin/auth-oauth.t
+++ b/t/plugin/auth-oauth.t
@@ -213,6 +213,15 @@
->element_exists('div.button.top a.logout[title~="test"]')
;
+$t->get_ok('/?q=Paum')
+ ->status_is(200)
+ ->text_like('h1 span', qr/KorAP: Find .Paum./i)
+ ->text_is('#total-results', '')
+ ->content_like(qr/\"authorized\"\:\"yes\"/)
+ ->element_exists_not('p.hint')
+ ;
+
+
# Logout
$t->get_ok('/user/logout')
->status_is(302)
@@ -237,6 +246,15 @@
->content_like(qr/\"authorized\"\:null/)
;
+$t->get_ok('/?q=Paum')
+ ->status_is(200)
+ ->text_like('h1 span', qr/KorAP: Find .Paum./i)
+ ->text_is('#total-results', '')
+ ->content_like(qr/\"authorized\"\:null/)
+ ->text_is('p.hint', 'Maybe you need to log in first?')
+ ;
+
+
# Get redirect
my $fwd = $t->get_ok('/?q=Baum&ql=poliqarp')
->status_is(200)