Akron | 9490e3b | 2019-10-17 12:26:29 +0200 | [diff] [blame] | 1 | use Mojo::Base -strict; |
| 2 | use Test::More; |
| 3 | use Test::Mojo; |
Akron | a24af0a | 2021-01-11 17:38:40 +0100 | [diff] [blame] | 4 | use Mojo::File qw/path/; |
Akron | 9490e3b | 2019-10-17 12:26:29 +0200 | [diff] [blame] | 5 | |
| 6 | # Test the documentation |
| 7 | |
| 8 | my $t = Test::Mojo->new('Kalamar'); |
| 9 | |
| 10 | my $app = $t->app; |
| 11 | |
| 12 | is($app->under_construction, '<p>Under Construction!</p>'); |
| 13 | |
Akron | 3cfa26d | 2019-10-24 15:17:34 +0200 | [diff] [blame] | 14 | is($app->embedded_link_to('doc', 'privacy', 'privacy'), '<a class="embedded-link" href="/doc/privacy">privacy</a>'); |
| 15 | is($app->embedded_link_to('doc', 'privacy', 'korap', 'privacy'), '<a class="embedded-link" href="/doc/korap/privacy">privacy</a>'); |
Akron | 9490e3b | 2019-10-17 12:26:29 +0200 | [diff] [blame] | 16 | |
| 17 | |
| 18 | my $c = $app->build_controller; |
| 19 | $c->title('Example'); |
| 20 | is($c->page_title, '<h2 id="page-top">Example</h2>'); |
| 21 | |
Akron | 90be03b | 2020-02-03 16:13:37 +0100 | [diff] [blame] | 22 | $t->get_ok('/' => { 'X-Forwarded-Host' => 'korap2.ids-mannheim.de'}) |
| 23 | ->attr_is('meta[property="og:url"]', 'content', '//korap2.ids-mannheim.de/') |
| 24 | ; |
| 25 | |
Akron | b7b91c5 | 2021-01-27 17:46:52 +0100 | [diff] [blame] | 26 | # Test csp |
Akron | bc6b3f2 | 2021-01-13 14:53:12 +0100 | [diff] [blame] | 27 | $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';!) |
Akron | b7b91c5 | 2021-01-27 17:46:52 +0100 | [diff] [blame] | 31 | ->header_like('Content-Security-Policy', qr!nonce-!) |
| 32 | ->content_like(qr/<script nonce/) |
| 33 | ->content_like(qr/document\.body\.classList\.remove\(\'no-js\'\);/) |
Akron | bc6b3f2 | 2021-01-13 14:53:12 +0100 | [diff] [blame] | 34 | ; |
| 35 | |
Akron | a24af0a | 2021-01-11 17:38:40 +0100 | [diff] [blame] | 36 | # Test additions |
| 37 | $t = Test::Mojo->new('Kalamar' => { |
| 38 | 'Localize' => { |
| 39 | dict => { |
| 40 | en_howToCite => 'Citation Help', |
| 41 | de_howToCite => 'Zitierhilfe', |
| 42 | en_recentCorpusPub => 'Recent publications to refer to DeReKo as linguistic research data', |
| 43 | de_recentCorpusPub => 'Neuere Publikationen zu DeReKo als linguistische Forschungsdatengrundlage', |
| 44 | en_recentToolPub => 'Recent publications to refer to KorAP as a tool for research', |
| 45 | de_recentToolPub => 'Neuere Publikationen zu KorAP als Forschungswerkzeug', |
| 46 | } |
| 47 | }, |
| 48 | 'TagHelpers-ContentBlock' => { |
| 49 | footer => [ |
| 50 | { |
| 51 | inline => '<%= link_to loc("howToCite") => url_for(doc => { page => "faq" })->fragment("howToCite") %>', |
| 52 | position => 75 |
| 53 | } |
| 54 | ], |
| 55 | faq => [ |
| 56 | { |
| 57 | position => 50, |
| 58 | inline => <<'HOWTOCITE' |
| 59 | <section> |
| 60 | <h3 id="howToCite"><%= loc 'howToCite' %></h3> |
| 61 | %= include 'custom/partial/citation' |
| 62 | </section> |
| 63 | HOWTOCITE |
| 64 | } |
| 65 | ] |
| 66 | } |
| 67 | }); |
| 68 | |
| 69 | push @{$t->app->renderer->paths}, path(path(__FILE__)->dirname); |
| 70 | |
| 71 | $t->get_ok('/') |
| 72 | ->text_is('footer a:nth-child(1)', 'Citation Help') |
| 73 | ->attr_like('footer a:nth-child(1)', 'href', qr'/doc/+faq#howToCite'); |
| 74 | |
| 75 | $t->get_ok('/doc//faq#howToCite') |
| 76 | ->text_is('#howToCite', 'Citation Help') |
| 77 | ->text_is('section > section h4', 'Recent publications to refer to DeReKo as linguistic research data') |
| 78 | ; |
| 79 | |
Akron | 9490e3b | 2019-10-17 12:26:29 +0200 | [diff] [blame] | 80 | done_testing; |
| 81 | |
| 82 | 1; |