blob: abd5e063dd14a83b15567a556d0f3b226d158c36 [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
Akrone40933b2022-12-21 09:56:55 +01007$ENV{KALAMAR_VERSION} = '0.47.999';
8
Akron2ac99312025-01-23 14:11:24 +01009#####################
10# Start Fake server #
11#####################
12my $mount_point = '/realapi/';
13$ENV{KALAMAR_API} = $mount_point;
14
Nils Diewald2fe12e12015-03-06 16:47:06 +000015my $t = Test::Mojo->new('Kalamar');
Akrona0cd5962015-06-29 09:38:00 +020016
Akron2ac99312025-01-23 14:11:24 +010017# Mount fake backend
18# Get the fixture path
19my $fixtures_path = path(Mojo::File->new(__FILE__)->dirname, 'server');
20my $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
Akrona0cd5962015-06-29 09:38:00 +020029$t->app->mode('production');
30
Nils Diewald996aa552014-12-02 03:26:44 +000031$t->get_ok('/')
32 ->status_is(200)
Nils Diewalda748b0e2015-05-19 22:54:06 +000033 ->text_is('title', 'KorAP - Corpus Analysis Platform')
Akron5e992162018-03-22 21:55:15 +010034 ->text_is('h1 span', 'KorAP - Corpus Analysis Platform')
35 ->element_exists('div.intro')
36 ->text_is('div.intro > p > strong', 'KorAP')
Akron690066c2021-01-22 17:39:18 +010037 ->content_unlike(qr!onload!)
Helge0d3630c2024-10-16 17:19:40 +020038 ->text_is('div.intro > p > a.link-guided-tour', 'guided tour')
Akronc84ec1a2024-04-12 13:50:10 +020039 ->text_is('nav > div > a[href=/doc/korap/kalamar]', 'V 0.47.999')
Akron397552c2023-09-18 12:13:33 +020040 ->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]')
Akron5e992162018-03-22 21:55:15 +010043 ;
44
Akron59992122019-10-29 11:28:45 +010045# Only routed when existing
46$t->get_ok('/settings')
47 ->status_is(404);
48
Akron5e992162018-03-22 21:55:15 +010049push @{$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
Akron0e1ed242018-10-11 13:22:00 +020060
Akron5e992162018-03-22 21:55:15 +010061$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')
Akrona17bc5b2018-10-05 13:35:01 +020066 ->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"]')
Akron9b829012024-09-23 14:56:53 +020070 ->element_exists_not('#koralQuery')
Akron25602e12024-11-19 13:24:00 +010071 ->element_exists('aside.invisible')
72 ->element_exists('aside.off')
Akron9b829012024-09-23 14:56:53 +020073 ;
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')
Akron25602e12024-11-19 13:24:00 +010086 ->element_exists('aside.invisible')
87 ->element_exists('aside.off')
Akron2ac99312025-01-23 14:11:24 +010088 ->text_is('#notifications > .notify-error', undef)
Akrona17bc5b2018-10-05 13:35:01 +020089 ;
Nils Diewald5d1ffb42014-05-21 17:45:34 +000090
Akrona0cd5962015-06-29 09:38:00 +020091$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
Akronb01cccc2024-09-30 15:32:43 +020096
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 Diewald5d1ffb42014-05-21 17:45:34 +0000105done_testing();