diff --git a/web/src/settings_emoji.js b/web/src/settings_emoji.js index 7dd8386335..ac21247ac1 100644 --- a/web/src/settings_emoji.js +++ b/web/src/settings_emoji.js @@ -221,8 +221,6 @@ function show_modal() { error(xhr) { $("#dialog_error").hide(); dialog_widget.hide_dialog_spinner(); - const errors = JSON.parse(xhr.responseText).msg; - xhr.responseText = JSON.stringify({msg: errors}); ui_report.error($t_html({defaultMessage: "Failed"}), xhr, $emoji_status); }, }); diff --git a/web/src/settings_user_groups_legacy.js b/web/src/settings_user_groups_legacy.js index 2578d11894..065a2befc5 100644 --- a/web/src/settings_user_groups_legacy.js +++ b/web/src/settings_user_groups_legacy.js @@ -216,8 +216,6 @@ export function populate_user_groups() { setTimeout(show_saved_button, 200); }, error(xhr) { - const errors = JSON.parse(xhr.responseText).msg; - xhr.responseText = JSON.stringify({msg: errors}); ui_report.error($t_html({defaultMessage: "Failed"}), xhr, $user_group_status); update_cancel_button(); $(`#user-groups #${CSS.escape(data.id)} .name`).text(group_data.name); @@ -324,8 +322,6 @@ export function add_user_group() { }, error(xhr) { $user_group_status.hide(); - const errors = JSON.parse(xhr.responseText).msg; - xhr.responseText = JSON.stringify({msg: errors}); ui_report.error($t_html({defaultMessage: "Failed"}), xhr, $user_group_status); }, }); diff --git a/web/tests/settings_user_groups_legacy.test.js b/web/tests/settings_user_groups_legacy.test.js index 67f033ba15..1fed7a0bb2 100644 --- a/web/tests/settings_user_groups_legacy.test.js +++ b/web/tests/settings_user_groups_legacy.test.js @@ -538,21 +538,14 @@ test_ui("on_events", ({override_rewire, mock_template}) => { assert.ok(!$("#dialog_error").visible()); })(); - (function test_post_error() { $("#dialog_error").show(); ui_report.error = (error_msg, error_obj, ele) => { - const xhr = { - responseText: '{"msg":"fake-msg"}', - }; assert.equal(error_msg, "translated HTML: Failed"); - assert.deepEqual(error_obj, xhr); + assert.deepEqual(error_obj, {responseJson: {msg: "fake-msg"}}); assert.equal(ele, $("#dialog_error")); }; - const xhr = { - responseText: '{"msg":"fake-msg", "attrib":"val"}', - }; - opts.error(xhr); + opts.error({responseJson: {msg: "fake-msg"}}); assert.ok(!$("#dialog_error").visible()); })(); @@ -763,17 +756,11 @@ test_ui("on_events", ({override_rewire, mock_template}) => { const $user_group_error = $(user_group_selector + " .user-group-status"); $user_group_error.show(); ui_report.error = (error_msg, error_obj, ele) => { - const xhr = { - responseText: '{"msg":"fake-msg"}', - }; assert.equal(error_msg, "translated HTML: Failed"); - assert.deepEqual(error_obj, xhr); + assert.deepEqual(error_obj, {responseJson: {msg: "fake-msg"}}); assert.equal(ele, $user_group_error); }; - const xhr = { - responseText: '{"msg":"fake-msg", "attrib":"val"}', - }; - opts.error(xhr); + opts.error({responseJson: {msg: "fake-msg"}}); assert.ok($user_group_error.visible()); })();