Make notifications framework CSP compliant

Change-Id: I95411f646053d76219908b91e9f0921c17280c28
diff --git a/t/plugin/notifications.t b/t/plugin/notifications.t
new file mode 100644
index 0000000..9291d01
--- /dev/null
+++ b/t/plugin/notifications.t
@@ -0,0 +1,31 @@
+use Mojolicious;
+use Test::Mojo;
+use Test::More;
+
+my $app = Mojolicious->new;
+my $t = Test::Mojo->new($app);
+
+# Client notifications
+$app->plugin(Notifications => {
+  'Kalamar::Plugin::Notifications' => 1,
+  JSON => 1,
+  HTML => 1
+});
+
+my $c = $app->build_controller;
+
+is($c->notifications('Kalamar::Plugin::Notifications'), '');
+
+$c->notify(warn => 'Error');
+$c->notify('warn' => 20, 'Hmmm');
+$c->notify('success' => {src => 'Kustvakt'}, 'Hmmm');
+
+my $n = $c->notifications('Kalamar::Plugin::Notifications');
+
+like($n, qr!^<div id="notifications">.*</div>$!s);
+like($n, qr!<div class="notify notify-warn" data-type="warn">Error</div>!);
+like($n, qr!<div class="notify notify-warn" data-type="warn">Hmmm</div>!);
+like($n, qr!<div class="notify notify-success" data-type="success" data-src="Kustvakt">Hmmm</div>!);
+
+done_testing;
+__END__
diff --git a/t/query.t b/t/query.t
index 73e488c..227dbf1 100644
--- a/t/query.t
+++ b/t/query.t
@@ -194,19 +194,19 @@
 # Query with failing parameters
 $t->get_ok('/?q=fantastisch&ql=Fabelsprache')
   ->status_is(400)
-  ->text_is('noscript div.notify-error', 'Parameter "ql" invalid')
+  ->text_is('#notifications div.notify-error', 'Parameter "ql" invalid')
   ->element_exists('#search')
-  ->element_count_is('noscript div.notify-error', 1)
+  ->element_count_is('#notifications div.notify-error', 1)
   ;
 $t->get_ok('/?q=fantastisch&cutoff=no')
   ->status_is(400)
-  ->text_is('noscript div.notify-error', 'Parameter "cutoff" invalid')
-  ->element_count_is('noscript div.notify-error', 1)
+  ->text_is('#notifications div.notify-error', 'Parameter "cutoff" invalid')
+  ->element_count_is('#notifications div.notify-error', 1)
   ;
 $t->get_ok('/?q=fantastisch&p=hui&o=hui&count=-8')
   ->status_is(400)
-  ->text_like('noscript div.notify-error', qr!Parameter ".+?" invalid!)
-  ->element_count_is('noscript div.notify-error', 3)
+  ->text_like('#notifications div.notify-error', qr!Parameter ".+?" invalid!)
+  ->element_count_is('#notifications div.notify-error', 3)
   ;
 
 # Query too long
@@ -214,20 +214,20 @@
 $t->get_ok('/?q=' . $long_query)
   ->status_is(400)
   ->text_is('#error','')
-  ->text_like('noscript div.notify-error', qr!Parameter ".+?" invalid!)
+  ->text_like('#notifications div.notify-error', qr!Parameter ".+?" invalid!)
   ;
 
 # Query with timeout
 $t->get_ok('/?q=timeout')
   ->status_is(200)
-  ->text_like('noscript div.notify-warn', qr!Response time exceeded!)
+  ->text_like('#notifications div.notify-warn', qr!Response time exceeded!)
   ->text_is('#total-results', '> 4,274,841');
 ;
 
 # Do not cache
 $t->get_ok('/?q=timeout')
   ->status_is(200)
-  # ->text_like('noscript div.notify-warning', qr!Response time exceeded!)
+  # ->text_like('#notifications div.notify-warning', qr!Response time exceeded!)
   ->element_exists("input#cq")
   ->element_exists_not("input#cq[value]")
   ->text_is('#total-results', '> 4,274,841');