blob: c9bce7f167f61761351f5f30af7008e043e6ef50 [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
Akronb7b91c52021-01-27 17:46:52 +010026# Test csp
Akronbc6b3f22021-01-13 14:53:12 +010027$t->get_ok('/')
28 ->header_like('Content-Security-Policy', qr!default-src 'self';!)
29 ->header_like('Content-Security-Policy', qr!media-src 'none';!)
30 ->header_like('Content-Security-Policy', qr!object-src 'self';!)
Akronb7b91c52021-01-27 17:46:52 +010031 ->header_like('Content-Security-Policy', qr!nonce-!)
32 ->content_like(qr/<script nonce/)
33 ->content_like(qr/document\.body\.classList\.remove\(\'no-js\'\);/)
Akron807225b2021-01-13 18:00:13 +010034 ->header_is('X-Content-Type-Options', 'nosniff')
Akron5b6d7272021-01-21 11:26:02 +010035 ->header_is('Access-Control-Allow-Methods','GET, POST, OPTIONS')
Akron88fc41c2021-01-21 15:25:49 +010036 ->header_is('X-Frame-Options', 'sameorigin')
Akronbc6b3f22021-01-13 14:53:12 +010037 ;
38
Akrona24af0a2021-01-11 17:38:40 +010039# Test additions
40$t = Test::Mojo->new('Kalamar' => {
41 'Localize' => {
42 dict => {
43 en_howToCite => 'Citation Help',
44 de_howToCite => 'Zitierhilfe',
45 en_recentCorpusPub => 'Recent publications to refer to DeReKo as linguistic research data',
46 de_recentCorpusPub => 'Neuere Publikationen zu DeReKo als linguistische Forschungsdatengrundlage',
47 en_recentToolPub => 'Recent publications to refer to KorAP as a tool for research',
48 de_recentToolPub => 'Neuere Publikationen zu KorAP als Forschungswerkzeug',
49 }
50 },
51 'TagHelpers-ContentBlock' => {
52 footer => [
53 {
54 inline => '<%= link_to loc("howToCite") => url_for(doc => { page => "faq" })->fragment("howToCite") %>',
55 position => 75
56 }
57 ],
58 faq => [
59 {
60 position => 50,
61 inline => <<'HOWTOCITE'
62<section>
63 <h3 id="howToCite"><%= loc 'howToCite' %></h3>
64%= include 'custom/partial/citation'
65</section>
66HOWTOCITE
67 }
68 ]
69 }
70});
71
72push @{$t->app->renderer->paths}, path(path(__FILE__)->dirname);
73
74$t->get_ok('/')
75 ->text_is('footer a:nth-child(1)', 'Citation Help')
76 ->attr_like('footer a:nth-child(1)', 'href', qr'/doc/+faq#howToCite');
77
78$t->get_ok('/doc//faq#howToCite')
79 ->text_is('#howToCite', 'Citation Help')
80 ->text_is('section > section h4', 'Recent publications to refer to DeReKo as linguistic research data')
81 ;
82
Akron9490e3b2019-10-17 12:26:29 +020083done_testing;
84
851;