blob: 4fb746484a1fe8dd3dd1ccc4845cc89cebf82df8 [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 => {
9 experimental_proxy => 1,
10 proxy_prefix => '/test'
11 }
12});
Nils Diewalda898dac2015-05-06 21:04:16 +000013
Akronccd71a42017-06-30 18:09:19 +020014# Embedding
Nils Diewalda898dac2015-05-06 21:04:16 +000015$t->get_ok('/doc/ql/poliqarp-plus')
16 ->status_is(200)
17 ->text_like('title', qr/poliqarp/i)
18 ->element_exists('aside.active')
19 ->element_exists('main.tutorial')
20 ->element_exists('header')
21 ->element_exists('aside nav')
Nils Diewalda748b0e2015-05-19 22:54:06 +000022 ->text_is('h1 span', 'KorAP: Poliqarp+')
23 ->element_exists('li.folded.active')
24 ->text_is('li.folded.active a', 'Poliqarp+');
Nils Diewalda898dac2015-05-06 21:04:16 +000025
26$t->get_ok('/doc/ql/poliqarp-plus?embedded=true')
27 ->status_is(200)
28 ->text_like('title', qr/poliqarp/i)
29 ->element_exists('aside.active')
30 ->element_exists('main.tutorial')
Nils Diewalda748b0e2015-05-19 22:54:06 +000031 ->element_exists_not('header')
32 ->element_exists('li.folded.active')
33 ->text_is('li.folded.active a', 'Poliqarp+');
Nils Diewalda898dac2015-05-06 21:04:16 +000034
Akronccd71a42017-06-30 18:09:19 +020035# Languages
36$t->get_ok('/' => { 'Accept-Language' => 'de-DE, en-US, en' })
37 ->status_is(200)
38 ->text_is("title", "KorAP - Korpusanalyseplattform der nächsten Generation");
39
40$t->get_ok('/' => { 'Accept-Language' => 'en-US, en, de-DE' })
41 ->status_is(200)
42 ->text_is("title", "KorAP - Corpus Analysis Platform");
43
44
45# Pages
46$t->get_ok('/doc/ql/poliqarp-plus' => { 'Accept-Language' => 'en-US, en, de-DE' })
47 ->status_is(200)
48 ->text_is("title", "KorAP: Poliqarp+")
49 ->text_is('main section > h3', 'Simple Segments');
50
51$t->get_ok('/doc/ql/poliqarp-plus' => { 'Accept-Language' => 'de-DE, en-US, en' })
52 ->status_is(200)
53 ->text_is("title", "KorAP: Poliqarp+")
54 ->text_is('main section > h3', 'Einfache Segmente');
55
56
57$t->get_ok('/doc/ql/annis' => { 'Accept-Language' => 'en-US, en, de-DE' })
58 ->status_is(200)
59 ->text_is("title", "KorAP: Annis QL");
60
Akronf4a7cf42018-01-09 15:58:45 +010061# Check corpus examples
62$t->get_ok('/doc/ql/poliqarp-plus')
63 ->status_is(200)
64 ->text_is('#segments pre.query.tutorial:nth-of-type(1) code', 'Baum');
65
Akron1bd65d92019-07-17 18:26:36 +020066# Check data
67$t->get_ok('/doc/data/annotation' => { 'Accept-Language' => 'en-US, en, de-DE' })
68 ->status_is(200)
Akron9490e3b2019-10-17 12:26:29 +020069 ->text_is('#page-top', 'KorAP: Annotations');
Akron1bd65d92019-07-17 18:26:36 +020070$t->get_ok('/doc/data/annotation' => { 'Accept-Language' => 'de-DE, en-US, en' })
71 ->status_is(200)
Akron9490e3b2019-10-17 12:26:29 +020072 ->text_is('#page-top', 'KorAP: Annotationen');
Akron1bd65d92019-07-17 18:26:36 +020073
Akronf4a7cf42018-01-09 15:58:45 +010074my $app = $t->app;
75
76$app->plugin(
77 'Localize' => {
78 dict => {
79 Q => {
80 newexample => {
81 poliqarp => {
82 simple => '** Beispiel'
83 }
84 }
85 }
86 }
87 }
88);
89
90# Set other example query
91$app->config('Kalamar')->{examplecorpus} = 'newexample';
92
93is($app->loc('Q_poliqarp_simple'), '** Beispiel');
94
95# Check corpus examples
96$t->get_ok('/doc/ql/poliqarp-plus')
97 ->status_is(200)
98 ->text_is('#segments pre.query.tutorial:nth-of-type(1) code', 'Beispiel')
99 ->text_is('#segments pre.query.tutorial:nth-of-type(1) span', '*');
Nils Diewalda898dac2015-05-06 21:04:16 +0000100
Akron07d8de62020-02-04 17:45:40 +0100101# Check API endpoint
102$t->get_ok('/doc/api' => { 'X-Forwarded-Host' => 'korap.ids-mannheim.de' })
103 ->status_is(200)
104 ->text_is('#api-service-uri', 'https://korap.ids-mannheim.de/test/api/v1.0/');
105
106
Nils Diewalda898dac2015-05-06 21:04:16 +0000107done_testing();