| 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 | |
| Helge | 3d1d04d | 2026-01-28 18:04:39 +0100 | [diff] [blame^] | 13 | # Get API version from app config (set in Kalamar.pm startup) |
| 14 | my $api_version = $t->app->config('Kalamar')->{api_version}; |
| 15 | |
| 16 | |
| Akron | aa5cf80 | 2021-06-11 11:31:00 +0200 | [diff] [blame] | 17 | # Bug 2021-06-11 |
| 18 | $t->get_ok('/doc/ql/wildcards?cat=1') |
| Akron | b9ca92b | 2024-03-14 10:20:18 +0100 | [diff] [blame] | 19 | ->status_is(404) # ! Should be 404! |
| 20 | ; |
| 21 | |
| 22 | $t->get_ok('/doc/ql/') |
| 23 | ->status_is(200) |
| 24 | ->text_is('title','KorAP: Query Languages') |
| 25 | ; |
| 26 | |
| 27 | $t->get_ok('/doc/ql') |
| 28 | ->status_is(200) |
| 29 | ->text_is('title','KorAP: Query Languages') |
| Akron | aa5cf80 | 2021-06-11 11:31:00 +0200 | [diff] [blame] | 30 | ; |
| 31 | |
| Akron | ccd71a4 | 2017-06-30 18:09:19 +0200 | [diff] [blame] | 32 | # Embedding |
| Nils Diewald | a898dac | 2015-05-06 21:04:16 +0000 | [diff] [blame] | 33 | $t->get_ok('/doc/ql/poliqarp-plus') |
| 34 | ->status_is(200) |
| 35 | ->text_like('title', qr/poliqarp/i) |
| 36 | ->element_exists('aside.active') |
| Akron | 1d09b53 | 2021-06-15 18:18:25 +0200 | [diff] [blame] | 37 | ->element_exists_not('aside.settings') |
| Nils Diewald | a898dac | 2015-05-06 21:04:16 +0000 | [diff] [blame] | 38 | ->element_exists('main.tutorial') |
| 39 | ->element_exists('header') |
| 40 | ->element_exists('aside nav') |
| Nils Diewald | a748b0e | 2015-05-19 22:54:06 +0000 | [diff] [blame] | 41 | ->text_is('h1 span', 'KorAP: Poliqarp+') |
| 42 | ->element_exists('li.folded.active') |
| 43 | ->text_is('li.folded.active a', 'Poliqarp+'); |
| Nils Diewald | a898dac | 2015-05-06 21:04:16 +0000 | [diff] [blame] | 44 | |
| 45 | $t->get_ok('/doc/ql/poliqarp-plus?embedded=true') |
| 46 | ->status_is(200) |
| 47 | ->text_like('title', qr/poliqarp/i) |
| 48 | ->element_exists('aside.active') |
| 49 | ->element_exists('main.tutorial') |
| Nils Diewald | a748b0e | 2015-05-19 22:54:06 +0000 | [diff] [blame] | 50 | ->element_exists_not('header') |
| 51 | ->element_exists('li.folded.active') |
| 52 | ->text_is('li.folded.active a', 'Poliqarp+'); |
| Nils Diewald | a898dac | 2015-05-06 21:04:16 +0000 | [diff] [blame] | 53 | |
| Akron | ccd71a4 | 2017-06-30 18:09:19 +0200 | [diff] [blame] | 54 | # Languages |
| 55 | $t->get_ok('/' => { 'Accept-Language' => 'de-DE, en-US, en' }) |
| 56 | ->status_is(200) |
| 57 | ->text_is("title", "KorAP - Korpusanalyseplattform der nächsten Generation"); |
| 58 | |
| 59 | $t->get_ok('/' => { 'Accept-Language' => 'en-US, en, de-DE' }) |
| 60 | ->status_is(200) |
| 61 | ->text_is("title", "KorAP - Corpus Analysis Platform"); |
| 62 | |
| Akron | b9ca92b | 2024-03-14 10:20:18 +0100 | [diff] [blame] | 63 | $t->get_ok('/doc/ql/' => { 'Accept-Language' => 'de-DE, en-US, en' }) |
| 64 | ->status_is(200) |
| 65 | ->text_is('title','KorAP: Anfragesprachen') |
| Helge | c166a63 | 2025-03-05 10:52:58 +0100 | [diff] [blame] | 66 | ->text_is('#examples > h3','Beispielanfragen') |
| Akron | b9ca92b | 2024-03-14 10:20:18 +0100 | [diff] [blame] | 67 | ; |
| 68 | |
| 69 | $t->get_ok('/doc/ql' => { 'Accept-Language' => 'de-DE, en-US, en' }) |
| 70 | ->status_is(200) |
| 71 | ->text_is('title','KorAP: Anfragesprachen') |
| 72 | ; |
| Akron | ccd71a4 | 2017-06-30 18:09:19 +0200 | [diff] [blame] | 73 | |
| 74 | # Pages |
| 75 | $t->get_ok('/doc/ql/poliqarp-plus' => { 'Accept-Language' => 'en-US, en, de-DE' }) |
| 76 | ->status_is(200) |
| 77 | ->text_is("title", "KorAP: Poliqarp+") |
| 78 | ->text_is('main section > h3', 'Simple Segments'); |
| 79 | |
| 80 | $t->get_ok('/doc/ql/poliqarp-plus' => { 'Accept-Language' => 'de-DE, en-US, en' }) |
| 81 | ->status_is(200) |
| 82 | ->text_is("title", "KorAP: Poliqarp+") |
| 83 | ->text_is('main section > h3', 'Einfache Segmente'); |
| 84 | |
| Akron | ccd71a4 | 2017-06-30 18:09:19 +0200 | [diff] [blame] | 85 | $t->get_ok('/doc/ql/annis' => { 'Accept-Language' => 'en-US, en, de-DE' }) |
| 86 | ->status_is(200) |
| Rebecca Wilm | 45e9afe | 2024-11-07 15:17:29 +0100 | [diff] [blame] | 87 | ->text_is("title", "KorAP: ANNIS QL"); |
| Akron | ccd71a4 | 2017-06-30 18:09:19 +0200 | [diff] [blame] | 88 | |
| Akron | f4a7cf4 | 2018-01-09 15:58:45 +0100 | [diff] [blame] | 89 | # Check corpus examples |
| 90 | $t->get_ok('/doc/ql/poliqarp-plus') |
| 91 | ->status_is(200) |
| 92 | ->text_is('#segments pre.query.tutorial:nth-of-type(1) code', 'Baum'); |
| 93 | |
| Akron | 1bd65d9 | 2019-07-17 18:26:36 +0200 | [diff] [blame] | 94 | # Check data |
| 95 | $t->get_ok('/doc/data/annotation' => { 'Accept-Language' => 'en-US, en, de-DE' }) |
| 96 | ->status_is(200) |
| Akron | 9490e3b | 2019-10-17 12:26:29 +0200 | [diff] [blame] | 97 | ->text_is('#page-top', 'KorAP: Annotations'); |
| Akron | 1bd65d9 | 2019-07-17 18:26:36 +0200 | [diff] [blame] | 98 | $t->get_ok('/doc/data/annotation' => { 'Accept-Language' => 'de-DE, en-US, en' }) |
| 99 | ->status_is(200) |
| Akron | 9490e3b | 2019-10-17 12:26:29 +0200 | [diff] [blame] | 100 | ->text_is('#page-top', 'KorAP: Annotationen'); |
| Akron | 1bd65d9 | 2019-07-17 18:26:36 +0200 | [diff] [blame] | 101 | |
| Akron | f4a7cf4 | 2018-01-09 15:58:45 +0100 | [diff] [blame] | 102 | my $app = $t->app; |
| 103 | |
| 104 | $app->plugin( |
| 105 | 'Localize' => { |
| 106 | dict => { |
| 107 | Q => { |
| 108 | newexample => { |
| 109 | poliqarp => { |
| 110 | simple => '** Beispiel' |
| 111 | } |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | } |
| 116 | ); |
| 117 | |
| 118 | # Set other example query |
| 119 | $app->config('Kalamar')->{examplecorpus} = 'newexample'; |
| 120 | |
| 121 | is($app->loc('Q_poliqarp_simple'), '** Beispiel'); |
| 122 | |
| 123 | # Check corpus examples |
| 124 | $t->get_ok('/doc/ql/poliqarp-plus') |
| 125 | ->status_is(200) |
| 126 | ->text_is('#segments pre.query.tutorial:nth-of-type(1) code', 'Beispiel') |
| 127 | ->text_is('#segments pre.query.tutorial:nth-of-type(1) span', '*'); |
| Nils Diewald | a898dac | 2015-05-06 21:04:16 +0000 | [diff] [blame] | 128 | |
| Akron | 07d8de6 | 2020-02-04 17:45:40 +0100 | [diff] [blame] | 129 | # Check API endpoint |
| 130 | $t->get_ok('/doc/api' => { 'X-Forwarded-Host' => 'korap.ids-mannheim.de' }) |
| 131 | ->status_is(200) |
| Helge | 3d1d04d | 2026-01-28 18:04:39 +0100 | [diff] [blame^] | 132 | ->text_is('#api-service-uri', 'https://korap.ids-mannheim.de/test/api/v' . $api_version . '/'); |
| Akron | 07d8de6 | 2020-02-04 17:45:40 +0100 | [diff] [blame] | 133 | |
| Helge | 23f7abd | 2024-02-27 16:35:15 +0100 | [diff] [blame] | 134 | # Set openapi path |
| Helge | 3d1d04d | 2026-01-28 18:04:39 +0100 | [diff] [blame^] | 135 | $app->config('Kalamar')->{openapi} = '/api/v' . $api_version . '/openapi/'; |
| Helge | 23f7abd | 2024-02-27 16:35:15 +0100 | [diff] [blame] | 136 | |
| 137 | # Check openapi endpoint |
| 138 | $t->get_ok('/doc/api' => { 'X-Forwarded-Host' => 'korap.ids-mannheim.de' }) |
| 139 | ->status_is(200) |
| Helge | 3d1d04d | 2026-01-28 18:04:39 +0100 | [diff] [blame^] | 140 | ->element_exists('#openapi > a[href="https://korap.ids-mannheim.de/api/v' . $api_version . '/openapi/"]'); |
| Akron | 07d8de6 | 2020-02-04 17:45:40 +0100 | [diff] [blame] | 141 | |
| Marc Kupietz | fcadda6 | 2021-09-08 09:06:25 +0200 | [diff] [blame] | 142 | # Languages of dev pages |
| 143 | $t->get_ok('/doc/development/kalamar') |
| 144 | ->status_is(200) |
| 145 | ->text_is("title", "KorAP: Kalamar") |
| 146 | ->content_like(qr!Main developer!); |
| 147 | |
| 148 | $t->get_ok('/doc/development/kalamar' => { 'Accept-Language' => 'de-DE, en-US, en' }) |
| 149 | ->status_is(200) |
| 150 | ->text_is("title", "KorAP: Kalamar") |
| 151 | ->content_like(qr!Hauptentwickler!); |
| 152 | |
| 153 | |
| Akron | 1011daf | 2021-03-01 12:34:58 +0100 | [diff] [blame] | 154 | # Check mail_to_chiffre |
| 155 | like($t->app->mail_to_chiffre('korap@korap.example'),qr!rel="nofollow"!); |
| 156 | like($t->app->mail_to_chiffre('korap@korap.example'),qr!class="PArok"!); |
| 157 | |
| Nils Diewald | a898dac | 2015-05-06 21:04:16 +0000 | [diff] [blame] | 158 | done_testing(); |