blob: 55f6518faf0f8c9728d1ee157ff72a0888e8e7d9 [file] [log] [blame]
Akron9490e3b2019-10-17 12:26:29 +02001use Mojo::Base -strict;
2use Test::More;
3use Test::Mojo;
Akrona24af0a2021-01-11 17:38:40 +01004use Mojo::File qw/path/;
Akron9490e3b2019-10-17 12:26:29 +02005
6# Test the documentation
7
8my $t = Test::Mojo->new('Kalamar');
9
10my $app = $t->app;
11
12is($app->under_construction, '<p>Under Construction!</p>');
13
Akron3cfa26d2019-10-24 15:17:34 +020014is($app->embedded_link_to('doc', 'privacy', 'privacy'), '<a class="embedded-link" href="/doc/privacy">privacy</a>');
15is($app->embedded_link_to('doc', 'privacy', 'korap', 'privacy'), '<a class="embedded-link" href="/doc/korap/privacy">privacy</a>');
Akron9490e3b2019-10-17 12:26:29 +020016
17
18my $c = $app->build_controller;
19$c->title('Example');
20is($c->page_title, '<h2 id="page-top">Example</h2>');
21
Akron90be03b2020-02-03 16:13:37 +010022$t->get_ok('/' => { 'X-Forwarded-Host' => 'korap2.ids-mannheim.de'})
23 ->attr_is('meta[property="og:url"]', 'content', '//korap2.ids-mannheim.de/')
24 ;
25
Akronbc6b3f22021-01-13 14:53:12 +010026$t->get_ok('/')
27 ->header_like('Content-Security-Policy', qr!default-src 'self';!)
28 ->header_like('Content-Security-Policy', qr!media-src 'none';!)
29 ->header_like('Content-Security-Policy', qr!object-src 'self';!)
30 ;
31
Akrona24af0a2021-01-11 17:38:40 +010032# Test additions
33$t = Test::Mojo->new('Kalamar' => {
34 'Localize' => {
35 dict => {
36 en_howToCite => 'Citation Help',
37 de_howToCite => 'Zitierhilfe',
38 en_recentCorpusPub => 'Recent publications to refer to DeReKo as linguistic research data',
39 de_recentCorpusPub => 'Neuere Publikationen zu DeReKo als linguistische Forschungsdatengrundlage',
40 en_recentToolPub => 'Recent publications to refer to KorAP as a tool for research',
41 de_recentToolPub => 'Neuere Publikationen zu KorAP als Forschungswerkzeug',
42 }
43 },
44 'TagHelpers-ContentBlock' => {
45 footer => [
46 {
47 inline => '<%= link_to loc("howToCite") => url_for(doc => { page => "faq" })->fragment("howToCite") %>',
48 position => 75
49 }
50 ],
51 faq => [
52 {
53 position => 50,
54 inline => <<'HOWTOCITE'
55<section>
56 <h3 id="howToCite"><%= loc 'howToCite' %></h3>
57%= include 'custom/partial/citation'
58</section>
59HOWTOCITE
60 }
61 ]
62 }
63});
64
65push @{$t->app->renderer->paths}, path(path(__FILE__)->dirname);
66
67$t->get_ok('/')
68 ->text_is('footer a:nth-child(1)', 'Citation Help')
69 ->attr_like('footer a:nth-child(1)', 'href', qr'/doc/+faq#howToCite');
70
71$t->get_ok('/doc//faq#howToCite')
72 ->text_is('#howToCite', 'Citation Help')
73 ->text_is('section > section h4', 'Recent publications to refer to DeReKo as linguistic research data')
74 ;
75
Akron9490e3b2019-10-17 12:26:29 +020076done_testing;
77
781;