blob: f3a3a7d2ea7d2b0c42333505e7a6848d745a3072 [file] [log] [blame]
Nils Diewalda898dac2015-05-06 21:04:16 +00001use Mojo::Base -strict;
Nils Diewalda898dac2015-05-06 21:04:16 +00002use Test::More;
3use Test::Mojo;
4
5# Test the documentation
6
Akron07d8de62020-02-04 17:45:40 +01007my $t = Test::Mojo->new('Kalamar' => {
8 Kalamar => {
Akron07d8de62020-02-04 17:45:40 +01009 proxy_prefix => '/test'
10 }
11});
Nils Diewalda898dac2015-05-06 21:04:16 +000012
Helge3d1d04d2026-01-28 18:04:39 +010013# Get API version from app config (set in Kalamar.pm startup)
14my $api_version = $t->app->config('Kalamar')->{api_version};
15
16
Akronaa5cf802021-06-11 11:31:00 +020017# Bug 2021-06-11
18$t->get_ok('/doc/ql/wildcards?cat=1')
Akronb9ca92b2024-03-14 10:20:18 +010019 ->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')
Akronaa5cf802021-06-11 11:31:00 +020030 ;
31
Akronccd71a42017-06-30 18:09:19 +020032# Embedding
Nils Diewalda898dac2015-05-06 21:04:16 +000033$t->get_ok('/doc/ql/poliqarp-plus')
34 ->status_is(200)
35 ->text_like('title', qr/poliqarp/i)
36 ->element_exists('aside.active')
Akron1d09b532021-06-15 18:18:25 +020037 ->element_exists_not('aside.settings')
Nils Diewalda898dac2015-05-06 21:04:16 +000038 ->element_exists('main.tutorial')
39 ->element_exists('header')
40 ->element_exists('aside nav')
Nils Diewalda748b0e2015-05-19 22:54:06 +000041 ->text_is('h1 span', 'KorAP: Poliqarp+')
42 ->element_exists('li.folded.active')
43 ->text_is('li.folded.active a', 'Poliqarp+');
Nils Diewalda898dac2015-05-06 21:04:16 +000044
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 Diewalda748b0e2015-05-19 22:54:06 +000050 ->element_exists_not('header')
51 ->element_exists('li.folded.active')
52 ->text_is('li.folded.active a', 'Poliqarp+');
Nils Diewalda898dac2015-05-06 21:04:16 +000053
Akronccd71a42017-06-30 18:09:19 +020054# 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
Akronb9ca92b2024-03-14 10:20:18 +010063$t->get_ok('/doc/ql/' => { 'Accept-Language' => 'de-DE, en-US, en' })
64 ->status_is(200)
65 ->text_is('title','KorAP: Anfragesprachen')
Helgec166a632025-03-05 10:52:58 +010066 ->text_is('#examples > h3','Beispielanfragen')
Akronb9ca92b2024-03-14 10:20:18 +010067 ;
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 ;
Akronccd71a42017-06-30 18:09:19 +020073
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
Akronccd71a42017-06-30 18:09:19 +020085$t->get_ok('/doc/ql/annis' => { 'Accept-Language' => 'en-US, en, de-DE' })
86 ->status_is(200)
Rebecca Wilm45e9afe2024-11-07 15:17:29 +010087 ->text_is("title", "KorAP: ANNIS QL");
Akronccd71a42017-06-30 18:09:19 +020088
Akronf4a7cf42018-01-09 15:58:45 +010089# 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
Akron1bd65d92019-07-17 18:26:36 +020094# Check data
95$t->get_ok('/doc/data/annotation' => { 'Accept-Language' => 'en-US, en, de-DE' })
96 ->status_is(200)
Akron9490e3b2019-10-17 12:26:29 +020097 ->text_is('#page-top', 'KorAP: Annotations');
Akron1bd65d92019-07-17 18:26:36 +020098$t->get_ok('/doc/data/annotation' => { 'Accept-Language' => 'de-DE, en-US, en' })
99 ->status_is(200)
Akron9490e3b2019-10-17 12:26:29 +0200100 ->text_is('#page-top', 'KorAP: Annotationen');
Akron1bd65d92019-07-17 18:26:36 +0200101
Akronf4a7cf42018-01-09 15:58:45 +0100102my $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
121is($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 Diewalda898dac2015-05-06 21:04:16 +0000128
Akron07d8de62020-02-04 17:45:40 +0100129# Check API endpoint
130$t->get_ok('/doc/api' => { 'X-Forwarded-Host' => 'korap.ids-mannheim.de' })
131 ->status_is(200)
Helge3d1d04d2026-01-28 18:04:39 +0100132 ->text_is('#api-service-uri', 'https://korap.ids-mannheim.de/test/api/v' . $api_version . '/');
Akron07d8de62020-02-04 17:45:40 +0100133
Helge23f7abd2024-02-27 16:35:15 +0100134# Set openapi path
Helge3d1d04d2026-01-28 18:04:39 +0100135$app->config('Kalamar')->{openapi} = '/api/v' . $api_version . '/openapi/';
Helge23f7abd2024-02-27 16:35:15 +0100136
137# Check openapi endpoint
138$t->get_ok('/doc/api' => { 'X-Forwarded-Host' => 'korap.ids-mannheim.de' })
139 ->status_is(200)
Helge3d1d04d2026-01-28 18:04:39 +0100140 ->element_exists('#openapi > a[href="https://korap.ids-mannheim.de/api/v' . $api_version . '/openapi/"]');
Akron07d8de62020-02-04 17:45:40 +0100141
Marc Kupietzfcadda62021-09-08 09:06:25 +0200142# 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
Akron1011daf2021-03-01 12:34:58 +0100154# Check mail_to_chiffre
155like($t->app->mail_to_chiffre('korap@korap.example'),qr!rel="nofollow"!);
156like($t->app->mail_to_chiffre('korap@korap.example'),qr!class="PArok"!);
157
Nils Diewalda898dac2015-05-06 21:04:16 +0000158done_testing();