Nils Diewald | 034ea70 | 2015-01-16 19:41:52 +0000 | [diff] [blame] | 1 | use Mojo::Base -strict; |
| 2 | use lib '../lib', 'lib'; |
Akron | 3042f24 | 2017-04-15 16:57:55 +0200 | [diff] [blame] | 3 | use Test::More; |
Nils Diewald | 034ea70 | 2015-01-16 19:41:52 +0000 | [diff] [blame] | 4 | use Test::Mojo; |
| 5 | |
Akron | 3042f24 | 2017-04-15 16:57:55 +0200 | [diff] [blame] | 6 | $ENV{MOJO_MODE} = 'test'; |
| 7 | |
Nils Diewald | 2fe12e1 | 2015-03-06 16:47:06 +0000 | [diff] [blame] | 8 | my $t = Test::Mojo->new('Kalamar'); |
Akron | 3042f24 | 2017-04-15 16:57:55 +0200 | [diff] [blame] | 9 | |
Nils Diewald | 034ea70 | 2015-01-16 19:41:52 +0000 | [diff] [blame] | 10 | $t->get_ok('/') |
| 11 | ->status_is(200) |
Nils Diewald | a748b0e | 2015-05-19 22:54:06 +0000 | [diff] [blame] | 12 | ->text_is('title', 'KorAP - Corpus Analysis Platform') |
| 13 | ->text_like('h1 span', qr/KorAP - Corpus Analysis Platform/i) |
Nils Diewald | 034ea70 | 2015-01-16 19:41:52 +0000 | [diff] [blame] | 14 | ; |
| 15 | |
| 16 | # Check paging |
Akron | 3042f24 | 2017-04-15 16:57:55 +0200 | [diff] [blame] | 17 | $t->get_ok('/?q=Baum') |
| 18 | ->text_like('h1 span', qr/KorAP: Find .Baum./i) |
Nils Diewald | a748b0e | 2015-05-19 22:54:06 +0000 | [diff] [blame] | 19 | # ->text_is('pre.query.serial span', 'JSON-LD Serialization for "test"') |
| 20 | ->text_like('#total-results', qr/\d+$/) |
Nils Diewald | 034ea70 | 2015-01-16 19:41:52 +0000 | [diff] [blame] | 21 | ->text_is('#pagination a[rel=self] span', 1) |
Akron | 45cd0ce | 2017-04-18 23:24:29 +0200 | [diff] [blame] | 22 | ->element_exists_not('#ql-field option[value=poliqarp][selected]') |
| 23 | ->element_exists_not('#ql-field option[value=cosmas2][selected]') |
Akron | 3042f24 | 2017-04-15 16:57:55 +0200 | [diff] [blame] | 24 | ; |
| 25 | |
Nils Diewald | 034ea70 | 2015-01-16 19:41:52 +0000 | [diff] [blame] | 26 | # Check paging |
Akron | 45cd0ce | 2017-04-18 23:24:29 +0200 | [diff] [blame] | 27 | $t->get_ok('/?q=test&p=2&ql=cosmas2') |
Nils Diewald | a748b0e | 2015-05-19 22:54:06 +0000 | [diff] [blame] | 28 | ->text_like('#total-results', qr/\d+$/) |
Nils Diewald | 034ea70 | 2015-01-16 19:41:52 +0000 | [diff] [blame] | 29 | ->text_is('#pagination a[rel=self] span', 2) |
Akron | 45cd0ce | 2017-04-18 23:24:29 +0200 | [diff] [blame] | 30 | ->element_exists('#ql-field option[value=cosmas2][selected]') |
| 31 | ->element_exists_not('#ql-field option[value=poliqarp][selected]') |
Nils Diewald | 034ea70 | 2015-01-16 19:41:52 +0000 | [diff] [blame] | 32 | ; |
| 33 | |
Akron | 14a79e6 | 2017-04-24 20:16:58 +0200 | [diff] [blame] | 34 | # 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 | |
Akron | 1b0c265 | 2017-04-27 15:28:49 +0200 | [diff] [blame] | 50 | |
Akron | 3fe9fc3 | 2018-03-20 13:12:31 +0100 | [diff] [blame] | 51 | # 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 | ; |
Akron | 1b0c265 | 2017-04-27 15:28:49 +0200 | [diff] [blame] | 56 | |
Akron | f44a0a2 | 2018-07-05 11:19:49 +0200 | [diff] [blame] | 57 | |
| 58 | # Check for query error |
| 59 | $t->get_ok('/?q=[orth=das&ql=poliqarp') |
| 60 | ->element_exists('.notify-error') |
| 61 | ->text_is('.notify-error', '302: Parantheses/brackets unbalanced.') |
| 62 | ; |
| 63 | |
Nils Diewald | a748b0e | 2015-05-19 22:54:06 +0000 | [diff] [blame] | 64 | done_testing; |
| 65 | __END__ |