DEV: Do not re-throw in popupAjaxError (#13462)

DEV: Do not re-throw in popupAjaxError (#13462)

Effectively reverts Don't swallow errors once they've been popped up · discourse/discourse@3ddc33b · GitHub

Makes the failure states testable; see the uncommented test.

I don’t think we’re re-catching these errors anyway?

update: We did in a single instance in discourse-code-review but it wasn’t really intentional and I fixed it in DEV: Asyncify by CvX · Pull Request #73 · discourse/discourse-code-review · GitHub

diff --git a/app/assets/javascripts/discourse/app/lib/ajax-error.js b/app/assets/javascripts/discourse/app/lib/ajax-error.js
index 0f3feba..4796e62 100644
--- a/app/assets/javascripts/discourse/app/lib/ajax-error.js
+++ b/app/assets/javascripts/discourse/app/lib/ajax-error.js
@@ -64,13 +64,5 @@ export function throwAjaxError(undoCallback) {
 }
 
 export function popupAjaxError(error) {
-  if (error && error._discourse_displayed) {
-    return;
-  }
   bootbox.alert(extractError(error));
-
-  error._discourse_displayed = true;
-
-  // We re-throw in a catch to not swallow the exception
-  throw error;
 }
diff --git a/app/assets/javascripts/discourse/tests/acceptance/group-manage-email-settings-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-manage-email-settings-test.js
index 7cdbae5..f021f0b 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/group-manage-email-settings-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/group-manage-email-settings-test.js
@@ -333,38 +333,38 @@ acceptance(
   }
 );
 
-// acceptance(
-//   "Managing Group Email Settings - SMTP and IMAP Enabled - Email Test Invalid",
-//   function (needs) {
-//     needs.user();
-//     needs.settings({ enable_smtp: true, enable_imap: true });
-
-//     needs.pretender((server, helper) => {
-//       server.post("/groups/47/test_email_settings", () => {
-//         return helper.response(400, {
-//           success: false,
-//           errors: [
-//             "There was an issue with the SMTP credentials provided, check the username and password and try again.",
-//           ],
-//         });
-//       });
-//     });
-
-//     test("enabling IMAP, testing, and saving", async function (assert) {
-//       await visit("/g/discourse/manage/email");
-
-//       await click("#enable_smtp");
-//       await click("#prefill_smtp_gmail");
-//       await fillIn('input[name="username"]', "myusername@gmail.com");
-//       await fillIn('input[name="password"]', "password@gmail.com");
-//       await click(".test-smtp-settings");
-
-//       assert.equal(
-//         query(".modal-body").innerText,
-//         "There was an issue with the SMTP credentials provided, check the username and password and try again.",
-//         "shows a dialogue with the error message from the server"
-//       );
-//       await click(".modal-footer .btn.btn-primary");
-//     });
-//   }
-// );
+acceptance(
+  "Managing Group Email Settings - SMTP and IMAP Enabled - Email Test Invalid",
+  function (needs) {
+    needs.user();
+    needs.settings({ enable_smtp: true, enable_imap: true });
+
+    needs.pretender((server, helper) => {
+      server.post("/groups/47/test_email_settings", () => {
+        return helper.response(422, {
+          success: false,
+          errors: [
+            "There was an issue with the SMTP credentials provided, check the username and password and try again.",
+          ],
+        });
+      });
+    });
+
+    test("enabling IMAP, testing, and saving", async function (assert) {
+      await visit("/g/discourse/manage/email");
+
+      await click("#enable_smtp");
+      await click("#prefill_smtp_gmail");
+      await fillIn('input[name="username"]', "myusername@gmail.com");
+      await fillIn('input[name="password"]', "password@gmail.com");
+      await click(".test-smtp-settings");
+
+      assert.equal(
+        query(".modal-body").innerText,
+        "There was an issue with the SMTP credentials provided, check the username and password and try again.",
+        "shows a dialogue with the error message from the server"
+      );
+      await click(".modal-footer .btn.btn-primary");
+    });
+  }
+);

GitHub sha: fe5923da06c2e432995a41039ae238809a6ef27e

This commit appears in #13462 which was approved by eviltrout. It was merged by CvX.