Akron | 0e1ed24 | 2018-10-11 13:22:00 +0200 | [diff] [blame] | 1 | use Mojo::Base -strict; |
| 2 | use Test::Mojo; |
| 3 | use Test::More; |
Akron | 3239663 | 2018-10-11 17:08:37 +0200 | [diff] [blame] | 4 | use Mojo::File qw/path/; |
Akron | 909ed08 | 2019-12-11 21:38:27 +0100 | [diff] [blame] | 5 | use Kalamar::Controller::Search; |
Akron | 3239663 | 2018-10-11 17:08:37 +0200 | [diff] [blame] | 6 | |
| 7 | |
| 8 | ##################### |
| 9 | # Start Fake server # |
| 10 | ##################### |
Akron | 63d963b | 2019-07-05 15:35:51 +0200 | [diff] [blame] | 11 | my $mount_point = '/realapi/'; |
Akron | 3239663 | 2018-10-11 17:08:37 +0200 | [diff] [blame] | 12 | $ENV{KALAMAR_API} = $mount_point; |
Akron | 0e1ed24 | 2018-10-11 13:22:00 +0200 | [diff] [blame] | 13 | |
| 14 | my $t = Test::Mojo->new('Kalamar'); |
| 15 | |
Akron | 3239663 | 2018-10-11 17:08:37 +0200 | [diff] [blame] | 16 | # Mount fake backend |
| 17 | # Get the fixture path |
Akron | 73f3608 | 2018-10-25 15:34:59 +0200 | [diff] [blame] | 18 | my $fixtures_path = path(Mojo::File->new(__FILE__)->dirname, 'server'); |
Akron | 3239663 | 2018-10-11 17:08:37 +0200 | [diff] [blame] | 19 | my $fake_backend = $t->app->plugin( |
| 20 | Mount => { |
| 21 | $mount_point => |
Akron | 73f3608 | 2018-10-25 15:34:59 +0200 | [diff] [blame] | 22 | $fixtures_path->child('mock.pl') |
Akron | 3239663 | 2018-10-11 17:08:37 +0200 | [diff] [blame] | 23 | } |
| 24 | ); |
| 25 | # Configure fake backend |
| 26 | $fake_backend->pattern->defaults->{app}->log($t->app->log); |
| 27 | |
Akron | bc6b3f2 | 2021-01-13 14:53:12 +0100 | [diff] [blame] | 28 | my $q = qr!(?:\"|")!; |
| 29 | |
Akron | 0e1ed24 | 2018-10-11 13:22:00 +0200 | [diff] [blame] | 30 | # Query passed |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 31 | my $err = $t->get_ok('/?q=baum') |
Akron | 0e1ed24 | 2018-10-11 13:22:00 +0200 | [diff] [blame] | 32 | ->status_is(200) |
Akron | 69481a4 | 2021-03-22 10:31:16 +0100 | [diff] [blame] | 33 | ->content_type_is('text/html;charset=UTF-8') |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 34 | |
Akron | 3239663 | 2018-10-11 17:08:37 +0200 | [diff] [blame] | 35 | ->text_is('title', 'KorAP: Find »baum« with Poliqarp') |
| 36 | ->element_exists('meta[name="DC.title"][content="KorAP: Find »baum« with Poliqarp"]') |
Akron | 0e1ed24 | 2018-10-11 13:22:00 +0200 | [diff] [blame] | 37 | ->element_exists('body[itemscope][itemtype="http://schema.org/SearchResultsPage"]') |
Akron | dffa939 | 2018-10-12 16:26:09 +0200 | [diff] [blame] | 38 | |
| 39 | # Total results |
Akron | 3239663 | 2018-10-11 17:08:37 +0200 | [diff] [blame] | 40 | ->text_is('#total-results', 51) |
Akron | dffa939 | 2018-10-12 16:26:09 +0200 | [diff] [blame] | 41 | |
| 42 | # Total pages |
Akron | 18a2a27 | 2020-06-16 11:47:38 +0200 | [diff] [blame] | 43 | ->element_count_is('#pagination > a', 5) |
Akron | dffa939 | 2018-10-12 16:26:09 +0200 | [diff] [blame] | 44 | |
Akron | 9bd140e | 2021-07-27 16:20:03 +0200 | [diff] [blame] | 45 | ->element_exists_not('#resultinfo > #pagination') |
| 46 | |
Akron | dffa939 | 2018-10-12 16:26:09 +0200 | [diff] [blame] | 47 | # api_response |
Akron | bc6b3f2 | 2021-01-13 14:53:12 +0100 | [diff] [blame] | 48 | ->content_like(qr/${q}authorized${q}:null/) |
| 49 | ->content_like(qr/${q}pubDate${q},${q}subTitle${q},${q}author${q}/) |
Akron | dffa939 | 2018-10-12 16:26:09 +0200 | [diff] [blame] | 50 | |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 51 | # No cutOff |
Akron | bc6b3f2 | 2021-01-13 14:53:12 +0100 | [diff] [blame] | 52 | ->content_unlike(qr!${q}cutOff${q}:true!) |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 53 | |
Akron | dffa939 | 2018-10-12 16:26:09 +0200 | [diff] [blame] | 54 | ->element_exists('li[data-text-sigle=GOE/AGI/00000]') |
| 55 | ->element_exists('li:nth-of-type(1) div.flop') |
| 56 | ->element_exists('li[data-text-sigle=GOE/AGI/00001]') |
| 57 | ->element_exists('li:nth-of-type(2) div.flip') |
| 58 | |
| 59 | # Match1 |
| 60 | ->element_exists('li:nth-of-type(1)' . |
| 61 | '[data-match-id="p2030-2031"]' . |
| 62 | '[data-text-sigle="GOE/AGI/00000"]' . |
| 63 | '[id="GOE/AGI/00000#p2030-2031"]' . |
| 64 | '[data-available-info^="base/s=spans"]' . |
| 65 | '[data-info^="{"]') |
| 66 | ->text_is('li:nth-of-type(1) div.meta', 'GOE/AGI/00000') |
| 67 | ->element_exists('li:nth-of-type(1) div.match-main div.match-wrap div.snippet') |
| 68 | ->element_exists('li:nth-of-type(1) div.snippet.startMore.endMore') |
| 69 | ->text_like('li:nth-of-type(1) div.snippet span.context-left',qr!sie etwas bedeuten!) |
| 70 | ->text_like('li:nth-of-type(1) div.snippet span.context-left',qr!sie etwas bedeuten!) |
| 71 | ->text_is('li:nth-of-type(1) div.snippet span.match mark','Baum') |
| 72 | ->text_like('li:nth-of-type(1) div.snippet span.context-right',qr!es war!) |
| 73 | ->text_is('li:nth-of-type(1) p.ref strong', 'Italienische Reise') |
| 74 | ->text_like('li:nth-of-type(1) p.ref', qr!by Goethe, Johann Wolfgang!) |
| 75 | ->text_is('li:nth-of-type(1) p.ref time[datetime=1982]', 1982) |
| 76 | ->text_is('li:nth-of-type(1) p.ref span.sigle', '[GOE/AGI/00000]') |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 77 | ->header_isnt('X-Kalamar-Cache', 'true') |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 78 | ->tx->res->dom->at('#error') |
Akron | 0e1ed24 | 2018-10-11 13:22:00 +0200 | [diff] [blame] | 79 | ; |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 80 | is(defined $err ? $err->text : '', ''); |
| 81 | |
Akron | 0e1ed24 | 2018-10-11 13:22:00 +0200 | [diff] [blame] | 82 | |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 83 | $t->get_ok('/?q=[orth=das') |
Akron | 7093b81 | 2018-10-19 17:28:21 +0200 | [diff] [blame] | 84 | ->status_is(400) |
| 85 | ->text_is('div.notify-error:nth-of-type(1)', '302: Parantheses/brackets unbalanced.') |
Akron | bc33beb | 2018-11-30 13:46:08 +0100 | [diff] [blame] | 86 | ->element_exists('#search') |
Akron | 7093b81 | 2018-10-19 17:28:21 +0200 | [diff] [blame] | 87 | ->text_like('div.notify-error:nth-of-type(2)', qr!302: Could not parse query .+? \[orth=das.+?!) |
| 88 | ; |
| 89 | |
Akron | 73f3608 | 2018-10-25 15:34:59 +0200 | [diff] [blame] | 90 | # Check for query error with ql (from remote.t) |
| 91 | $t->get_ok('/?q=[orth=das&ql=poliqarp') |
| 92 | ->element_exists('.notify-error') |
| 93 | ->text_is('.notify-error', '302: Parantheses/brackets unbalanced.') |
Akron | bc6b3f2 | 2021-01-13 14:53:12 +0100 | [diff] [blame] | 94 | ->content_like(qr!data-koralquery=!) |
Akron | 3c390c4 | 2020-03-30 09:06:21 +0200 | [diff] [blame] | 95 | ->text_is('.no-results:nth-of-type(1)', 'Unable to perform the action.') |
Akron | 73f3608 | 2018-10-25 15:34:59 +0200 | [diff] [blame] | 96 | ; |
| 97 | |
| 98 | |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 99 | # Query with partial cache (for total results) |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 100 | $err = $t->get_ok('/?q=baum') |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 101 | ->status_is(200) |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 102 | ->text_is('title', 'KorAP: Find »baum« with Poliqarp') |
| 103 | ->element_exists('meta[name="DC.title"][content="KorAP: Find »baum« with Poliqarp"]') |
| 104 | ->element_exists('body[itemscope][itemtype="http://schema.org/SearchResultsPage"]') |
| 105 | ->header_isnt('X-Kalamar-Cache', 'true') |
Akron | bc6b3f2 | 2021-01-13 14:53:12 +0100 | [diff] [blame] | 106 | ->content_like(qr!${q}cutOff${q}:true!) |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 107 | ->text_is('#total-results', 51) |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 108 | ->tx->res->dom->at('#error') |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 109 | ; |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 110 | is(defined $err ? $err->text : '', ''); |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 111 | |
Akron | 385249d | 2018-10-29 12:26:29 +0100 | [diff] [blame] | 112 | # Query without partial cache (unfortunately) (but no total results) |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 113 | $err = $t->get_ok('/?q=baum&cutoff=true') |
Akron | 385249d | 2018-10-29 12:26:29 +0100 | [diff] [blame] | 114 | ->status_is(200) |
Akron | 385249d | 2018-10-29 12:26:29 +0100 | [diff] [blame] | 115 | ->text_is('title', 'KorAP: Find »baum« with Poliqarp') |
| 116 | ->element_exists('meta[name="DC.title"][content="KorAP: Find »baum« with Poliqarp"]') |
| 117 | ->element_exists('body[itemscope][itemtype="http://schema.org/SearchResultsPage"]') |
| 118 | ->header_isnt('X-Kalamar-Cache', 'true') |
Akron | bc6b3f2 | 2021-01-13 14:53:12 +0100 | [diff] [blame] | 119 | ->content_like(qr!${q}cutOff${q}:true!) |
Akron | 385249d | 2018-10-29 12:26:29 +0100 | [diff] [blame] | 120 | ->element_exists_not('#total-results') |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 121 | ->tx->res->dom->at('#error') |
Akron | 385249d | 2018-10-29 12:26:29 +0100 | [diff] [blame] | 122 | ; |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 123 | is(defined $err ? $err->text : '', ''); |
Akron | 385249d | 2018-10-29 12:26:29 +0100 | [diff] [blame] | 124 | |
| 125 | # Query with partial cache (but no total results) |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 126 | $err = $t->get_ok('/?q=baum&cutoff=true') |
Akron | 385249d | 2018-10-29 12:26:29 +0100 | [diff] [blame] | 127 | ->status_is(200) |
Akron | 385249d | 2018-10-29 12:26:29 +0100 | [diff] [blame] | 128 | ->text_is('title', 'KorAP: Find »baum« with Poliqarp') |
| 129 | ->element_exists('meta[name="DC.title"][content="KorAP: Find »baum« with Poliqarp"]') |
| 130 | ->element_exists('body[itemscope][itemtype="http://schema.org/SearchResultsPage"]') |
| 131 | ->header_is('X-Kalamar-Cache', 'true') |
Akron | bc6b3f2 | 2021-01-13 14:53:12 +0100 | [diff] [blame] | 132 | ->content_like(qr!${q}cutOff${q}:true!) |
Akron | 385249d | 2018-10-29 12:26:29 +0100 | [diff] [blame] | 133 | ->element_exists_not('#total-results') |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 134 | ->tx->res->dom->at('#error') |
Akron | 385249d | 2018-10-29 12:26:29 +0100 | [diff] [blame] | 135 | ; |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 136 | is(defined $err ? $err->text : '', ''); |
| 137 | |
Akron | 385249d | 2018-10-29 12:26:29 +0100 | [diff] [blame] | 138 | |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 139 | # Query with full cache |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 140 | $err = $t->get_ok('/?q=baum') |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 141 | ->status_is(200) |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 142 | ->text_is('title', 'KorAP: Find »baum« with Poliqarp') |
| 143 | ->element_exists('meta[name="DC.title"][content="KorAP: Find »baum« with Poliqarp"]') |
| 144 | ->element_exists('body[itemscope][itemtype="http://schema.org/SearchResultsPage"]') |
| 145 | ->header_is('X-Kalamar-Cache', 'true') |
Akron | bc6b3f2 | 2021-01-13 14:53:12 +0100 | [diff] [blame] | 146 | ->content_like(qr!${q}cutOff${q}:true!) |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 147 | ->text_is('#total-results', 51) |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 148 | ->tx->res->dom->at('#error') |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 149 | ; |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 150 | is(defined $err ? $err->text : '', ''); |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 151 | |
| 152 | |
| 153 | # Query with page information |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 154 | $err = $t->get_ok('/?q=der&p=1&count=2') |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 155 | ->status_is(200) |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 156 | ->text_is('title', 'KorAP: Find »der« with Poliqarp') |
| 157 | |
| 158 | # Total results |
| 159 | ->text_is('#total-results', '14,581') |
| 160 | |
| 161 | # Total pages |
Akron | 18a2a27 | 2020-06-16 11:47:38 +0200 | [diff] [blame] | 162 | ->element_count_is('#pagination > a', 7) |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 163 | ->text_is('#pagination a:nth-of-type(6) span', 7291) |
Akron | bc6b3f2 | 2021-01-13 14:53:12 +0100 | [diff] [blame] | 164 | ->content_like(qr!${q}count${q}:2!) |
| 165 | ->content_like(qr!${q}startIndex${q}:0!) |
| 166 | ->content_like(qr!${q}itemsPerPage${q}:2!) |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 167 | |
| 168 | # No caching |
| 169 | ->header_isnt('X-Kalamar-Cache', 'true') |
| 170 | |
| 171 | # Not searched for "der" before |
Akron | bc6b3f2 | 2021-01-13 14:53:12 +0100 | [diff] [blame] | 172 | ->content_unlike(qr!${q}cutOff${q}:true!) |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 173 | ->tx->res->dom->at('#error') |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 174 | ; |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 175 | is(defined $err ? $err->text : '', ''); |
| 176 | |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 177 | |
Akron | 4c7cf95 | 2019-08-29 09:31:35 +0200 | [diff] [blame] | 178 | # Check pagination repetion of page |
| 179 | my $next_href = $t->get_ok('/?q=der&p=1&count=2') |
| 180 | ->tx->res->dom->at('#pagination a[rel=next]')->attr('href'); |
| 181 | like($next_href, qr/p=2/); |
| 182 | unlike($next_href, qr/p=1/); |
| 183 | |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 184 | # Query with page information - next page |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 185 | $err = $t->get_ok('/?q=der&p=2&count=2') |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 186 | ->status_is(200) |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 187 | ->text_is('title', 'KorAP: Find »der« with Poliqarp') |
Akron | bc33beb | 2018-11-30 13:46:08 +0100 | [diff] [blame] | 188 | ->element_exists('#search') |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 189 | |
| 190 | # Total results |
| 191 | ->text_is('#total-results', '14,581') |
| 192 | |
| 193 | # Total pages |
Akron | 18a2a27 | 2020-06-16 11:47:38 +0200 | [diff] [blame] | 194 | ->element_count_is('#pagination > a', 7) |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 195 | ->text_is('#pagination a:nth-of-type(6) span', 7291) |
Akron | bc6b3f2 | 2021-01-13 14:53:12 +0100 | [diff] [blame] | 196 | ->content_like(qr!${q}count${q}:2!) |
| 197 | ->content_like(qr!${q}itemsPerPage${q}:2!) |
| 198 | ->content_like(qr!${q}startIndex${q}:2!) |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 199 | |
| 200 | # No caching |
| 201 | ->header_isnt('X-Kalamar-Cache', 'true') |
Akron | bc6b3f2 | 2021-01-13 14:53:12 +0100 | [diff] [blame] | 202 | ->content_like(qr!${q}cutOff${q}:true!) |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 203 | ->tx->res->dom->at('#error') |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 204 | ; |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 205 | is(defined $err ? $err->text : '', ''); |
| 206 | |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 207 | |
Akron | c4be819 | 2018-10-25 16:07:53 +0200 | [diff] [blame] | 208 | # Query with failing parameters |
| 209 | $t->get_ok('/?q=fantastisch&ql=Fabelsprache') |
| 210 | ->status_is(400) |
Akron | cb5c171 | 2021-01-26 18:01:04 +0100 | [diff] [blame] | 211 | ->text_is('#notifications div.notify-error', 'Parameter "ql" invalid') |
Akron | bc33beb | 2018-11-30 13:46:08 +0100 | [diff] [blame] | 212 | ->element_exists('#search') |
Akron | cb5c171 | 2021-01-26 18:01:04 +0100 | [diff] [blame] | 213 | ->element_count_is('#notifications div.notify-error', 1) |
Akron | c4be819 | 2018-10-25 16:07:53 +0200 | [diff] [blame] | 214 | ; |
| 215 | $t->get_ok('/?q=fantastisch&cutoff=no') |
| 216 | ->status_is(400) |
Akron | cb5c171 | 2021-01-26 18:01:04 +0100 | [diff] [blame] | 217 | ->text_is('#notifications div.notify-error', 'Parameter "cutoff" invalid') |
| 218 | ->element_count_is('#notifications div.notify-error', 1) |
Akron | c4be819 | 2018-10-25 16:07:53 +0200 | [diff] [blame] | 219 | ; |
| 220 | $t->get_ok('/?q=fantastisch&p=hui&o=hui&count=-8') |
| 221 | ->status_is(400) |
Akron | cb5c171 | 2021-01-26 18:01:04 +0100 | [diff] [blame] | 222 | ->text_like('#notifications div.notify-error', qr!Parameter ".+?" invalid!) |
| 223 | ->element_count_is('#notifications div.notify-error', 3) |
Akron | c4be819 | 2018-10-25 16:07:53 +0200 | [diff] [blame] | 224 | ; |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 225 | |
Akron | d1ff8d8 | 2018-11-08 13:16:55 +0100 | [diff] [blame] | 226 | # Query too long |
| 227 | my $long_query = 'b' x 2000; |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 228 | $err = $t->get_ok('/?q=' . $long_query) |
Akron | d1ff8d8 | 2018-11-08 13:16:55 +0100 | [diff] [blame] | 229 | ->status_is(400) |
Akron | cb5c171 | 2021-01-26 18:01:04 +0100 | [diff] [blame] | 230 | ->text_like('#notifications div.notify-error', qr!Parameter ".+?" invalid!) |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 231 | ->tx->res->dom->at('#error') |
Akron | d1ff8d8 | 2018-11-08 13:16:55 +0100 | [diff] [blame] | 232 | ; |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 233 | is(defined $err ? $err->text : '', ''); |
Akron | d1ff8d8 | 2018-11-08 13:16:55 +0100 | [diff] [blame] | 234 | |
Akron | a3c353c | 2019-02-14 23:50:00 +0100 | [diff] [blame] | 235 | # Query with timeout |
| 236 | $t->get_ok('/?q=timeout') |
| 237 | ->status_is(200) |
Akron | cb5c171 | 2021-01-26 18:01:04 +0100 | [diff] [blame] | 238 | ->text_like('#notifications div.notify-warn', qr!Response time exceeded!) |
Akron | a3c353c | 2019-02-14 23:50:00 +0100 | [diff] [blame] | 239 | ->text_is('#total-results', '> 4,274,841'); |
| 240 | ; |
| 241 | |
Akron | cce055c | 2021-07-02 12:18:03 +0200 | [diff] [blame] | 242 | # Query with error |
| 243 | $t->get_ok('/?q=error') |
| 244 | ->status_is(400) |
| 245 | ->text_is('#notifications .notify-error','500: Internal Server Error') |
| 246 | ; |
| 247 | |
Akron | a3c353c | 2019-02-14 23:50:00 +0100 | [diff] [blame] | 248 | # Do not cache |
| 249 | $t->get_ok('/?q=timeout') |
| 250 | ->status_is(200) |
Akron | cb5c171 | 2021-01-26 18:01:04 +0100 | [diff] [blame] | 251 | # ->text_like('#notifications div.notify-warning', qr!Response time exceeded!) |
Akron | cd42a14 | 2019-07-12 18:55:37 +0200 | [diff] [blame] | 252 | ->element_exists("input#cq") |
| 253 | ->element_exists_not("input#cq[value]") |
Akron | a3c353c | 2019-02-14 23:50:00 +0100 | [diff] [blame] | 254 | ->text_is('#total-results', '> 4,274,841'); |
| 255 | ; |
| 256 | |
Akron | 91a7685 | 2019-08-28 12:35:37 +0200 | [diff] [blame] | 257 | $t->app->defaults(no_cache => 1); |
| 258 | |
Akron | cd42a14 | 2019-07-12 18:55:37 +0200 | [diff] [blame] | 259 | # Query with collection |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 260 | $err = $t->get_ok('/?q=baum&collection=availability+%3D+%2FCC-BY.*%2F') |
Akron | cd42a14 | 2019-07-12 18:55:37 +0200 | [diff] [blame] | 261 | ->status_is(200) |
| 262 | ->element_exists("input#cq[value='availability = /CC-BY.*/']") |
Akron | bc6b3f2 | 2021-01-13 14:53:12 +0100 | [diff] [blame] | 263 | ->content_like(qr!${q}availability${q}!) |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 264 | ->tx->res->dom->at('#error') |
Akron | cd42a14 | 2019-07-12 18:55:37 +0200 | [diff] [blame] | 265 | ; |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 266 | is(defined $err ? $err->text : '', ''); |
| 267 | |
Akron | cd42a14 | 2019-07-12 18:55:37 +0200 | [diff] [blame] | 268 | |
Akron | 4cdc4fc | 2020-04-28 12:19:11 +0200 | [diff] [blame] | 269 | $t->app->hook( |
Akron | 7c87c1a | 2020-04-28 12:35:55 +0200 | [diff] [blame] | 270 | after_search => sub { |
Akron | 4cdc4fc | 2020-04-28 12:19:11 +0200 | [diff] [blame] | 271 | my $c = shift; |
| 272 | $c->content_for('after_search_results' => '<p id="special">Funny</p>'); |
| 273 | } |
| 274 | ); |
| 275 | |
Akron | cd42a14 | 2019-07-12 18:55:37 +0200 | [diff] [blame] | 276 | # Query with corpus query |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 277 | $err = $t->get_ok('/?q=baum&cq=availability+%3D+%2FCC-BY.*%2F') |
Akron | cd42a14 | 2019-07-12 18:55:37 +0200 | [diff] [blame] | 278 | ->status_is(200) |
| 279 | ->element_exists("input#cq[value='availability = /CC-BY.*/']") |
Akron | bc6b3f2 | 2021-01-13 14:53:12 +0100 | [diff] [blame] | 280 | ->content_like(qr!${q}availability${q}!) |
Akron | 4cdc4fc | 2020-04-28 12:19:11 +0200 | [diff] [blame] | 281 | ->text_is('#special', 'Funny') |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 282 | ->tx->res->dom->at('#error') |
Akron | cd42a14 | 2019-07-12 18:55:37 +0200 | [diff] [blame] | 283 | ; |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 284 | is(defined $err ? $err->text : '', ''); |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 285 | |
Akron | 909ed08 | 2019-12-11 21:38:27 +0100 | [diff] [blame] | 286 | my $match = { |
| 287 | matchID => 'match-FOLK/00070-SE-01/T-04-p5441-5442', |
| 288 | textSigle => 'FOLK/00070-SE-01/T-04' |
| 289 | }; |
| 290 | |
| 291 | $match = Kalamar::Controller::Search::_map_match($match); |
| 292 | |
| 293 | is($match->{matchID}, 'p5441-5442'); |
| 294 | |
Akron | 7b9a196 | 2020-07-02 09:52:53 +0200 | [diff] [blame] | 295 | # Query with pipe |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 296 | $err = $t->get_ok('/?q=baum&pipe=glemm') |
Akron | 7b9a196 | 2020-07-02 09:52:53 +0200 | [diff] [blame] | 297 | ->status_is(200) |
Akron | bc6b3f2 | 2021-01-13 14:53:12 +0100 | [diff] [blame] | 298 | ->content_like(qr/${q}pipes${q}:${q}glemm${q}/) |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 299 | ->tx->res->dom->at('#error') |
Akron | 7b9a196 | 2020-07-02 09:52:53 +0200 | [diff] [blame] | 300 | ; |
Akron | 58c6099 | 2021-09-07 13:11:43 +0200 | [diff] [blame] | 301 | is(defined $err ? $err->text : '', ''); |
Akron | 7b9a196 | 2020-07-02 09:52:53 +0200 | [diff] [blame] | 302 | |
Akron | 909ed08 | 2019-12-11 21:38:27 +0100 | [diff] [blame] | 303 | |
Akron | 0e1ed24 | 2018-10-11 13:22:00 +0200 | [diff] [blame] | 304 | done_testing; |
Akron | 8ea8429 | 2018-10-24 13:41:52 +0200 | [diff] [blame] | 305 | __END__ |