Akron | 4c33c62 | 2018-11-12 13:43:27 +0100 | [diff] [blame] | 1 | use Mojo::Base -strict; |
| 2 | use Test::More; |
| 3 | use Test::Mojo; |
| 4 | |
| 5 | # Test the documentation |
| 6 | my $t = Test::Mojo->new('Kalamar'); |
| 7 | |
| 8 | $t->app->plugin('Piwik' => { |
| 9 | url => 'https://piwik.korap.ids-mannheim.de/', |
| 10 | site_id => 1, |
| 11 | embed => 1 |
| 12 | }); |
| 13 | |
| 14 | # Load piwik |
| 15 | $t->app->plugin('Kalamar::Plugin::Piwik'); |
| 16 | |
| 17 | $t->get_ok('/doc/faq') |
| 18 | ->status_is(200) |
| 19 | ->text_like('section[name=piwik-opt-out] h3', qr!can I opt-out!) |
| 20 | ->element_exists('section[name=piwik-opt-out] iframe') |
| 21 | ->content_like(qr!var _paq!) |
| 22 | ->content_like(qr!window\.addEventListener\('korapRequest!) |
Akron | b89863a | 2018-11-13 16:43:59 +0100 | [diff] [blame^] | 23 | ->content_like(qr!setDocumentTitle!) |
| 24 | ->content_like(qr!setCustomUrl!) |
| 25 | ->content_like(qr!trackPageView!) |
Akron | 4c33c62 | 2018-11-12 13:43:27 +0100 | [diff] [blame] | 26 | ; |
| 27 | |
Akron | 7c75841 | 2018-11-13 14:17:00 +0100 | [diff] [blame] | 28 | # No embedding |
| 29 | $t->app->plugin('Piwik' => { |
| 30 | url => 'https://piwik.korap.ids-mannheim.de/', |
| 31 | site_id => 1, |
| 32 | embed => 0 |
| 33 | }); |
| 34 | |
| 35 | $t->get_ok('/doc/faq') |
| 36 | ->status_is(200) |
| 37 | ->text_like('section[name=piwik-opt-out] h3', qr!can I opt-out!) |
| 38 | ->element_exists_not('section[name=piwik-opt-out] iframe') |
| 39 | ->content_unlike(qr!var _paq!) |
| 40 | ->content_unlike(qr!window\.addEventListener\('korapRequest!) |
| 41 | ; |
| 42 | |
| 43 | |
Akron | 4c33c62 | 2018-11-12 13:43:27 +0100 | [diff] [blame] | 44 | done_testing(); |