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