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