Akron | ccd9d7d | 2020-09-22 09:51:19 +0200 | [diff] [blame] | 1 | use Mojo::Base -strict; |
| 2 | use Test::More; |
| 3 | use Test::Mojo; |
| 4 | use Mojo::File qw/tempfile/; |
| 5 | |
| 6 | # Test the documentation |
| 7 | my $t = Test::Mojo->new('Kalamar'); |
| 8 | |
| 9 | my $temp = tempfile(); |
| 10 | |
Akron | 889bc20 | 2024-03-15 17:16:55 +0100 | [diff] [blame] | 11 | $temp->spew(<<SCRIPT); |
Akron | ccd9d7d | 2020-09-22 09:51:19 +0200 | [diff] [blame] | 12 | [{ |
Akron | 8dda1c6 | 2021-01-20 10:27:32 +0100 | [diff] [blame] | 13 | "name" : "Export", |
| 14 | "desc" : "Exports Kalamar results", |
| 15 | "embed" : [{ |
| 16 | "panel" : "result", |
| 17 | "title" : "exports KWICs and snippets", |
| 18 | "icon" : "\uf019", |
| 19 | "classes" : ["button-icon","plugin"], |
| 20 | "onClick" : { |
| 21 | "action" : "addWidget", |
| 22 | "template" : "http://localhost:7777/res/export.html" |
Akron | ccd9d7d | 2020-09-22 09:51:19 +0200 | [diff] [blame] | 23 | } |
| 24 | }] |
| 25 | }] |
| 26 | SCRIPT |
| 27 | |
| 28 | $t->app->plugin('Plugins' => { |
| 29 | default_plugins => $temp->to_string |
| 30 | }); |
| 31 | |
| 32 | $t->get_ok('/') |
| 33 | ->text_is('h1 span', 'KorAP - Corpus Analysis Platform') |
Akron | 8dda1c6 | 2021-01-20 10:27:32 +0100 | [diff] [blame] | 34 | ->content_unlike(qr!KorAP\.Plugins\s*=\s*\[!) |
| 35 | ->content_unlike(qr!<script>\/\/<\!\[CDATA\[!) |
| 36 | ->content_like(qr!<span id="kalamar-plugins" data-plugins="/settings/plugin/list\.json"></span>!) |
| 37 | ; |
| 38 | |
| 39 | $t->get_ok('/settings/plugin/list.json') |
| 40 | ->status_is(200) |
| 41 | ->header_is('Content-Type','application/json;charset=UTF-8') |
| 42 | ->content_unlike(qr!KorAP\.Plugins=!) |
| 43 | ->content_like(qr!button-icon!) |
| 44 | ->json_is('/0/embed/0/title','exports KWICs and snippets') |
Akron | ccd9d7d | 2020-09-22 09:51:19 +0200 | [diff] [blame] | 45 | ; |
| 46 | |
| 47 | done_testing; |