Nils Diewald | 5d1ffb4 | 2014-05-21 17:45:34 +0000 | [diff] [blame] | 1 | use Mojo::Base -strict; |
Nils Diewald | 5d1ffb4 | 2014-05-21 17:45:34 +0000 | [diff] [blame] | 2 | use Test::More; |
| 3 | use Test::Mojo; |
Akron | 5e99216 | 2018-03-22 21:55:15 +0100 | [diff] [blame] | 4 | use Mojo::File qw/path/; |
Akron | a17bc5b | 2018-10-05 13:35:01 +0200 | [diff] [blame] | 5 | use utf8; |
Nils Diewald | 5d1ffb4 | 2014-05-21 17:45:34 +0000 | [diff] [blame] | 6 | |
Akron | e40933b | 2022-12-21 09:56:55 +0100 | [diff] [blame] | 7 | $ENV{KALAMAR_VERSION} = '0.47.999'; |
| 8 | |
Akron | 2ac9931 | 2025-01-23 14:11:24 +0100 | [diff] [blame^] | 9 | ##################### |
| 10 | # Start Fake server # |
| 11 | ##################### |
| 12 | my $mount_point = '/realapi/'; |
| 13 | $ENV{KALAMAR_API} = $mount_point; |
| 14 | |
Nils Diewald | 2fe12e1 | 2015-03-06 16:47:06 +0000 | [diff] [blame] | 15 | my $t = Test::Mojo->new('Kalamar'); |
Akron | a0cd596 | 2015-06-29 09:38:00 +0200 | [diff] [blame] | 16 | |
Akron | 2ac9931 | 2025-01-23 14:11:24 +0100 | [diff] [blame^] | 17 | # Mount fake backend |
| 18 | # Get the fixture path |
| 19 | my $fixtures_path = path(Mojo::File->new(__FILE__)->dirname, 'server'); |
| 20 | my $fake_backend = $t->app->plugin( |
| 21 | Mount => { |
| 22 | $mount_point => |
| 23 | $fixtures_path->child('mock.pl') |
| 24 | } |
| 25 | ); |
| 26 | # Configure fake backend |
| 27 | $fake_backend->pattern->defaults->{app}->log($t->app->log); |
| 28 | |
Akron | a0cd596 | 2015-06-29 09:38:00 +0200 | [diff] [blame] | 29 | $t->app->mode('production'); |
| 30 | |
Nils Diewald | 996aa55 | 2014-12-02 03:26:44 +0000 | [diff] [blame] | 31 | $t->get_ok('/') |
| 32 | ->status_is(200) |
Nils Diewald | a748b0e | 2015-05-19 22:54:06 +0000 | [diff] [blame] | 33 | ->text_is('title', 'KorAP - Corpus Analysis Platform') |
Akron | 5e99216 | 2018-03-22 21:55:15 +0100 | [diff] [blame] | 34 | ->text_is('h1 span', 'KorAP - Corpus Analysis Platform') |
| 35 | ->element_exists('div.intro') |
| 36 | ->text_is('div.intro > p > strong', 'KorAP') |
Akron | 690066c | 2021-01-22 17:39:18 +0100 | [diff] [blame] | 37 | ->content_unlike(qr!onload!) |
Helge | 0d3630c | 2024-10-16 17:19:40 +0200 | [diff] [blame] | 38 | ->text_is('div.intro > p > a.link-guided-tour', 'guided tour') |
Akron | c84ec1a | 2024-04-12 13:50:10 +0200 | [diff] [blame] | 39 | ->text_is('nav > div > a[href=/doc/korap/kalamar]', 'V 0.47.999') |
Akron | 397552c | 2023-09-18 12:13:33 +0200 | [diff] [blame] | 40 | ->element_exists('select#ql-field option[value=poliqarp]') |
| 41 | ->element_exists('select#ql-field option[value=cqp]') |
| 42 | ->element_exists_not('select#ql-field option[value=noliqart]') |
Akron | 5e99216 | 2018-03-22 21:55:15 +0100 | [diff] [blame] | 43 | ; |
| 44 | |
Akron | 5999212 | 2019-10-29 11:28:45 +0100 | [diff] [blame] | 45 | # Only routed when existing |
| 46 | $t->get_ok('/settings') |
| 47 | ->status_is(404); |
| 48 | |
Akron | 5e99216 | 2018-03-22 21:55:15 +0100 | [diff] [blame] | 49 | push @{$t->app->renderer->paths}, path(path(__FILE__)->dirname); |
| 50 | |
| 51 | $t->app->plugin(Localize => { |
| 52 | dict => { |
| 53 | Template => { |
| 54 | intro => 'custom/intro' |
| 55 | } |
| 56 | }, |
| 57 | override => 1 |
| 58 | }); |
| 59 | |
Akron | 0e1ed24 | 2018-10-11 13:22:00 +0200 | [diff] [blame] | 60 | |
Akron | 5e99216 | 2018-03-22 21:55:15 +0100 | [diff] [blame] | 61 | $t->get_ok('/') |
| 62 | ->status_is(200) |
| 63 | ->text_is('title', 'KorAP - Corpus Analysis Platform') |
| 64 | ->text_is('h1 span', 'KorAP - Corpus Analysis Platform') |
| 65 | ->element_exists('div.intro') |
Akron | a17bc5b | 2018-10-05 13:35:01 +0200 | [diff] [blame] | 66 | ->text_is('div.intro h2', 'This is a custom intro page!') |
| 67 | ->element_exists('meta[name="DC.description"][content="KorAP - Corpus Analysis Platform"]') |
| 68 | ->element_exists('meta[name="keywords"][content^="KorAP"]') |
| 69 | ->element_exists('body[itemscope][itemtype="http://schema.org/WebApplication"]') |
Akron | 9b82901 | 2024-09-23 14:56:53 +0200 | [diff] [blame] | 70 | ->element_exists_not('#koralQuery') |
Akron | 25602e1 | 2024-11-19 13:24:00 +0100 | [diff] [blame] | 71 | ->element_exists('aside.invisible') |
| 72 | ->element_exists('aside.off') |
Akron | 9b82901 | 2024-09-23 14:56:53 +0200 | [diff] [blame] | 73 | ; |
| 74 | |
| 75 | $t->get_ok('/?cq=corpusSigle%3DGOE') |
| 76 | ->status_is(200) |
| 77 | ->text_is('title', 'KorAP - Corpus Analysis Platform') |
| 78 | ->text_is('h1 span', 'KorAP - Corpus Analysis Platform') |
| 79 | ->element_exists_not('#notifications div.notify') |
| 80 | ->element_exists('div.intro') |
| 81 | ->text_is('div.intro h2', 'This is a custom intro page!') |
| 82 | ->element_exists('meta[name="DC.description"][content="KorAP - Corpus Analysis Platform"]') |
| 83 | ->element_exists('meta[name="keywords"][content^="KorAP"]') |
| 84 | ->element_exists('body[itemscope][itemtype="http://schema.org/WebApplication"]') |
| 85 | ->element_exists('#koralQuery') |
Akron | 25602e1 | 2024-11-19 13:24:00 +0100 | [diff] [blame] | 86 | ->element_exists('aside.invisible') |
| 87 | ->element_exists('aside.off') |
Akron | 2ac9931 | 2025-01-23 14:11:24 +0100 | [diff] [blame^] | 88 | ->text_is('#notifications > .notify-error', undef) |
Akron | a17bc5b | 2018-10-05 13:35:01 +0200 | [diff] [blame] | 89 | ; |
Nils Diewald | 5d1ffb4 | 2014-05-21 17:45:34 +0000 | [diff] [blame] | 90 | |
Akron | a0cd596 | 2015-06-29 09:38:00 +0200 | [diff] [blame] | 91 | $t->get_ok('/huhuhuhuhu') |
| 92 | ->status_is(404) |
| 93 | ->text_is('title', 'KorAP: 404 - Page not found') |
| 94 | ->text_is('h1 span', 'KorAP: 404 - Page not found'); |
| 95 | |
Akron | b01cccc | 2024-09-30 15:32:43 +0200 | [diff] [blame] | 96 | |
| 97 | $t->get_ok('/doc/off') |
| 98 | ->status_is(200) |
| 99 | ->text_is('title', 'KorAP - Corpus Analysis Platform') |
| 100 | ->text_is('h1 span', 'KorAP - Corpus Analysis Platform') |
| 101 | ->attr_is('aside', 'class',' off') |
| 102 | ; |
| 103 | |
| 104 | |
Nils Diewald | 5d1ffb4 | 2014-05-21 17:45:34 +0000 | [diff] [blame] | 105 | done_testing(); |