LP#1775719 Modify array check for Phantomjs; reduce logging;
authorBill Erickson <berickxx@gmail.com>
Thu, 9 Aug 2018 14:20:54 +0000 (10:20 -0400)
committerKathy Lussier <klussier@masslnc.org>
Fri, 10 Aug 2018 14:22:20 +0000 (10:22 -0400)
PhantomJS doesn't support the handy [1,2,3].includes(1) function, so
replace it with the tried-and-true indexOf();

Avoid logging errors on failure to connect to the shared offline worker
when running within phantomjs.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/web/js/ui/default/staff/services/lovefield.js

index cfd787f..561f900 100644 (file)
@@ -33,7 +33,10 @@ angular.module('egCoreMod')
         }
 
         service.worker.onerror = function(err) {
-            console.error('Error loading shared worker', err);
+            // avoid spamming unit test runner on failure to connect.
+            if (!navigator.userAgent.match(/PhantomJS/)) {
+                console.error('Error loading shared worker', err);
+            }
             service.cannotConnect = true;
         }
 
@@ -108,7 +111,7 @@ angular.module('egCoreMod')
     // Create and connect to the give schema
     service.connectToSchema = function(schema) {
 
-        if (service.connectedSchemas.includes(schema)) {
+        if (service.connectedSchemas.indexOf(schema) >= 0) {
             // already connected
             return $q.when();
         }