blob: fd48b4317d3a7ba9ac6f896b129104495ff94a62 [file] [log] [blame]
Nils Diewald5d1ffb42014-05-21 17:45:34 +00001use Mojo::Base -strict;
Nils Diewald5d1ffb42014-05-21 17:45:34 +00002use Test::More;
3use Test::Mojo;
Akron5e992162018-03-22 21:55:15 +01004use Mojo::File qw/path/;
Akrona17bc5b2018-10-05 13:35:01 +02005use utf8;
Nils Diewald5d1ffb42014-05-21 17:45:34 +00006
Nils Diewald2fe12e12015-03-06 16:47:06 +00007my $t = Test::Mojo->new('Kalamar');
Akrona0cd5962015-06-29 09:38:00 +02008
9$t->app->mode('production');
10
Nils Diewald996aa552014-12-02 03:26:44 +000011$t->get_ok('/')
12 ->status_is(200)
Nils Diewalda748b0e2015-05-19 22:54:06 +000013 ->text_is('title', 'KorAP - Corpus Analysis Platform')
Akron5e992162018-03-22 21:55:15 +010014 ->text_is('h1 span', 'KorAP - Corpus Analysis Platform')
15 ->element_exists('div.intro')
16 ->text_is('div.intro > p > strong', 'KorAP')
17 ;
18
19push @{$t->app->renderer->paths}, path(path(__FILE__)->dirname);
20
21$t->app->plugin(Localize => {
22 dict => {
23 Template => {
24 intro => 'custom/intro'
25 }
26 },
27 override => 1
28});
29
30$t->get_ok('/')
31 ->status_is(200)
32 ->text_is('title', 'KorAP - Corpus Analysis Platform')
33 ->text_is('h1 span', 'KorAP - Corpus Analysis Platform')
34 ->element_exists('div.intro')
Akrona17bc5b2018-10-05 13:35:01 +020035 ->text_is('div.intro h2', 'This is a custom intro page!')
36 ->element_exists('meta[name="DC.description"][content="KorAP - Corpus Analysis Platform"]')
37 ->element_exists('meta[name="keywords"][content^="KorAP"]')
38 ->element_exists('body[itemscope][itemtype="http://schema.org/WebApplication"]')
39 ;
Nils Diewald5d1ffb42014-05-21 17:45:34 +000040
Akrona0cd5962015-06-29 09:38:00 +020041$t->get_ok('/huhuhuhuhu')
42 ->status_is(404)
43 ->text_is('title', 'KorAP: 404 - Page not found')
44 ->text_is('h1 span', 'KorAP: 404 - Page not found');
45
Akrona17bc5b2018-10-05 13:35:01 +020046$t->get_ok('/?q=hui')
47 ->status_is(200)
48 ->text_is('title', 'KorAP: Find »hui« with Poliqarp')
49 ->element_exists('meta[name="DC.title"][content="KorAP: Find »hui« with Poliqarp"]')
50 ->element_exists('body[itemscope][itemtype="http://schema.org/SearchResultsPage"]')
51 ;
52
Nils Diewald5d1ffb42014-05-21 17:45:34 +000053done_testing();