FIX: use full screen login for new-topic route (#7467)

DEV: add javascript tests for new-topic and new-message routes

DEV: fix an existing test that was being skipped
This commit is contained in:
Arpit Jalan
2019-05-01 22:54:29 +05:30
committed by GitHub
parent da0e37512a
commit b5ea50a154
9 changed files with 103 additions and 17 deletions

View File

@ -18,9 +18,7 @@ QUnit.test("does not display uncategorized if not allowed", async assert => {
assert.ok(categoryChooser.rowByIndex(0).name() !== "uncategorized");
});
// TODO: fix the test to work with new code to land on category page
// (https://github.com/discourse/discourse/commit/7d9c97d66141d35d00258fe544211d9fd7f79a76)
QUnit.skip("prefill category when category_id is set", async assert => {
QUnit.test("prefill category when category_id is set", async assert => {
await visit("/new-topic?category_id=1");
assert.equal(

View File

@ -0,0 +1,43 @@
import { acceptance, logIn } from "helpers/qunit-helpers";
acceptance("New Message");
QUnit.test("accessing new-message route when logged out", async assert => {
await visit(
"/new-message?username=eviltrout&title=message%20title&body=message%20body"
);
assert.ok(exists(".modal.login-modal"), "it shows the login modal");
});
QUnit.test("accessing new-message route when logged in", async assert => {
logIn();
Discourse.reset();
await visit(
"/new-message?username=eviltrout&title=message%20title&body=message%20body"
);
assert.ok(exists(".composer-fields"), "it opens composer");
assert.equal(
find("#reply-title")
.val()
.trim(),
"message title",
"it pre-fills message title"
);
assert.equal(
find(".d-editor-input")
.val()
.trim(),
"message body",
"it pre-fills message body"
);
assert.equal(
find(".users-input .item:eq(0)")
.text()
.trim(),
"eviltrout",
"it selects correct username"
);
});

View File

@ -0,0 +1,39 @@
import { acceptance, logIn } from "helpers/qunit-helpers";
acceptance("New Topic");
QUnit.test("accessing new-topic route when logged out", async assert => {
await visit("/new-topic?title=topic%20title&body=topic%20body");
assert.ok(exists(".modal.login-modal"), "it shows the login modal");
});
QUnit.test("accessing new-topic route when logged in", async assert => {
logIn();
Discourse.reset();
await visit("/new-topic?title=topic%20title&body=topic%20body&category=bug");
assert.ok(exists(".composer-fields"), "it opens composer");
assert.equal(
find("#reply-title")
.val()
.trim(),
"topic title",
"it pre-fills topic title"
);
assert.equal(
find(".d-editor-input")
.val()
.trim(),
"topic body",
"it pre-fills topic body"
);
assert.equal(
selectKit(".category-chooser")
.header()
.value(),
1,
"it selects desired category"
);
});

View File

@ -150,7 +150,7 @@ export default {
{ action_type: 11, count: 20, id: null }
],
can_send_private_messages: true,
can_send_private_message_to_user: false,
can_send_private_message_to_user: true,
bio_excerpt:
'<p>Co-founder of Discourse. Previously, I created <a href="http://forumwarz.com">Forumwarz</a>. <a href="https://twitter.com/eviltrout">Follow me on Twitter</a>. I am <a class="mention" href="/u/eviltrout">@eviltrout</a>.</p>',
trust_level: 4,

View File

@ -62,6 +62,18 @@ export default function() {
return response(json);
});
this.get("/c/bug/l/latest.json", () => {
const json = fixturesByUrl["/c/bug/l/latest.json"];
if (loggedIn()) {
// Stuff to let us post
json.topic_list.can_create_topic = true;
json.topic_list.draft_key = "new_topic";
json.topic_list.draft_sequence = 1;
}
return response(json);
});
this.get("/tags", () => {
return response({
tags: [