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>'); |
Marc Kupietz | fcadda6 | 2021-09-08 09:06:25 +0200 | [diff] [blame] | 15 | is($app->embedded_link_to('doc', 'privacy', 'development', 'privacy'), '<a class="embedded-link" href="/doc/development/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-!) |
Akron | aef5cf2 | 2021-06-21 11:45:54 +0200 | [diff] [blame] | 32 | ->header_like('Content-Security-Policy', qr!frame-ancestors 'self';!) |
Akron | b7b91c5 | 2021-01-27 17:46:52 +0100 | [diff] [blame] | 33 | ->content_like(qr/<script nonce/) |
| 34 | ->content_like(qr/document\.body\.classList\.remove\(\'no-js\'\);/) |
Akron | 807225b | 2021-01-13 18:00:13 +0100 | [diff] [blame] | 35 | ->header_is('X-Content-Type-Options', 'nosniff') |
Akron | 5b6d727 | 2021-01-21 11:26:02 +0100 | [diff] [blame] | 36 | ->header_is('Access-Control-Allow-Methods','GET, POST, OPTIONS') |
Akron | 52b32d0 | 2021-01-21 17:37:19 +0100 | [diff] [blame] | 37 | ->header_is('X-XSS-Protection', '1; mode=block') |
Akron | bc6b3f2 | 2021-01-13 14:53:12 +0100 | [diff] [blame] | 38 | ; |
| 39 | |
Akron | a24af0a | 2021-01-11 17:38:40 +0100 | [diff] [blame] | 40 | # Test additions |
| 41 | $t = Test::Mojo->new('Kalamar' => { |
| 42 | 'Localize' => { |
| 43 | dict => { |
| 44 | en_howToCite => 'Citation Help', |
| 45 | de_howToCite => 'Zitierhilfe', |
| 46 | en_recentCorpusPub => 'Recent publications to refer to DeReKo as linguistic research data', |
| 47 | de_recentCorpusPub => 'Neuere Publikationen zu DeReKo als linguistische Forschungsdatengrundlage', |
Marc Kupietz | 98a935d | 2023-09-01 16:31:10 +0200 | [diff] [blame] | 48 | en_recentToolPub => 'Recent publications to refer to KorAP as a research tool', |
Akron | a24af0a | 2021-01-11 17:38:40 +0100 | [diff] [blame] | 49 | de_recentToolPub => 'Neuere Publikationen zu KorAP als Forschungswerkzeug', |
Akron | c417749 | 2023-11-29 08:35:37 +0100 | [diff] [blame] | 50 | title_addon => 'Test', |
Akron | a24af0a | 2021-01-11 17:38:40 +0100 | [diff] [blame] | 51 | } |
| 52 | }, |
| 53 | 'TagHelpers-ContentBlock' => { |
| 54 | footer => [ |
| 55 | { |
| 56 | inline => '<%= link_to loc("howToCite") => url_for(doc => { page => "faq" })->fragment("howToCite") %>', |
| 57 | position => 75 |
| 58 | } |
| 59 | ], |
| 60 | faq => [ |
| 61 | { |
| 62 | position => 50, |
| 63 | inline => <<'HOWTOCITE' |
| 64 | <section> |
| 65 | <h3 id="howToCite"><%= loc 'howToCite' %></h3> |
| 66 | %= include 'custom/partial/citation' |
| 67 | </section> |
| 68 | HOWTOCITE |
| 69 | } |
| 70 | ] |
| 71 | } |
| 72 | }); |
| 73 | |
| 74 | push @{$t->app->renderer->paths}, path(path(__FILE__)->dirname); |
| 75 | |
| 76 | $t->get_ok('/') |
| 77 | ->text_is('footer a:nth-child(1)', 'Citation Help') |
| 78 | ->attr_like('footer a:nth-child(1)', 'href', qr'/doc/+faq#howToCite'); |
| 79 | |
| 80 | $t->get_ok('/doc//faq#howToCite') |
| 81 | ->text_is('#howToCite', 'Citation Help') |
| 82 | ->text_is('section > section h4', 'Recent publications to refer to DeReKo as linguistic research data') |
| 83 | ; |
| 84 | |
Akron | c417749 | 2023-11-29 08:35:37 +0100 | [diff] [blame] | 85 | $t->get_ok('/') |
| 86 | ->text_is('title', 'KorAP-Test - Corpus Analysis Platform') |
| 87 | ->text_is('h1 > span', 'KorAP-Test - Corpus Analysis Platform') |
| 88 | ->text_is('div.logoaddon', 'Test') |
| 89 | ; |
| 90 | |
Akron | 459bf58 | 2023-11-03 10:17:11 +0100 | [diff] [blame] | 91 | like($app->korap_maintenance('2023-10-03','13:00','15:00'), qr!<time datetime="2023-10-03">!); |
| 92 | like($app->korap_maintenance('2023-10-03','13:00','15:00'), qr!Tuesday, 3rd October 2023!); |
| 93 | like($app->korap_maintenance('2023-10-03','13:00','15:00'), qr!Maintenance 13:00 - 15:00 o'clock!); |
| 94 | like($app->korap_maintenance('2023-10-03','13:00','15:00'), qr!Due to maintenance work the service will be interrupted\.!); |
| 95 | |
| 96 | |
| 97 | $c = $app->build_controller; |
| 98 | $c->req->headers->accept_language('de-DE, en-US, en'); |
| 99 | $c->app($app); |
| 100 | |
| 101 | like($c->korap_maintenance('2023-10-03','13:00','15:00'), qr!<time datetime="2023-10-03">!); |
| 102 | like($c->korap_maintenance('2023-10-03','13:00','15:00'), qr!Dienstag, 3\. Oktober 2023!); |
| 103 | like($c->korap_maintenance('2023-10-03','13:00','15:00'), qr!Wartungsfenster 13:00 - 15:00 Uhr!); |
| 104 | like($c->korap_maintenance('2023-10-03','13:00','15:00'), qr!Aufgrund von Wartungsarbeiten wird es zu Unterbrechungen des Dienstes kommen\.!); |
| 105 | |
| 106 | |
Akron | 9490e3b | 2019-10-17 12:26:29 +0200 | [diff] [blame] | 107 | done_testing; |
| 108 | |
| 109 | 1; |