فهرست منبع

HUE-3849 [editor] Sample popup does not fail gracefully when failing to load a table

Johan Ahlen 9 سال پیش
والد
کامیت
81ca89c

+ 6 - 1
desktop/core/src/desktop/static/desktop/js/apiHelper.js

@@ -132,7 +132,12 @@
    * @returns {boolean} - True if actually an error
    */
   ApiHelper.prototype.successResponseIsError = function (response) {
-    return typeof response !== 'undefined' && (response.status === -1 || response.status === 500 || response.code === 503 || response.code === 500);
+    return typeof response !== 'undefined' && (
+        typeof response.traceback !== 'undefined' ||
+        response.status === -1 ||
+        response.status === 500 ||
+        response.code === 503 ||
+        response.code === 500);
   };
 
   /**

+ 26 - 0
desktop/core/src/desktop/static/desktop/spec/apiHelperSpec.js

@@ -28,5 +28,31 @@ define([
       var otherHelper = ApiHelper.getInstance();
       expect(subject == otherHelper).toBeTruthy();
     });
+
+    describe("success response that is actually an error", function () {
+      it("should not determine that a success response is an error response if status is 0", function () {
+        expect(subject.successResponseIsError({ status: 0 })).toBeFalsy();
+      });
+
+      it("should determine that a success response is an error response if status is -1", function () {
+        expect(subject.successResponseIsError({ status: -1 })).toBeTruthy();
+      });
+
+      it("should determine that a success response is an error response if status is 500", function () {
+        expect(subject.successResponseIsError({ status: 500 })).toBeTruthy();
+      });
+
+      it("should determine that a success response is an error response if code is 500", function () {
+        expect(subject.successResponseIsError({ code: 500 })).toBeTruthy();
+      });
+
+      it("should determine that a success response is an error response if code is 503", function () {
+        expect(subject.successResponseIsError({ code: 503 })).toBeTruthy();
+      });
+
+      it("should determine that a success response is an error response if it contains traceback", function () {
+        expect(subject.successResponseIsError({ traceback: {} })).toBeTruthy();
+      });
+    });
   });
 });