| Akron | c8ffbac | 2026-07-22 17:58:54 +0200 | [diff] [blame] | 1 | use Mojo::Base -strict; |
| 2 | use Test::More; |
| 3 | use Test::Mojo; |
| 4 | use Mojo::File qw/curfile/; |
| 5 | |
| 6 | my $t = Test::Mojo->new('Kalamar'); |
| 7 | |
| 8 | ok($t->app->renderer->handlers->{md}, 'md handler registered in Kalamar'); |
| 9 | |
| 10 | ok($t->app->renderer->helpers->{markdown}, 'markdown helper registered in Kalamar'); |
| 11 | |
| 12 | push @{$t->app->renderer->paths}, curfile->dirname; |
| 13 | |
| 14 | $t->get_ok('/doc/md_test') |
| 15 | ->status_is(200) |
| 16 | ->element_exists('html head title') |
| 17 | ->content_like(qr/<h4>/) |
| 18 | ->content_like(qr/<table>/) |
| 19 | ->content_like(qr/<strong>test page<\/strong>/) |
| 20 | ->content_like(qr/class="query tutorial"/) |
| 21 | ; |
| 22 | |
| 23 | # Markdown external link uses ext_link_to (target="_top") |
| 24 | $t->get_ok('/doc/md_test') |
| 25 | ->content_like(qr/<a href="https:\/\/github\.com\/KorAP\/Kalamar" target="_top">/) |
| 26 | ; |
| 27 | |
| 28 | # Markdown internal link uses undef |
| 29 | $t->get_ok('/doc/md_test') |
| 30 | ->content_like(qr/<a href="\/doc\/faq">FAQ<\/a>/) |
| 31 | ; |
| 32 | |
| 33 | # Localized custom pages: a German visitor gets custom/de/doc/md_test, |
| 34 | # an English one falls back to the default custom/doc/md_test. |
| 35 | $t->get_ok('/doc/md_test' => { 'Accept-Language' => 'de-DE, en-US, en' }) |
| 36 | ->status_is(200) |
| 37 | ->content_like(qr/Testseite/) |
| 38 | ->content_unlike(qr/test page/) |
| 39 | ; |
| 40 | |
| 41 | $t->get_ok('/doc/md_test' => { 'Accept-Language' => 'en-US, en, de-DE' }) |
| 42 | ->status_is(200) |
| 43 | ->content_like(qr/test page/) |
| 44 | ->content_unlike(qr/Testseite/) |
| 45 | ; |
| 46 | |
| 47 | done_testing; |