blob: 924cd73521a636e6c3c609d4d79ce1d01a7f4016 [file] [log] [blame]
Akron0e1ed242018-10-11 13:22:00 +02001use Mojo::Base -strict;
2use Test::Mojo;
3use Test::More;
Akron32396632018-10-11 17:08:37 +02004use Mojo::File qw/path/;
Akron95dfb252024-07-01 15:00:09 +02005use Mojo::JSON qw'decode_json';
Akron909ed082019-12-11 21:38:27 +01006use Kalamar::Controller::Search;
Akron32396632018-10-11 17:08:37 +02007
8
9#####################
10# Start Fake server #
11#####################
Akron63d963b2019-07-05 15:35:51 +020012my $mount_point = '/realapi/';
Akron32396632018-10-11 17:08:37 +020013$ENV{KALAMAR_API} = $mount_point;
Akron0e1ed242018-10-11 13:22:00 +020014
Akronc4177492023-11-29 08:35:37 +010015my $t = Test::Mojo->new('Kalamar' => {
16 Localize => {
17 dict => {
18 title_addon => 'Test'
19 }
20 }
21});
Akron0e1ed242018-10-11 13:22:00 +020022
Akron32396632018-10-11 17:08:37 +020023# Mount fake backend
24# Get the fixture path
Akron73f36082018-10-25 15:34:59 +020025my $fixtures_path = path(Mojo::File->new(__FILE__)->dirname, 'server');
Akron32396632018-10-11 17:08:37 +020026my $fake_backend = $t->app->plugin(
27 Mount => {
28 $mount_point =>
Akron73f36082018-10-25 15:34:59 +020029 $fixtures_path->child('mock.pl')
Akron32396632018-10-11 17:08:37 +020030 }
31);
32# Configure fake backend
33$fake_backend->pattern->defaults->{app}->log($t->app->log);
34
Akronbc6b3f22021-01-13 14:53:12 +010035my $q = qr!(?:\"|")!;
36
Akron0e1ed242018-10-11 13:22:00 +020037# Query passed
Akron58c60992021-09-07 13:11:43 +020038my $err = $t->get_ok('/?q=baum')
Akron0e1ed242018-10-11 13:22:00 +020039 ->status_is(200)
Akron69481a42021-03-22 10:31:16 +010040 ->content_type_is('text/html;charset=UTF-8')
Akron8ea84292018-10-24 13:41:52 +020041
Akronc4177492023-11-29 08:35:37 +010042 ->text_is('title', 'KorAP-Test: Find »baum« with Poliqarp')
43 ->element_exists('meta[name="DC.title"][content="KorAP-Test: Find »baum« with Poliqarp"]')
Akron0e1ed242018-10-11 13:22:00 +020044 ->element_exists('body[itemscope][itemtype="http://schema.org/SearchResultsPage"]')
Akrondffa9392018-10-12 16:26:09 +020045
46 # Total results
Akron32396632018-10-11 17:08:37 +020047 ->text_is('#total-results', 51)
Akrondffa9392018-10-12 16:26:09 +020048
49 # Total pages
Akron18a2a272020-06-16 11:47:38 +020050 ->element_count_is('#pagination > a', 5)
Akrondffa9392018-10-12 16:26:09 +020051
Akron9bd140e2021-07-27 16:20:03 +020052 ->element_exists_not('#resultinfo > #pagination')
53
Akrondffa9392018-10-12 16:26:09 +020054 # api_response
Akronbc6b3f22021-01-13 14:53:12 +010055 ->content_like(qr/${q}authorized${q}:null/)
56 ->content_like(qr/${q}pubDate${q},${q}subTitle${q},${q}author${q}/)
Akrondffa9392018-10-12 16:26:09 +020057
Akron8ea84292018-10-24 13:41:52 +020058 # No cutOff
Akronbc6b3f22021-01-13 14:53:12 +010059 ->content_unlike(qr!${q}cutOff${q}:true!)
Akron8ea84292018-10-24 13:41:52 +020060
Akrondffa9392018-10-12 16:26:09 +020061 ->element_exists('li[data-text-sigle=GOE/AGI/00000]')
62 ->element_exists('li:nth-of-type(1) div.flop')
63 ->element_exists('li[data-text-sigle=GOE/AGI/00001]')
64 ->element_exists('li:nth-of-type(2) div.flip')
65
66 # Match1
67 ->element_exists('li:nth-of-type(1)' .
68 '[data-match-id="p2030-2031"]' .
69 '[data-text-sigle="GOE/AGI/00000"]' .
70 '[id="GOE/AGI/00000#p2030-2031"]' .
71 '[data-available-info^="base/s=spans"]' .
72 '[data-info^="{"]')
73 ->text_is('li:nth-of-type(1) div.meta', 'GOE/AGI/00000')
74 ->element_exists('li:nth-of-type(1) div.match-main div.match-wrap div.snippet')
75 ->element_exists('li:nth-of-type(1) div.snippet.startMore.endMore')
76 ->text_like('li:nth-of-type(1) div.snippet span.context-left',qr!sie etwas bedeuten!)
77 ->text_like('li:nth-of-type(1) div.snippet span.context-left',qr!sie etwas bedeuten!)
78 ->text_is('li:nth-of-type(1) div.snippet span.match mark','Baum')
79 ->text_like('li:nth-of-type(1) div.snippet span.context-right',qr!es war!)
80 ->text_is('li:nth-of-type(1) p.ref strong', 'Italienische Reise')
81 ->text_like('li:nth-of-type(1) p.ref', qr!by Goethe, Johann Wolfgang!)
Akrondffa9392018-10-12 16:26:09 +020082 ->text_is('li:nth-of-type(1) p.ref span.sigle', '[GOE/AGI/00000]')
Akron22b008a2024-06-26 17:06:05 +020083 ->text_is('li:nth-of-type(1) p.ref time[datetime=1982]', 1982)
84 ->text_like('li:nth-of-type(1) p.ref ', qr!von \(, \)!)
85 ->text_is('li:nth-of-type(1) p.ref span.pages', 'p. 109')
86
87 ->element_exists_not('li:nth-of-type(2) p.ref time')
88 ->text_like('li:nth-of-type(2) p.ref ', qr!von \(\)!)
89 ->text_is('li:nth-of-type(2) p.ref span.pages', 'pp. 109–204')
90
Akron8ea84292018-10-24 13:41:52 +020091 ->header_isnt('X-Kalamar-Cache', 'true')
Akron26d57f22021-09-10 16:48:57 +020092 ->attr_is('#pagination','data-page','1')
93 ->attr_is('#pagination','data-total','3')
94 ->attr_is('#pagination','data-count','25')
Akron58c60992021-09-07 13:11:43 +020095 ->tx->res->dom->at('#error')
Akron0e1ed242018-10-11 13:22:00 +020096 ;
Akron3422d452024-05-14 11:14:07 +020097
Akron58c60992021-09-07 13:11:43 +020098is(defined $err ? $err->text : '', '');
99
Akron3422d452024-05-14 11:14:07 +0200100# Query passed
101$t->app->defaults(items_per_page => 20);
102
103$t->get_ok('/?q=baum')
104 ->status_is(200)
105 ->content_type_is('text/html;charset=UTF-8')
106 ->element_count_is('#pagination > a', 5)
107 ->attr_is('#pagination','data-page','1')
108 ->attr_is('#pagination','data-total','3')
109 ->attr_is('#pagination','data-count','20')
110;
111
112$t->app->defaults(items_per_page => 25);
Akron0e1ed242018-10-11 13:22:00 +0200113
Akron8ea84292018-10-24 13:41:52 +0200114$t->get_ok('/?q=[orth=das')
Akron7093b812018-10-19 17:28:21 +0200115 ->status_is(400)
116 ->text_is('div.notify-error:nth-of-type(1)', '302: Parantheses/brackets unbalanced.')
Akronbc33beb2018-11-30 13:46:08 +0100117 ->element_exists('#search')
Akron7093b812018-10-19 17:28:21 +0200118 ->text_like('div.notify-error:nth-of-type(2)', qr!302: Could not parse query .+? \[orth=das.+?!)
119 ;
120
Akron73f36082018-10-25 15:34:59 +0200121# Check for query error with ql (from remote.t)
122$t->get_ok('/?q=[orth=das&ql=poliqarp')
123 ->element_exists('.notify-error')
124 ->text_is('.notify-error', '302: Parantheses/brackets unbalanced.')
Akronbc6b3f22021-01-13 14:53:12 +0100125 ->content_like(qr!data-koralquery=!)
Akron3c390c42020-03-30 09:06:21 +0200126 ->text_is('.no-results:nth-of-type(1)', 'Unable to perform the action.')
Akron73f36082018-10-25 15:34:59 +0200127 ;
128
129
Akron8ea84292018-10-24 13:41:52 +0200130# Query with partial cache (for total results)
Akron58c60992021-09-07 13:11:43 +0200131$err = $t->get_ok('/?q=baum')
Akron8ea84292018-10-24 13:41:52 +0200132 ->status_is(200)
Akronc4177492023-11-29 08:35:37 +0100133 ->text_is('title', 'KorAP-Test: Find »baum« with Poliqarp')
134 ->element_exists('meta[name="DC.title"][content="KorAP-Test: Find »baum« with Poliqarp"]')
Akron8ea84292018-10-24 13:41:52 +0200135 ->element_exists('body[itemscope][itemtype="http://schema.org/SearchResultsPage"]')
136 ->header_isnt('X-Kalamar-Cache', 'true')
Akronbc6b3f22021-01-13 14:53:12 +0100137 ->content_like(qr!${q}cutOff${q}:true!)
Akron8ea84292018-10-24 13:41:52 +0200138 ->text_is('#total-results', 51)
Akron58c60992021-09-07 13:11:43 +0200139 ->tx->res->dom->at('#error')
Akron8ea84292018-10-24 13:41:52 +0200140 ;
Akron58c60992021-09-07 13:11:43 +0200141is(defined $err ? $err->text : '', '');
Akron8ea84292018-10-24 13:41:52 +0200142
Akron385249d2018-10-29 12:26:29 +0100143# Query without partial cache (unfortunately) (but no total results)
Akron58c60992021-09-07 13:11:43 +0200144$err = $t->get_ok('/?q=baum&cutoff=true')
Akron385249d2018-10-29 12:26:29 +0100145 ->status_is(200)
Akronc4177492023-11-29 08:35:37 +0100146 ->text_is('title', 'KorAP-Test: Find »baum« with Poliqarp')
147 ->element_exists('meta[name="DC.title"][content="KorAP-Test: Find »baum« with Poliqarp"]')
Akron385249d2018-10-29 12:26:29 +0100148 ->element_exists('body[itemscope][itemtype="http://schema.org/SearchResultsPage"]')
149 ->header_isnt('X-Kalamar-Cache', 'true')
Akronbc6b3f22021-01-13 14:53:12 +0100150 ->content_like(qr!${q}cutOff${q}:true!)
Akron385249d2018-10-29 12:26:29 +0100151 ->element_exists_not('#total-results')
Akron58c60992021-09-07 13:11:43 +0200152 ->tx->res->dom->at('#error')
Akron385249d2018-10-29 12:26:29 +0100153 ;
Akron58c60992021-09-07 13:11:43 +0200154is(defined $err ? $err->text : '', '');
Akron385249d2018-10-29 12:26:29 +0100155
156# Query with partial cache (but no total results)
Akron58c60992021-09-07 13:11:43 +0200157$err = $t->get_ok('/?q=baum&cutoff=true')
Akron385249d2018-10-29 12:26:29 +0100158 ->status_is(200)
Akronc4177492023-11-29 08:35:37 +0100159 ->text_is('title', 'KorAP-Test: Find »baum« with Poliqarp')
160 ->element_exists('meta[name="DC.title"][content="KorAP-Test: Find »baum« with Poliqarp"]')
Akron385249d2018-10-29 12:26:29 +0100161 ->element_exists('body[itemscope][itemtype="http://schema.org/SearchResultsPage"]')
162 ->header_is('X-Kalamar-Cache', 'true')
Akronbc6b3f22021-01-13 14:53:12 +0100163 ->content_like(qr!${q}cutOff${q}:true!)
Akron385249d2018-10-29 12:26:29 +0100164 ->element_exists_not('#total-results')
Akron58c60992021-09-07 13:11:43 +0200165 ->tx->res->dom->at('#error')
Akron385249d2018-10-29 12:26:29 +0100166 ;
Akron58c60992021-09-07 13:11:43 +0200167is(defined $err ? $err->text : '', '');
168
Akron385249d2018-10-29 12:26:29 +0100169
Akron8ea84292018-10-24 13:41:52 +0200170# Query with full cache
Akron58c60992021-09-07 13:11:43 +0200171$err = $t->get_ok('/?q=baum')
Akron8ea84292018-10-24 13:41:52 +0200172 ->status_is(200)
Akronc4177492023-11-29 08:35:37 +0100173 ->text_is('title', 'KorAP-Test: Find »baum« with Poliqarp')
174 ->element_exists('meta[name="DC.title"][content="KorAP-Test: Find »baum« with Poliqarp"]')
Akron8ea84292018-10-24 13:41:52 +0200175 ->element_exists('body[itemscope][itemtype="http://schema.org/SearchResultsPage"]')
176 ->header_is('X-Kalamar-Cache', 'true')
Akronbc6b3f22021-01-13 14:53:12 +0100177 ->content_like(qr!${q}cutOff${q}:true!)
Akron8ea84292018-10-24 13:41:52 +0200178 ->text_is('#total-results', 51)
Akron58c60992021-09-07 13:11:43 +0200179 ->tx->res->dom->at('#error')
Akron8ea84292018-10-24 13:41:52 +0200180 ;
Akron58c60992021-09-07 13:11:43 +0200181is(defined $err ? $err->text : '', '');
Akron8ea84292018-10-24 13:41:52 +0200182
183
184# Query with page information
Akronc23ce662021-12-14 12:39:42 +0100185$err = $t->get_ok('/?q=der&p=1&count=2' => { 'Accept-Language' => 'en-US, en, de-DE' })
Akron8ea84292018-10-24 13:41:52 +0200186 ->status_is(200)
Akronc4177492023-11-29 08:35:37 +0100187 ->text_is('title', 'KorAP-Test: Find »der« with Poliqarp')
Akron8ea84292018-10-24 13:41:52 +0200188
189 # Total results
190 ->text_is('#total-results', '14,581')
191
192 # Total pages
Akron18a2a272020-06-16 11:47:38 +0200193 ->element_count_is('#pagination > a', 7)
Akronc23ce662021-12-14 12:39:42 +0100194 ->text_is('#pagination a:nth-of-type(6) span', '7,291')
Akrona4b17f72021-11-04 15:37:02 +0100195 ->element_exists('#pagination a.ellipsis.inactive')
Akronbc6b3f22021-01-13 14:53:12 +0100196 ->content_like(qr!${q}count${q}:2!)
197 ->content_like(qr!${q}startIndex${q}:0!)
198 ->content_like(qr!${q}itemsPerPage${q}:2!)
Akron8ea84292018-10-24 13:41:52 +0200199
200 # No caching
201 ->header_isnt('X-Kalamar-Cache', 'true')
202
203 # Not searched for "der" before
Akronbc6b3f22021-01-13 14:53:12 +0100204 ->content_unlike(qr!${q}cutOff${q}:true!)
Akron26d57f22021-09-10 16:48:57 +0200205
206 ->attr_is('#pagination','data-page','1')
207 ->attr_is('#pagination','data-total','7291')
208 ->attr_is('#pagination','data-count','2')
209
Akron58c60992021-09-07 13:11:43 +0200210 ->tx->res->dom->at('#error')
Akron8ea84292018-10-24 13:41:52 +0200211 ;
Akron58c60992021-09-07 13:11:43 +0200212is(defined $err ? $err->text : '', '');
213
Akron8ea84292018-10-24 13:41:52 +0200214
Akron4c7cf952019-08-29 09:31:35 +0200215# Check pagination repetion of page
216my $next_href = $t->get_ok('/?q=der&p=1&count=2')
217 ->tx->res->dom->at('#pagination a[rel=next]')->attr('href');
218like($next_href, qr/p=2/);
219unlike($next_href, qr/p=1/);
220
Akron8ea84292018-10-24 13:41:52 +0200221# Query with page information - next page
Akronc23ce662021-12-14 12:39:42 +0100222$err = $t->get_ok('/?q=der&p=2&count=2' => { 'Accept-Language' => 'de-DE, en-US, en' })
Akron8ea84292018-10-24 13:41:52 +0200223 ->status_is(200)
Akronc4177492023-11-29 08:35:37 +0100224 ->text_is('div.logoaddon', 'Test')
225 ->text_is('title', 'KorAP-Test: Finde »der« mit Poliqarp')
Akronbc33beb2018-11-30 13:46:08 +0100226 ->element_exists('#search')
Akron8ea84292018-10-24 13:41:52 +0200227
228 # Total results
Akronc23ce662021-12-14 12:39:42 +0100229 ->text_is('#total-results', '14.581')
Akron8ea84292018-10-24 13:41:52 +0200230
231 # Total pages
Akron18a2a272020-06-16 11:47:38 +0200232 ->element_count_is('#pagination > a', 7)
Akronc23ce662021-12-14 12:39:42 +0100233 ->text_is('#pagination a:nth-of-type(6) span', '7.291')
Akronbc6b3f22021-01-13 14:53:12 +0100234 ->content_like(qr!${q}count${q}:2!)
235 ->content_like(qr!${q}itemsPerPage${q}:2!)
236 ->content_like(qr!${q}startIndex${q}:2!)
Akron8ea84292018-10-24 13:41:52 +0200237
Akron26d57f22021-09-10 16:48:57 +0200238 ->attr_is('#pagination','data-page','2')
239 ->attr_is('#pagination','data-total','7291')
240 ->attr_is('#pagination','data-count','2')
241
Akron8ea84292018-10-24 13:41:52 +0200242 # No caching
243 ->header_isnt('X-Kalamar-Cache', 'true')
Akronbc6b3f22021-01-13 14:53:12 +0100244 ->content_like(qr!${q}cutOff${q}:true!)
Akron58c60992021-09-07 13:11:43 +0200245 ->tx->res->dom->at('#error')
Akron8ea84292018-10-24 13:41:52 +0200246 ;
Akron58c60992021-09-07 13:11:43 +0200247is(defined $err ? $err->text : '', '');
248
Akron8ea84292018-10-24 13:41:52 +0200249
Akronc4be8192018-10-25 16:07:53 +0200250# Query with failing parameters
251$t->get_ok('/?q=fantastisch&ql=Fabelsprache')
252 ->status_is(400)
Akroncb5c1712021-01-26 18:01:04 +0100253 ->text_is('#notifications div.notify-error', 'Parameter "ql" invalid')
Akronbc33beb2018-11-30 13:46:08 +0100254 ->element_exists('#search')
Akroncb5c1712021-01-26 18:01:04 +0100255 ->element_count_is('#notifications div.notify-error', 1)
Akronc4be8192018-10-25 16:07:53 +0200256 ;
257$t->get_ok('/?q=fantastisch&cutoff=no')
258 ->status_is(400)
Akroncb5c1712021-01-26 18:01:04 +0100259 ->text_is('#notifications div.notify-error', 'Parameter "cutoff" invalid')
260 ->element_count_is('#notifications div.notify-error', 1)
Akronc4be8192018-10-25 16:07:53 +0200261 ;
262$t->get_ok('/?q=fantastisch&p=hui&o=hui&count=-8')
263 ->status_is(400)
Akroncb5c1712021-01-26 18:01:04 +0100264 ->text_like('#notifications div.notify-error', qr!Parameter ".+?" invalid!)
265 ->element_count_is('#notifications div.notify-error', 3)
Akronc4be8192018-10-25 16:07:53 +0200266 ;
Akron8ea84292018-10-24 13:41:52 +0200267
Marc Kupietz4dc3d502022-07-06 16:50:14 +0200268# Long, but not too long query
269my $long_query = 'b' x 4096;
Akron58c60992021-09-07 13:11:43 +0200270$err = $t->get_ok('/?q=' . $long_query)
Akrond1ff8d82018-11-08 13:16:55 +0100271 ->status_is(400)
Marc Kupietz4dc3d502022-07-06 16:50:14 +0200272 ->text_like('#notifications div.notify-error', qr!Unable to load query response from!)
273 ->tx->res->dom->at('#error')
274 ;
275
276# Query too long
277my $too_long_query = 'b' x 4097;
278$err = $t->get_ok('/?q=' . $too_long_query)
279 ->status_is(400)
Akroncb5c1712021-01-26 18:01:04 +0100280 ->text_like('#notifications div.notify-error', qr!Parameter ".+?" invalid!)
Akron58c60992021-09-07 13:11:43 +0200281 ->tx->res->dom->at('#error')
Akrond1ff8d82018-11-08 13:16:55 +0100282 ;
Akron58c60992021-09-07 13:11:43 +0200283is(defined $err ? $err->text : '', '');
Akrond1ff8d82018-11-08 13:16:55 +0100284
Akrona3c353c2019-02-14 23:50:00 +0100285# Query with timeout
286$t->get_ok('/?q=timeout')
287 ->status_is(200)
Akroncb5c1712021-01-26 18:01:04 +0100288 ->text_like('#notifications div.notify-warn', qr!Response time exceeded!)
Akrona3c353c2019-02-14 23:50:00 +0100289 ->text_is('#total-results', '> 4,274,841');
290;
291
Akroncce055c2021-07-02 12:18:03 +0200292# Query with error
293$t->get_ok('/?q=error')
294 ->status_is(400)
295 ->text_is('#notifications .notify-error','500: Internal Server Error')
296;
297
Akrona3c353c2019-02-14 23:50:00 +0100298# Do not cache
299$t->get_ok('/?q=timeout')
300 ->status_is(200)
Akroncb5c1712021-01-26 18:01:04 +0100301 # ->text_like('#notifications div.notify-warning', qr!Response time exceeded!)
Akroncd42a142019-07-12 18:55:37 +0200302 ->element_exists("input#cq")
303 ->element_exists_not("input#cq[value]")
Akrona3c353c2019-02-14 23:50:00 +0100304 ->text_is('#total-results', '> 4,274,841');
305 ;
306
Akron91a76852019-08-28 12:35:37 +0200307$t->app->defaults(no_cache => 1);
308
Akroncd42a142019-07-12 18:55:37 +0200309# Query with collection
Akron58c60992021-09-07 13:11:43 +0200310$err = $t->get_ok('/?q=baum&collection=availability+%3D+%2FCC-BY.*%2F')
Akroncd42a142019-07-12 18:55:37 +0200311 ->status_is(200)
312 ->element_exists("input#cq[value='availability = /CC-BY.*/']")
Akronbc6b3f22021-01-13 14:53:12 +0100313 ->content_like(qr!${q}availability${q}!)
Akron58c60992021-09-07 13:11:43 +0200314 ->tx->res->dom->at('#error')
Akroncd42a142019-07-12 18:55:37 +0200315 ;
Akron58c60992021-09-07 13:11:43 +0200316is(defined $err ? $err->text : '', '');
317
Akroncd42a142019-07-12 18:55:37 +0200318
Akron4cdc4fc2020-04-28 12:19:11 +0200319$t->app->hook(
Akron7c87c1a2020-04-28 12:35:55 +0200320 after_search => sub {
Akron4cdc4fc2020-04-28 12:19:11 +0200321 my $c = shift;
322 $c->content_for('after_search_results' => '<p id="special">Funny</p>');
323 }
324);
325
Akroncd42a142019-07-12 18:55:37 +0200326# Query with corpus query
Akron58c60992021-09-07 13:11:43 +0200327$err = $t->get_ok('/?q=baum&cq=availability+%3D+%2FCC-BY.*%2F')
Akroncd42a142019-07-12 18:55:37 +0200328 ->status_is(200)
329 ->element_exists("input#cq[value='availability = /CC-BY.*/']")
Akronbc6b3f22021-01-13 14:53:12 +0100330 ->content_like(qr!${q}availability${q}!)
Akron4cdc4fc2020-04-28 12:19:11 +0200331 ->text_is('#special', 'Funny')
Akron58c60992021-09-07 13:11:43 +0200332 ->tx->res->dom->at('#error')
Akroncd42a142019-07-12 18:55:37 +0200333 ;
Akron58c60992021-09-07 13:11:43 +0200334is(defined $err ? $err->text : '', '');
Akron8ea84292018-10-24 13:41:52 +0200335
Akron909ed082019-12-11 21:38:27 +0100336my $match = {
337 matchID => 'match-FOLK/00070-SE-01/T-04-p5441-5442',
338 textSigle => 'FOLK/00070-SE-01/T-04'
339};
340
341$match = Kalamar::Controller::Search::_map_match($match);
342
343is($match->{matchID}, 'p5441-5442');
344
Akron7b9a1962020-07-02 09:52:53 +0200345# Query with pipe
Akron58c60992021-09-07 13:11:43 +0200346$err = $t->get_ok('/?q=baum&pipe=glemm')
Akron7b9a1962020-07-02 09:52:53 +0200347 ->status_is(200)
Akronbc6b3f22021-01-13 14:53:12 +0100348 ->content_like(qr/${q}pipes${q}:${q}glemm${q}/)
Akron58c60992021-09-07 13:11:43 +0200349 ->tx->res->dom->at('#error')
Akron7b9a1962020-07-02 09:52:53 +0200350 ;
Akron58c60992021-09-07 13:11:43 +0200351is(defined $err ? $err->text : '', '');
Akron7b9a1962020-07-02 09:52:53 +0200352
Akron909ed082019-12-11 21:38:27 +0100353
Akron95dfb252024-07-01 15:00:09 +0200354my $base_fixtures = path(Mojo::File->new(__FILE__)->dirname, 'fixtures');
355my $text_info = $base_fixtures->child('response_textinfo_goe_agi_00000.json')->slurp;
356my $fields = decode_json($text_info)->{json}->{document}->{fields};
357
358my $f = Kalamar::Controller::Search::_flatten_fields($fields);
359
360is($f->{textSigle}, 'GOE/AGI/00000');
361is($f->{author}, 'Goethe, Johann Wolfgang von');
362is($f->{docSigle}, 'GOE/AGI');
363is($f->{docTitle}, 'Goethe: Autobiographische Schriften III, (1813-1816, 1819-1829)');
364is($f->{textType}, 'Autobiographie');
365is($f->{language}, 'de');
366is($f->{availability}, 'ACA-NC');
367is($f->{title}, 'Italienische Reise');
368is($f->{creationDate}, '1813');
369is($f->{pubDate}, '1982');
370is($f->{reference}, 'Goethe, Johann Wolfgang von: Italienische Reise. Auch ich in Arkadien!, (Geschrieben: 1813-1816), In: Goethe, Johann Wolfgang von: Goethes Werke, Bd. 11, Autobiographische Schriften III, Hrsg.: Trunz, Erich. München: Verlag C. H. Beck, 1982, S. 9-349');
371is($f->{subTitle}, 'Auch ich in Arkadien!');
372is($f->{tokenSource}, 'base#tokens');
373is($f->{foundries}, 'corenlp corenlp/constituency corenlp/morpho corenlp/sentences dereko dereko/structure dereko/structure/base-sentences-paragraphs-pagebreaks malt malt/dependency marmot marmot/morpho opennlp opennlp/morpho opennlp/sentences treetagger treetagger/morpho');
374is($f->{publisher}, 'Verlag C. H. Beck');
375is($f->{corpusAuthor}, 'Goethe, Johann Wolfgang von');
376is($f->{layerInfos}, 'corenlp/c=spans corenlp/p=tokens corenlp/s=spans dereko/s=spans malt/d=rels marmot/m=tokens marmot/p=tokens opennlp/p=tokens opennlp/s=spans tt/l=tokens tt/p=tokens');
377is($f->{pubPlace}, 'München');
378is($f->{corpusTitle}, 'Goethes Werke');
379is($f->{corpusSigle}, 'GOE');
380is($f->{corpusEditor}, 'Trunz, Erich');
381
382
Akron0e1ed242018-10-11 13:22:00 +0200383done_testing;
Akron8ea84292018-10-24 13:41:52 +0200384__END__