blob: ec386969c697717e08374f7478e25a45c0f04d7f [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
Akron8eef3462018-09-20 16:45:10 +020010if (0) {
11
Nils Diewald034ea702015-01-16 19:41:52 +000012$t->get_ok('/')
13 ->status_is(200)
Nils Diewalda748b0e2015-05-19 22:54:06 +000014 ->text_is('title', 'KorAP - Corpus Analysis Platform')
15 ->text_like('h1 span', qr/KorAP - Corpus Analysis Platform/i)
Nils Diewald034ea702015-01-16 19:41:52 +000016 ;
17
18# Check paging
Akron3042f242017-04-15 16:57:55 +020019$t->get_ok('/?q=Baum')
20 ->text_like('h1 span', qr/KorAP: Find .Baum./i)
Nils Diewalda748b0e2015-05-19 22:54:06 +000021 # ->text_is('pre.query.serial span', 'JSON-LD Serialization for "test"')
22 ->text_like('#total-results', qr/\d+$/)
Nils Diewald034ea702015-01-16 19:41:52 +000023 ->text_is('#pagination a[rel=self] span', 1)
Akron45cd0ce2017-04-18 23:24:29 +020024 ->element_exists_not('#ql-field option[value=poliqarp][selected]')
25 ->element_exists_not('#ql-field option[value=cosmas2][selected]')
Akron3042f242017-04-15 16:57:55 +020026 ;
27
Nils Diewald034ea702015-01-16 19:41:52 +000028# Check paging
Akron45cd0ce2017-04-18 23:24:29 +020029$t->get_ok('/?q=test&p=2&ql=cosmas2')
Nils Diewalda748b0e2015-05-19 22:54:06 +000030 ->text_like('#total-results', qr/\d+$/)
Nils Diewald034ea702015-01-16 19:41:52 +000031 ->text_is('#pagination a[rel=self] span', 2)
Akron45cd0ce2017-04-18 23:24:29 +020032 ->element_exists('#ql-field option[value=cosmas2][selected]')
33 ->element_exists_not('#ql-field option[value=poliqarp][selected]')
Nils Diewald034ea702015-01-16 19:41:52 +000034;
35
Akron14a79e62017-04-24 20:16:58 +020036# Check paging
37$t->get_ok('/?q=test&p=2&ql=cosmas2')
38 ->text_like('#total-results', qr/\d+$/)
39 ->text_is('#pagination a[rel=self] span', 2)
40 ->element_exists('#ql-field option[value=cosmas2][selected]')
41 ->element_exists_not('#ql-field option[value=poliqarp][selected]')
42;
43
44# Check for authorization
45# this should just trigger a fixture - it's not serious
46$t->get_ok('/?q=test&p=2&ql=cosmas3')
47 ->element_exists_not('#pagination a[rel=self] span')
48 ->element_exists('#search #no-results')
49 ->text_like('.notify-error', qr!No entity found!)
50 ;
51
Akron1b0c2652017-04-27 15:28:49 +020052
Akron3fe9fc32018-03-20 13:12:31 +010053# Check for server error
54$t->get_ok('/?q=server_fail&ql=poliqarp')
55 ->element_exists('.notify-error')
56 ->text_is('.notify-error', '500: Internal Server Error (remote)')
57 ;
Akron1b0c2652017-04-27 15:28:49 +020058
Akron8eef3462018-09-20 16:45:10 +020059};
60
Akronf44a0a22018-07-05 11:19:49 +020061
62# Check for query error
63$t->get_ok('/?q=[orth=das&ql=poliqarp')
64 ->element_exists('.notify-error')
65 ->text_is('.notify-error', '302: Parantheses/brackets unbalanced.')
Akron8eef3462018-09-20 16:45:10 +020066 ->content_like(qr!KorAP\.koralQuery =!)
Akronf44a0a22018-07-05 11:19:49 +020067 ;
68
Nils Diewalda748b0e2015-05-19 22:54:06 +000069done_testing;
70__END__