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/; |
| 5 | |
| 6 | |
| 7 | ##################### |
| 8 | # Start Fake server # |
| 9 | ##################### |
| 10 | my $mount_point = '/api/'; |
| 11 | $ENV{KALAMAR_API} = $mount_point; |
Akron | 0e1ed24 | 2018-10-11 13:22:00 +0200 | [diff] [blame] | 12 | |
| 13 | my $t = Test::Mojo->new('Kalamar'); |
| 14 | |
Akron | 3239663 | 2018-10-11 17:08:37 +0200 | [diff] [blame^] | 15 | # Mount fake backend |
| 16 | # Get the fixture path |
| 17 | my $fixtures_path = path(Mojo::File->new(__FILE__)->dirname, 'fixtures'); |
| 18 | my $fake_backend = $t->app->plugin( |
| 19 | Mount => { |
| 20 | $mount_point => |
| 21 | $fixtures_path->child('fake_backend.pl') |
| 22 | } |
| 23 | ); |
| 24 | # Configure fake backend |
| 25 | $fake_backend->pattern->defaults->{app}->log($t->app->log); |
| 26 | |
Akron | 0e1ed24 | 2018-10-11 13:22:00 +0200 | [diff] [blame] | 27 | # Query passed |
Akron | 3239663 | 2018-10-11 17:08:37 +0200 | [diff] [blame^] | 28 | $t->get_ok('/q2?q=baum') |
Akron | 0e1ed24 | 2018-10-11 13:22:00 +0200 | [diff] [blame] | 29 | ->status_is(200) |
| 30 | ->text_is('#error','') |
Akron | 3239663 | 2018-10-11 17:08:37 +0200 | [diff] [blame^] | 31 | ->text_is('title', 'KorAP: Find »baum« with Poliqarp') |
| 32 | ->element_exists('meta[name="DC.title"][content="KorAP: Find »baum« with Poliqarp"]') |
Akron | 0e1ed24 | 2018-10-11 13:22:00 +0200 | [diff] [blame] | 33 | ->element_exists('body[itemscope][itemtype="http://schema.org/SearchResultsPage"]') |
Akron | 3239663 | 2018-10-11 17:08:37 +0200 | [diff] [blame^] | 34 | ->text_is('#total-results', 51) |
Akron | 0e1ed24 | 2018-10-11 13:22:00 +0200 | [diff] [blame] | 35 | ; |
| 36 | |
| 37 | |
| 38 | |
| 39 | done_testing; |