blob: 4828b854e818c2c44cd07b983bff380612e76b0d [file] [log] [blame]
Nils Diewald034ea702015-01-16 19:41:52 +00001use Mojo::Base -strict;
2use lib '../lib', 'lib';
Akron3042f242017-04-15 16:57:55 +02003use Test::More;
Nils Diewald034ea702015-01-16 19:41:52 +00004use Test::Mojo;
5
Akron3042f242017-04-15 16:57:55 +02006$ENV{MOJO_MODE} = 'test';
7
Nils Diewald2fe12e12015-03-06 16:47:06 +00008my $t = Test::Mojo->new('Kalamar');
Akron3042f242017-04-15 16:57:55 +02009
Nils Diewald034ea702015-01-16 19:41:52 +000010$t->get_ok('/')
11 ->status_is(200)
Nils Diewalda748b0e2015-05-19 22:54:06 +000012 ->text_is('title', 'KorAP - Corpus Analysis Platform')
13 ->text_like('h1 span', qr/KorAP - Corpus Analysis Platform/i)
Nils Diewald034ea702015-01-16 19:41:52 +000014 ;
15
16# Check paging
Akron3042f242017-04-15 16:57:55 +020017$t->get_ok('/?q=Baum')
18 ->text_like('h1 span', qr/KorAP: Find .Baum./i)
Nils Diewalda748b0e2015-05-19 22:54:06 +000019 # ->text_is('pre.query.serial span', 'JSON-LD Serialization for "test"')
20 ->text_like('#total-results', qr/\d+$/)
Nils Diewald034ea702015-01-16 19:41:52 +000021 ->text_is('#pagination a[rel=self] span', 1)
Akron45cd0ce2017-04-18 23:24:29 +020022 ->element_exists_not('#ql-field option[value=poliqarp][selected]')
23 ->element_exists_not('#ql-field option[value=cosmas2][selected]')
Akron3042f242017-04-15 16:57:55 +020024 ;
25
Nils Diewald034ea702015-01-16 19:41:52 +000026# Check paging
Akron45cd0ce2017-04-18 23:24:29 +020027$t->get_ok('/?q=test&p=2&ql=cosmas2')
Nils Diewalda748b0e2015-05-19 22:54:06 +000028 ->text_like('#total-results', qr/\d+$/)
Nils Diewald034ea702015-01-16 19:41:52 +000029 ->text_is('#pagination a[rel=self] span', 2)
Akron45cd0ce2017-04-18 23:24:29 +020030 ->element_exists('#ql-field option[value=cosmas2][selected]')
31 ->element_exists_not('#ql-field option[value=poliqarp][selected]')
Nils Diewald034ea702015-01-16 19:41:52 +000032;
33
Akron14a79e62017-04-24 20:16:58 +020034# Check paging
35$t->get_ok('/?q=test&p=2&ql=cosmas2')
36 ->text_like('#total-results', qr/\d+$/)
37 ->text_is('#pagination a[rel=self] span', 2)
38 ->element_exists('#ql-field option[value=cosmas2][selected]')
39 ->element_exists_not('#ql-field option[value=poliqarp][selected]')
40;
41
42# Check for authorization
43# this should just trigger a fixture - it's not serious
44$t->get_ok('/?q=test&p=2&ql=cosmas3')
45 ->element_exists_not('#pagination a[rel=self] span')
46 ->element_exists('#search #no-results')
47 ->text_like('.notify-error', qr!No entity found!)
48 ;
49
Akron1b0c2652017-04-27 15:28:49 +020050
Akron3fe9fc32018-03-20 13:12:31 +010051# Check for server error
52$t->get_ok('/?q=server_fail&ql=poliqarp')
53 ->element_exists('.notify-error')
54 ->text_is('.notify-error', '500: Internal Server Error (remote)')
55 ;
Akron1b0c2652017-04-27 15:28:49 +020056
Nils Diewalda748b0e2015-05-19 22:54:06 +000057done_testing;
58__END__