Nils Diewald | a898dac | 2015-05-06 21:04:16 +0000 | [diff] [blame] | 1 | use Mojo::Base -strict; |
Nils Diewald | a898dac | 2015-05-06 21:04:16 +0000 | [diff] [blame] | 2 | use Test::More; |
| 3 | use Test::Mojo; |
| 4 | |
| 5 | # Test the documentation |
| 6 | |
Akron | 07d8de6 | 2020-02-04 17:45:40 +0100 | [diff] [blame] | 7 | my $t = Test::Mojo->new('Kalamar' => { |
| 8 | Kalamar => { |
| 9 | experimental_proxy => 1, |
| 10 | proxy_prefix => '/test' |
| 11 | } |
| 12 | }); |
Nils Diewald | a898dac | 2015-05-06 21:04:16 +0000 | [diff] [blame] | 13 | |
Akron | ccd71a4 | 2017-06-30 18:09:19 +0200 | [diff] [blame] | 14 | # Embedding |
Nils Diewald | a898dac | 2015-05-06 21:04:16 +0000 | [diff] [blame] | 15 | $t->get_ok('/doc/ql/poliqarp-plus') |
| 16 | ->status_is(200) |
| 17 | ->text_like('title', qr/poliqarp/i) |
| 18 | ->element_exists('aside.active') |
| 19 | ->element_exists('main.tutorial') |
| 20 | ->element_exists('header') |
| 21 | ->element_exists('aside nav') |
Nils Diewald | a748b0e | 2015-05-19 22:54:06 +0000 | [diff] [blame] | 22 | ->text_is('h1 span', 'KorAP: Poliqarp+') |
| 23 | ->element_exists('li.folded.active') |
| 24 | ->text_is('li.folded.active a', 'Poliqarp+'); |
Nils Diewald | a898dac | 2015-05-06 21:04:16 +0000 | [diff] [blame] | 25 | |
| 26 | $t->get_ok('/doc/ql/poliqarp-plus?embedded=true') |
| 27 | ->status_is(200) |
| 28 | ->text_like('title', qr/poliqarp/i) |
| 29 | ->element_exists('aside.active') |
| 30 | ->element_exists('main.tutorial') |
Nils Diewald | a748b0e | 2015-05-19 22:54:06 +0000 | [diff] [blame] | 31 | ->element_exists_not('header') |
| 32 | ->element_exists('li.folded.active') |
| 33 | ->text_is('li.folded.active a', 'Poliqarp+'); |
Nils Diewald | a898dac | 2015-05-06 21:04:16 +0000 | [diff] [blame] | 34 | |
Akron | ccd71a4 | 2017-06-30 18:09:19 +0200 | [diff] [blame] | 35 | # Languages |
| 36 | $t->get_ok('/' => { 'Accept-Language' => 'de-DE, en-US, en' }) |
| 37 | ->status_is(200) |
| 38 | ->text_is("title", "KorAP - Korpusanalyseplattform der nächsten Generation"); |
| 39 | |
| 40 | $t->get_ok('/' => { 'Accept-Language' => 'en-US, en, de-DE' }) |
| 41 | ->status_is(200) |
| 42 | ->text_is("title", "KorAP - Corpus Analysis Platform"); |
| 43 | |
| 44 | |
| 45 | # Pages |
| 46 | $t->get_ok('/doc/ql/poliqarp-plus' => { 'Accept-Language' => 'en-US, en, de-DE' }) |
| 47 | ->status_is(200) |
| 48 | ->text_is("title", "KorAP: Poliqarp+") |
| 49 | ->text_is('main section > h3', 'Simple Segments'); |
| 50 | |
| 51 | $t->get_ok('/doc/ql/poliqarp-plus' => { 'Accept-Language' => 'de-DE, en-US, en' }) |
| 52 | ->status_is(200) |
| 53 | ->text_is("title", "KorAP: Poliqarp+") |
| 54 | ->text_is('main section > h3', 'Einfache Segmente'); |
| 55 | |
| 56 | |
| 57 | $t->get_ok('/doc/ql/annis' => { 'Accept-Language' => 'en-US, en, de-DE' }) |
| 58 | ->status_is(200) |
| 59 | ->text_is("title", "KorAP: Annis QL"); |
| 60 | |
Akron | f4a7cf4 | 2018-01-09 15:58:45 +0100 | [diff] [blame] | 61 | # Check corpus examples |
| 62 | $t->get_ok('/doc/ql/poliqarp-plus') |
| 63 | ->status_is(200) |
| 64 | ->text_is('#segments pre.query.tutorial:nth-of-type(1) code', 'Baum'); |
| 65 | |
Akron | 1bd65d9 | 2019-07-17 18:26:36 +0200 | [diff] [blame] | 66 | # Check data |
| 67 | $t->get_ok('/doc/data/annotation' => { 'Accept-Language' => 'en-US, en, de-DE' }) |
| 68 | ->status_is(200) |
Akron | 9490e3b | 2019-10-17 12:26:29 +0200 | [diff] [blame] | 69 | ->text_is('#page-top', 'KorAP: Annotations'); |
Akron | 1bd65d9 | 2019-07-17 18:26:36 +0200 | [diff] [blame] | 70 | $t->get_ok('/doc/data/annotation' => { 'Accept-Language' => 'de-DE, en-US, en' }) |
| 71 | ->status_is(200) |
Akron | 9490e3b | 2019-10-17 12:26:29 +0200 | [diff] [blame] | 72 | ->text_is('#page-top', 'KorAP: Annotationen'); |
Akron | 1bd65d9 | 2019-07-17 18:26:36 +0200 | [diff] [blame] | 73 | |
Akron | f4a7cf4 | 2018-01-09 15:58:45 +0100 | [diff] [blame] | 74 | my $app = $t->app; |
| 75 | |
| 76 | $app->plugin( |
| 77 | 'Localize' => { |
| 78 | dict => { |
| 79 | Q => { |
| 80 | newexample => { |
| 81 | poliqarp => { |
| 82 | simple => '** Beispiel' |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | ); |
| 89 | |
| 90 | # Set other example query |
| 91 | $app->config('Kalamar')->{examplecorpus} = 'newexample'; |
| 92 | |
| 93 | is($app->loc('Q_poliqarp_simple'), '** Beispiel'); |
| 94 | |
| 95 | # Check corpus examples |
| 96 | $t->get_ok('/doc/ql/poliqarp-plus') |
| 97 | ->status_is(200) |
| 98 | ->text_is('#segments pre.query.tutorial:nth-of-type(1) code', 'Beispiel') |
| 99 | ->text_is('#segments pre.query.tutorial:nth-of-type(1) span', '*'); |
Nils Diewald | a898dac | 2015-05-06 21:04:16 +0000 | [diff] [blame] | 100 | |
Akron | 07d8de6 | 2020-02-04 17:45:40 +0100 | [diff] [blame] | 101 | # Check API endpoint |
| 102 | $t->get_ok('/doc/api' => { 'X-Forwarded-Host' => 'korap.ids-mannheim.de' }) |
| 103 | ->status_is(200) |
| 104 | ->text_is('#api-service-uri', 'https://korap.ids-mannheim.de/test/api/v1.0/'); |
| 105 | |
| 106 | |
Nils Diewald | a898dac | 2015-05-06 21:04:16 +0000 | [diff] [blame] | 107 | done_testing(); |