discourse/test/javascripts/acceptance/admin-emails-test.js.es6
Mark VanLandingham 176aa0ac7d
DEV: Import pretender instead of global server var (#8996)
* DEV: Remove server global test variable

* Delete yarn-error.log

* prettier and some eslint fixes

* add global server variable back for plugins

* rename imported server to pretender

* prettier

* support plugin server. usage

* Export pretender as named

* Prettier

* change default pretender export

* fix bad import

* Use pretender() and original default export

* export new Pretender as default

* fix accidental change

* WIP testing

* add pretend handlers in correct location

* move more stuff into the correct pretender

* Consolidated more pretenders

* comment out another bad test

* fix user acceptance tests

* commented out bad test

* fixed another composer server stub

* fix more tests

* fixed tag test pretender

* Fix admin email test

* removed another draft handler

* add back test

* fix and uncomment another test

* remove test that is not useful

* remove commented out lines

* reapply handlers between every test

* no need to re-stub requests now :)

* cleanup from review

* more cleanup
2020-03-02 14:24:31 -05:00

42 lines
1.0 KiB
JavaScript

import { acceptance } from "helpers/qunit-helpers";
import pretender from "helpers/create-pretender";
acceptance("Admin - Emails", { loggedIn: true });
const email = `
From: "somebody" <somebody@example.com>
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 => {
pretender.post("/admin/email/advanced-test", () => {
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."
);
});