blob: 4d5cd700a46ed4471990b726327c1cdcc044e5ec [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
Akronaa5cf802021-06-11 11:31:00 +020013# Bug 2021-06-11
14$t->get_ok('/doc/ql/wildcards?cat=1')
Akronb9ca92b2024-03-14 10:20:18 +010015 ->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')
Akronaa5cf802021-06-11 11:31:00 +020026 ;
27
Akronccd71a42017-06-30 18:09:19 +020028# Embedding
Nils Diewalda898dac2015-05-06 21:04:16 +000029$t->get_ok('/doc/ql/poliqarp-plus')
30 ->status_is(200)
31 ->text_like('title', qr/poliqarp/i)
32 ->element_exists('aside.active')
Akron1d09b532021-06-15 18:18:25 +020033 ->element_exists_not('aside.settings')
Nils Diewalda898dac2015-05-06 21:04:16 +000034 ->element_exists('main.tutorial')
35 ->element_exists('header')
36 ->element_exists('aside nav')
Nils Diewalda748b0e2015-05-19 22:54:06 +000037 ->text_is('h1 span', 'KorAP: Poliqarp+')
38 ->element_exists('li.folded.active')
39 ->text_is('li.folded.active a', 'Poliqarp+');
Nils Diewalda898dac2015-05-06 21:04:16 +000040
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 Diewalda748b0e2015-05-19 22:54:06 +000046 ->element_exists_not('header')
47 ->element_exists('li.folded.active')
48 ->text_is('li.folded.active a', 'Poliqarp+');
Nils Diewalda898dac2015-05-06 21:04:16 +000049
Akronccd71a42017-06-30 18:09:19 +020050# 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
Akronb9ca92b2024-03-14 10:20:18 +010059$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 ;
Akronccd71a42017-06-30 18:09:19 +020069
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
Akronccd71a42017-06-30 18:09:19 +020081$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
Akronf4a7cf42018-01-09 15:58:45 +010085# 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
Akron1bd65d92019-07-17 18:26:36 +020090# Check data
91$t->get_ok('/doc/data/annotation' => { 'Accept-Language' => 'en-US, en, de-DE' })
92 ->status_is(200)
Akron9490e3b2019-10-17 12:26:29 +020093 ->text_is('#page-top', 'KorAP: Annotations');
Akron1bd65d92019-07-17 18:26:36 +020094$t->get_ok('/doc/data/annotation' => { 'Accept-Language' => 'de-DE, en-US, en' })
95 ->status_is(200)
Akron9490e3b2019-10-17 12:26:29 +020096 ->text_is('#page-top', 'KorAP: Annotationen');
Akron1bd65d92019-07-17 18:26:36 +020097
Akronf4a7cf42018-01-09 15:58:45 +010098my $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
117is($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 Diewalda898dac2015-05-06 21:04:16 +0000124
Akron07d8de62020-02-04 17:45:40 +0100125# 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
Helge23f7abd2024-02-27 16:35:15 +0100130# Set openapi path
131$app->config('Kalamar')->{openapi} = '/api/v1.0/openapi/';
132
133# Check openapi endpoint
134$t->get_ok('/doc/api' => { 'X-Forwarded-Host' => 'korap.ids-mannheim.de' })
135 ->status_is(200)
136 ->element_exists('#openapi > a[href="https://korap.ids-mannheim.de/api/v1.0/openapi/"]');
Akron07d8de62020-02-04 17:45:40 +0100137
Marc Kupietzfcadda62021-09-08 09:06:25 +0200138# Languages of dev pages
139$t->get_ok('/doc/development/kalamar')
140 ->status_is(200)
141 ->text_is("title", "KorAP: Kalamar")
142 ->content_like(qr!Main developer!);
143
144$t->get_ok('/doc/development/kalamar' => { 'Accept-Language' => 'de-DE, en-US, en' })
145 ->status_is(200)
146 ->text_is("title", "KorAP: Kalamar")
147 ->content_like(qr!Hauptentwickler!);
148
149
Akron1011daf2021-03-01 12:34:58 +0100150# Check mail_to_chiffre
151like($t->app->mail_to_chiffre('korap@korap.example'),qr!rel="nofollow"!);
152like($t->app->mail_to_chiffre('korap@korap.example'),qr!class="PArok"!);
153
Nils Diewalda898dac2015-05-06 21:04:16 +0000154done_testing();