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