From 71e750469d039bc9f7b08e83521d8659c6ea4a6b 2016-08-05 16:06:27
From: Marcin Lulek <mlulek@rhodecode.com>
Date: 2016-08-05 16:06:27
Subject: [PATCH] js tests: simplify js test html

---

diff --git a/backend/src/appenlight/templates/tests/js_airbrake_error.jinja2 b/backend/src/appenlight/templates/tests/js_airbrake_error.jinja2
index 4be6f26..18ed9d4 100644
--- a/backend/src/appenlight/templates/tests/js_airbrake_error.jinja2
+++ b/backend/src/appenlight/templates/tests/js_airbrake_error.jinja2
@@ -1,57 +1,54 @@
-{% extends "/layout.jinja2" %}
-{% from '/reports/reports_small_list_old.jinja2' import render_reports with context %}
-{% block additional_layout_scripts %}
-<script src="/static/scripts/jerrormator.js" type="text/javascript"></script>
-{% endblock %}
-{% block content_class %}{% endblock %}
-{% set layout_disable_menu = True %}
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="utf-8">
 
-{% block additional_styles %}
+    <title>Error test</title>
+    <meta name="description" content="">
+</head>
+<body>
+
+<h1>Error test</h1>
 
 
 <script type="text/javascript">
-  (function(callback) {
-    var ab = document.createElement('script');
-    ab.type = 'text/javascript'; ab.async = true;
-    ab.onload = ab.onreadystatechange = callback;
-    // this should match your copy of the compiled notifier.js or notifier.min.js
-    //ab.src = (("https:" == document.location.protocol) ? "https://ssljscdn" : "http://jscdn") + ".airbrake.io/notifier.min.js";
-    ab.src = "/static/scripts/notifier.js";
-    var p = document.getElementsByTagName('script')[0];
-    p.parentNode.insertBefore(ab, p);
-  }(function () {
-    Airbrake.setGuessFunctionName(true);
-    Airbrake.setHost('api.appenlight.com');
-    console.log(Airbrake)
-    // insert your public api key
-    Airbrake.setKey('1ec3119102154a8caaa307a4495b8558');
-    Airbrake.setEnvironment('production');
-    Airbrake.setErrorDefaults({
-      url: document.URL,
-      component: "",
-      action: "",
-      user: "someuser",
-    });
-  }));
-  // example error
-setTimeout(function(){
-    try {
-        cvxzvcxzcvxv + 263
-    } catch (e) {
-        window.Airbrake.captureException(e);
-    }
-    console.log('foo');
-},2000);
+    (function(callback) {
+        var ab = document.createElement('script');
+        ab.type = 'text/javascript'; ab.async = true;
+        ab.onload = ab.onreadystatechange = callback;
+        // this should match your copy of the compiled notifier.js or notifier.min.js
+        //ab.src = (("https:" == document.location.protocol) ? "https://ssljscdn" : "http://jscdn") + ".airbrake.io/notifier.min.js";
+        ab.src = "/static/scripts/notifier.js";
+        var p = document.getElementsByTagName('script')[0];
+        p.parentNode.insertBefore(ab, p);
+    }(function () {
+        Airbrake.setGuessFunctionName(true);
+        Airbrake.setHost('api.appenlight.com');
+        console.log(Airbrake)
+        // insert your public api key
+        Airbrake.setKey('{{ request.registry.settings.get('appenlight.public_api_key') }}');
+        Airbrake.setEnvironment('production');
+        Airbrake.setErrorDefaults({
+            url: document.URL,
+            component: "",
+            action: "",
+            user: "someuser",
+        });
+    }));
+    // example error
+    setTimeout(function(){
+        try {
+            cvxzvcxzcvxv + 263
+        } catch (e) {
+            window.Airbrake.captureException(e);
+        }
+        console.log('foo');
+    },2000);
 
 
 
 
 </script>
-{% endblock %}
-
-{% block page_title %}
-<h1 class="page-title">{{_('JS')}}</h1>
-{% endblock %}
-{% block content %}
 
-{% endblock %}
+</body>
+</html>
diff --git a/backend/src/appenlight/templates/tests/js_error.jinja2 b/backend/src/appenlight/templates/tests/js_error.jinja2
index 6b30e93..b14bf38 100644
--- a/backend/src/appenlight/templates/tests/js_error.jinja2
+++ b/backend/src/appenlight/templates/tests/js_error.jinja2
@@ -1,53 +1,81 @@
-{% extends "/layout.jinja2" %}
-{% block dojodeps %}
-    deps: ["appenlight","appenlight/sections/test_error"]
-{% endblock %}
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="utf-8">
 
