diff --git a/app/assets/stylesheets/common/admin/emails.scss b/app/assets/stylesheets/common/admin/emails.scss
index 6be0f2bb2e4..732f3d40bb1 100644
--- a/app/assets/stylesheets/common/admin/emails.scss
+++ b/app/assets/stylesheets/common/admin/emails.scss
@@ -89,7 +89,7 @@
display: block;
}
- textarea {
+ .email-body {
width: 95%;
height: 150px;
font-family: monospace;
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index e1cad513213..201668125fe 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -3415,7 +3415,7 @@ en:
preview_digest: "Preview Summary"
advanced_test:
title: "Advanced Test"
- desc: "See how Discourse processes recieved emails. To be able to correctly process the email, please paste below the whole original email message."
+ desc: "See how Discourse processes received emails. To be able to correctly process the email, please paste below the whole original email message."
email: "Original message"
run: "Run Test"
text: "Selected Text Body"
diff --git a/spec/requests/admin/email_controller_spec.rb b/spec/requests/admin/email_controller_spec.rb
index a6d30ba958f..3df6f3a0342 100644
--- a/spec/requests/admin/email_controller_spec.rb
+++ b/spec/requests/admin/email_controller_spec.rb
@@ -184,4 +184,28 @@ describe Admin::EmailController do
expect(incoming['error']).to eq(I18n.t("emails.incoming.unrecognized_error"))
end
end
+
+ describe '#advanced_test' do
+ it 'should ...' do
+ email = <<~EMAIL
+ From: "somebody"
+ To: someone@example.com
+ Date: Mon, 3 Dec 2018 00:00:00 -0000
+ Subject: This is some subject
+ Content-Type: text/plain; charset="UTF-8"
+
+ Hello, this is a test!
+
+ ---
+
+ This part should be elided.
+ EMAIL
+ post "/admin/email/advanced-test.json", params: { email: email }
+ expect(response.status).to eq(200)
+ incoming = JSON.parse(response.body)
+ expect(incoming['format']).to eq(1)
+ expect(incoming['text']).to eq("Hello, this is a test!")
+ expect(incoming['elided']).to eq("---\n\nThis part should be elided.")
+ end
+ end
end
diff --git a/test/javascripts/acceptance/admin-emails-test.js.es6 b/test/javascripts/acceptance/admin-emails-test.js.es6
new file mode 100644
index 00000000000..f44cf638e91
--- /dev/null
+++ b/test/javascripts/acceptance/admin-emails-test.js.es6
@@ -0,0 +1,41 @@
+import { acceptance } from "helpers/qunit-helpers";
+
+acceptance("Admin - Emails", { loggedIn: true });
+
+const email = `
+From: "somebody"
+To: someone@example.com
+Date: Mon, 3 Dec 2018 00:00:00 -0000
+Subject: This is some subject
+Content-Type: text/plain; charset="UTF-8"
+
+Hello, this is a test!
+
+---
+
+This part should be elided.`.trim();
+
+QUnit.test("shows selected and elided text", async assert => {
+ // prettier-ignore
+ server.post("/admin/email/advanced-test", () => { // eslint-disable-line no-undef
+ return [
+ 200,
+ { "Content-Type": "application/json" },
+ {
+ format: 1,
+ text: "Hello, this is a test!",
+ elided: "---\n\nThis part should be elided.",
+ }
+ ];
+ });
+
+ await visit("/admin/email/advanced-test");
+ await fillIn("textarea.email-body", email);
+ await click(".email-advanced-test button");
+
+ assert.equal(find(".text pre").text(), "Hello, this is a test!");
+ assert.equal(
+ find(".elided pre").text(),
+ "---\n\nThis part should be elided."
+ );
+});