mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 01:54:02 +08:00
FIX: Correctly display /admin/emails
errors (#17321)
Also removed unused codepath in `admin-badges-show`.
This commit is contained in:
parent
c5f0aa2f32
commit
a0a7b3f9c4
|
@ -43,10 +43,10 @@ export default Controller.extend({
|
|||
this.set("sentTestEmailMessage", response.sent_test_email_message)
|
||||
)
|
||||
.catch((e) => {
|
||||
if (e.responseJSON && e.responseJSON.errors) {
|
||||
if (e.jqXHR.responseJSON?.errors) {
|
||||
bootbox.alert(
|
||||
I18n.t("admin.email.error", {
|
||||
server_error: e.responseJSON.errors[0],
|
||||
server_error: e.jqXHR.responseJSON.errors[0],
|
||||
})
|
||||
);
|
||||
} else {
|
||||
|
|
|
@ -33,16 +33,6 @@ export default Route.extend({
|
|||
},
|
||||
|
||||
actions: {
|
||||
saveError(e) {
|
||||
let msg = I18n.t("generic_error");
|
||||
if (e.responseJSON && e.responseJSON.errors) {
|
||||
msg = I18n.t("generic_error_with_reason", {
|
||||
error: e.responseJSON.errors.join(". "),
|
||||
});
|
||||
}
|
||||
bootbox.alert(msg);
|
||||
},
|
||||
|
||||
editGroupings() {
|
||||
const model = this.controllerFor("admin-badges").get("badgeGroupings");
|
||||
showModal("admin-edit-badge-groupings", { model, admin: true });
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { acceptance, queryAll } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { click, fillIn, visit } from "@ember/test-helpers";
|
||||
import { test } from "qunit";
|
||||
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||
|
||||
const EMAIL = `
|
||||
From: "somebody" <somebody@example.com>
|
||||
|
@ -17,25 +18,40 @@ This part should be elided.`;
|
|||
|
||||
acceptance("Admin - Emails", function (needs) {
|
||||
needs.user();
|
||||
needs.pretender((server, helper) => {
|
||||
server.post("/admin/email/advanced-test", () => {
|
||||
return helper.response({
|
||||
test("shows selected and elided text", async function (assert) {
|
||||
pretender.post("/admin/email/advanced-test", () => {
|
||||
return response({
|
||||
format: 1,
|
||||
text: "Hello, this is a test!",
|
||||
elided: "---\n\nThis part should be elided.",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test("shows selected and elided text", async function (assert) {
|
||||
await visit("/admin/email/advanced-test");
|
||||
await fillIn("textarea.email-body", EMAIL.trim());
|
||||
await click(".email-advanced-test button");
|
||||
|
||||
assert.strictEqual(queryAll(".text pre").text(), "Hello, this is a test!");
|
||||
assert.strictEqual(query(".text pre").innerText, "Hello, this is a test!");
|
||||
assert.strictEqual(
|
||||
queryAll(".elided pre").text(),
|
||||
query(".elided pre").innerText,
|
||||
"---\n\nThis part should be elided."
|
||||
);
|
||||
});
|
||||
|
||||
test("displays received errors when testing emails", async function (assert) {
|
||||
pretender.get("/admin/email.json", () => {
|
||||
return response({});
|
||||
});
|
||||
|
||||
pretender.post("/admin/email/test", () => {
|
||||
return response(422, { errors: ["some error"] });
|
||||
});
|
||||
|
||||
await visit("/admin/email");
|
||||
await fillIn(".admin-controls input", "test@example.com");
|
||||
await click(".btn-primary");
|
||||
|
||||
assert.ok(query(".bootbox.modal").innerText.includes("some error"));
|
||||
await click(".bootbox .btn-primary");
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user