-{% block additional_layout_scripts %}
+    <title>Error test</title>
+    <meta name="description" content="">
+    {% if request.registry.settings.get('appenlight.public_api_key') %}
+        <script type="application/javascript">
+            var initAppEnlight = function () {
+                if(this.readyState!='loading'){
+                    AppEnlight.init({
+                        apiKey:'{{ request.registry.settings.get('appenlight.public_api_key') }}',
+                        windowOnError: 1 // enable to hook to window.onerror
+                    });
+                    // setting request info is completly optional
+                    AppEnlight.setRequestInfo({
+                        server:"{{ request.environ.get('SERVER_NAME', '<unknown>') }}",
+                        {% if request.user %}
+                            username:'{{ request.user.user_name }}',
+                        {% endif %}
+                        ip: "{{ request.environ.get('REMOTE_ADDR', '') }}",
+                        request_id:"{{ request.environ.get('appenlight.request_id', '') }}"
+                    });
 
-{% endblock %}
-{% block content_class %}{% endblock %}
-{% set layout_disable_menu = True %}
+                    AppEnlight.addGlobalTags({framework:'angular', 'language':'javascript'});
+                    AppEnlight.addGlobalExtra({some_key:'on every request'});
 
-{% block additional_styles %}
-    <script type="text/javascript">
+                }
+            };
+            //  load the script asynchroneously
+            var scrElem = document.createElement('script');
+            scrElem.type = 'text/javascript';
+            scrElem.async = true;
+            scrElem.onload = scrElem.onreadystatechange = initAppEnlight;
+            scrElem.src = "//cdn.jsdelivr.net/appenlight/latest/appenlight-client.min.js";
+            scrElem.src = "/static/appenlight/js/appenlight-client.js";
+            var p = document.getElementsByTagName('script')[0];
+            p.parentNode.insertBefore(scrElem, p);
+        </script>
+    {% endif %}
+</head>
+<body>
 
+<h1>Error test</h1>
 
-        function subfunction() {
-            subsubfunction();
-        }
+<script type="text/javascript">
 
-        function subsubfunction() {
-            console.log('A');
+    function subfunction() {
+        subsubfunction();
+    }
 
-            try {
-                1 + nonexistantvar;
-            } catch (exc) {
-                AppEnlight.grabError(exc, {
-                    extra: {foo: 'foo'},
-                    tags: {'bar': 'aa', 'baz': 5}
-                });
-            }
+    function subsubfunction() {
+        console.log('A');
 
-            //var x = 1/0 + fateqtwetew;
-            console.log('B');
+        try {
+            1 + nonexistantvar;
+        } catch (exc) {
+            AppEnlight.grabError(exc, {
+                extra: {foo: 'foo'},
+                tags: {'bar': 'aa', 'baz': 5}
+            });
         }
 
-        setTimeout(function () {
-            subfunction();
-        }, 5000);
+        //var x = 1/0 + fateqtwetew;
+        console.log('B');
+    }
 
+    setTimeout(function () {
+        subfunction();
+    }, 5000);
 
-        setTimeout(function () {
-            brokenCode + 666;
-        }, 3000);
 
-    </script>
-{% endblock %}
+    setTimeout(function () {
+        brokenCode + 666;
+    }, 3000);
 
-{% block page_title %}
-    <h1 class="page-title">{{ _('JS') }}</h1>
-{% endblock %}
-{% block content %}
+</script>
 
-{% endblock %}
+</body>
+</html>
diff --git a/backend/src/appenlight/templates/tests/js_log.jinja2 b/backend/src/appenlight/templates/tests/js_log.jinja2
index 146e5c8..32a5389 100644
--- a/backend/src/appenlight/templates/tests/js_log.jinja2
+++ b/backend/src/appenlight/templates/tests/js_log.jinja2
@@ -1,33 +1,58 @@
-{% extends "/layout.jinja2" %}
-{% block additional_layout_scripts %}
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="utf-8">
+
+    <title>Error test</title>
+    <meta name="description" content="">
+    {% if request.registry.settings.get('appenlight.public_api_key') %}
+        <script type="application/javascript">
+            var initAppEnlight = function () {
+                if(this.readyState!='loading'){
+                    AppEnlight.init({
+                        apiKey:'{{ request.registry.settings.get('appenlight.public_api_key') }}',
+                        windowOnError: 1 // enable to hook to window.onerror
+                    });
+                    // setting request info is completly optional
+                    AppEnlight.setRequestInfo({
+                        server:"{{ request.environ.get('SERVER_NAME', '<unknown>') }}",
+                        {% if request.user %}
+                            username:'{{ request.user.user_name }}',
+                        {% endif %}
+                        ip: "{{ request.environ.get('REMOTE_ADDR', '') }}",
+                        request_id:"{{ request.environ.get('appenlight.request_id', '') }}"
+                    });
+
+                    AppEnlight.addGlobalTags({framework:'angular', 'language':'javascript'});
+                    AppEnlight.addGlobalExtra({some_key:'on every request'});
+
+                }
+            };
+            //  load the script asynchroneously
+            var scrElem = document.createElement('script');
+            scrElem.type = 'text/javascript';
+            scrElem.async = true;
+            scrElem.onload = scrElem.onreadystatechange = initAppEnlight;
+            scrElem.src = "//cdn.jsdelivr.net/appenlight/latest/appenlight-client.min.js";
+            scrElem.src = "/static/appenlight/js/appenlight-client.js";
+            var p = document.getElementsByTagName('script')[0];
+            p.parentNode.insertBefore(scrElem, p);
+        </script>
+    {% endif %}
+</head>
+<body>
+
+<h1>Error test</h1>
 
-{% endblock %}
-
-{% block additional_styles %}
 <script type="text/javascript">
-setTimeout(function(){
-      AppEnlight.log('error',"some test message");
-      AppEnlight.log('info',"some info message");
-      AppEnlight.log('warning',"some warn message");
-},2000);
-
-
-
 
+    setTimeout(function(){
+        AppEnlight.log('error',"some test message");
+        AppEnlight.log('info',"some info message");
+        AppEnlight.log('warning',"some warn message");
+    },2000);
 
 </script>
-{% endblock %}
-
-{% block content_class %}{% endblock %}
-{% set layout_disable_menu = True %}
-
-
-
-{% block page_title %}
-<h1 class="page-title">{{_('JS')}}</h1>
-{% endblock %}
-{% block content %}
-
-
 
-{% endblock %}
+</body>
+</html>