blob: 714842889ee6aa02edba49c350e8642d558bc816 [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
Nils Diewalda748b0e2015-05-19 22:54:06 +000050done_testing;
51__END__