blob: 75ed9b8e1b83dba285a7aa3414db7ff1135e090c [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/;
5
6
7#####################
8# Start Fake server #
9#####################
10my $mount_point = '/api/';
11$ENV{KALAMAR_API} = $mount_point;
Akron0e1ed242018-10-11 13:22:00 +020012
13my $t = Test::Mojo->new('Kalamar');
14
Akron32396632018-10-11 17:08:37 +020015# Mount fake backend
16# Get the fixture path
17my $fixtures_path = path(Mojo::File->new(__FILE__)->dirname, 'fixtures');
18my $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
Akron0e1ed242018-10-11 13:22:00 +020027# Query passed
Akron32396632018-10-11 17:08:37 +020028$t->get_ok('/q2?q=baum')
Akron0e1ed242018-10-11 13:22:00 +020029 ->status_is(200)
30 ->text_is('#error','')
Akron32396632018-10-11 17:08:37 +020031 ->text_is('title', 'KorAP: Find »baum« with Poliqarp')
32 ->element_exists('meta[name="DC.title"][content="KorAP: Find »baum« with Poliqarp"]')
Akron0e1ed242018-10-11 13:22:00 +020033 ->element_exists('body[itemscope][itemtype="http://schema.org/SearchResultsPage"]')
Akron32396632018-10-11 17:08:37 +020034 ->text_is('#total-results', 51)
Akron0e1ed242018-10-11 13:22:00 +020035 ;
36
37
38
39done_testing;