FIX: Warn users of overwriting new topic draft (#8841)
This commit is contained in:
committed by
GitHub
parent
91b70f8ffc
commit
c8a02161dd
@@ -2,6 +2,8 @@ import selectKit from "helpers/select-kit-helper";
|
||||
import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
|
||||
import { _clearSnapshots } from "select-kit/components/composer-actions";
|
||||
import { toggleCheckDraftPopup } from "discourse/controllers/composer";
|
||||
import Draft from "discourse/models/draft";
|
||||
import { Promise } from "rsvp";
|
||||
|
||||
acceptance("Composer Actions", {
|
||||
loggedIn: true,
|
||||
@@ -99,6 +101,9 @@ QUnit.test("replying to post - toggle_whisper", async assert => {
|
||||
});
|
||||
|
||||
QUnit.test("replying to post - reply_as_new_topic", async assert => {
|
||||
sandbox
|
||||
.stub(Draft, "get")
|
||||
.returns(Promise.resolve({ draft: "", draft_sequence: 0 }));
|
||||
const composerActions = selectKit(".composer-actions");
|
||||
const categoryChooser = selectKit(".title-wrapper .category-chooser");
|
||||
const categoryChooserReplyArea = selectKit(".reply-area .category-chooser");
|
||||
@@ -129,46 +134,16 @@ QUnit.test("replying to post - reply_as_new_topic", async assert => {
|
||||
.val()
|
||||
.includes(quote)
|
||||
);
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
QUnit.test("shared draft", async assert => {
|
||||
try {
|
||||
toggleCheckDraftPopup(true);
|
||||
|
||||
const composerActions = selectKit(".composer-actions");
|
||||
const tags = selectKit(".mini-tag-chooser");
|
||||
|
||||
await visit("/");
|
||||
await click("#create-topic");
|
||||
|
||||
await fillIn(
|
||||
"#reply-title",
|
||||
"This is the new text for the title using 'quotes'"
|
||||
);
|
||||
|
||||
await fillIn(".d-editor-input", "This is the new text for the post");
|
||||
await tags.expand();
|
||||
await tags.selectRowByValue("monkey");
|
||||
await composerActions.expand();
|
||||
await composerActions.selectRowByValue("shared_draft");
|
||||
|
||||
assert.equal(tags.header().value(), "monkey", "tags are not reset");
|
||||
|
||||
assert.equal(
|
||||
find("#reply-title").val(),
|
||||
"This is the new text for the title using 'quotes'"
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
find("#reply-control .btn-primary.create .d-button-label").text(),
|
||||
I18n.t("composer.create_shared_draft")
|
||||
);
|
||||
|
||||
assert.ok(find("#reply-control.composing-shared-draft").length === 1);
|
||||
await click(".modal-footer .btn.btn-default");
|
||||
} finally {
|
||||
toggleCheckDraftPopup(false);
|
||||
}
|
||||
QUnit.test("reply_as_new_topic without a new_topic draft", async assert => {
|
||||
await visit("/t/internationalization-localization/280");
|
||||
await click(".create.reply");
|
||||
const composerActions = selectKit(".composer-actions");
|
||||
await composerActions.expand();
|
||||
await composerActions.selectRowByValue("reply_as_new_topic");
|
||||
assert.equal(exists(find(".bootbox")), false);
|
||||
});
|
||||
|
||||
QUnit.test("hide component if no content", async assert => {
|
||||
@@ -363,3 +338,78 @@ QUnit.test(
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
acceptance("Composer Actions With New Topic Draft", {
|
||||
loggedIn: true,
|
||||
settings: {
|
||||
enable_whispers: true
|
||||
},
|
||||
site: {
|
||||
can_tag_topics: true
|
||||
},
|
||||
beforeEach() {
|
||||
_clearSnapshots();
|
||||
},
|
||||
pretend(server, helper) {
|
||||
server.get("draft.json", () => {
|
||||
return helper.response({
|
||||
draft:
|
||||
'{"reply":"dum de dum da ba.","action":"createTopic","title":"dum da ba dum dum","categoryId":null,"archetypeId":"regular","metaData":null,"composerTime":540879,"typingTime":3400}',
|
||||
draft_sequence: 0
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test("shared draft", async assert => {
|
||||
try {
|
||||
toggleCheckDraftPopup(true);
|
||||
|
||||
const composerActions = selectKit(".composer-actions");
|
||||
const tags = selectKit(".mini-tag-chooser");
|
||||
|
||||
await visit("/");
|
||||
await click("#create-topic");
|
||||
|
||||
await fillIn(
|
||||
"#reply-title",
|
||||
"This is the new text for the title using 'quotes'"
|
||||
);
|
||||
|
||||
await fillIn(".d-editor-input", "This is the new text for the post");
|
||||
await tags.expand();
|
||||
await tags.selectRowByValue("monkey");
|
||||
await composerActions.expand();
|
||||
await composerActions.selectRowByValue("shared_draft");
|
||||
|
||||
assert.equal(tags.header().value(), "monkey", "tags are not reset");
|
||||
|
||||
assert.equal(
|
||||
find("#reply-title").val(),
|
||||
"This is the new text for the title using 'quotes'"
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
find("#reply-control .btn-primary.create .d-button-label").text(),
|
||||
I18n.t("composer.create_shared_draft")
|
||||
);
|
||||
|
||||
assert.ok(find("#reply-control.composing-shared-draft").length === 1);
|
||||
await click(".modal-footer .btn.btn-default");
|
||||
} finally {
|
||||
toggleCheckDraftPopup(false);
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test("reply_as_new_topic with new_topic draft", async assert => {
|
||||
await visit("/t/internationalization-localization/280");
|
||||
await click(".create.reply");
|
||||
const composerActions = selectKit(".composer-actions");
|
||||
await composerActions.expand();
|
||||
await composerActions.selectRowByValue("reply_as_new_topic");
|
||||
assert.equal(
|
||||
find(".bootbox .modal-body").text(),
|
||||
I18n.t("composer.composer_actions.reply_as_new_topic.confirm")
|
||||
);
|
||||
await click(".modal-footer .btn.btn-default");
|
||||
});
|
||||
|
||||
@@ -366,14 +366,14 @@ QUnit.test("update post time through advanced search ui", async assert => {
|
||||
"it should update the search term correctly"
|
||||
);
|
||||
|
||||
const postTimeSelector = selectKit(
|
||||
".search-advanced-options .select-kit#postTime"
|
||||
);
|
||||
|
||||
await visit("/search");
|
||||
|
||||
await fillIn(".search-query", "none");
|
||||
await fillIn("#search-post-date .date-picker", "2016-10-05");
|
||||
await fillIn("#search-post-date .date-picker", "October 5, 2016");
|
||||
|
||||
const postTimeSelector = selectKit(
|
||||
".search-advanced-options .select-kit#postTime"
|
||||
);
|
||||
await postTimeSelector.expand();
|
||||
await postTimeSelector.selectRowByValue("after");
|
||||
|
||||
|
||||
@@ -18,5 +18,10 @@ QUnit.test("Stream - resume draft", async assert => {
|
||||
assert.ok(find(".user-stream-item").length > 0, "has drafts");
|
||||
|
||||
await click(".user-stream-item .resume-draft");
|
||||
assert.equal(find(".d-editor-input").val(), "dum de dum da ba.");
|
||||
assert.equal(
|
||||
find(".d-editor-input")
|
||||
.val()
|
||||
.trim(),
|
||||
"A fun new topic for testing drafts."
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
export default {
|
||||
"/draft.json": {
|
||||
draft:
|
||||
'{"reply":"dum de dum da ba.","action":"createTopic","title":"dum da ba dum dum","categoryId":null,"archetypeId":"regular","metaData":null,"composerTime":540879,"typingTime":3400}',
|
||||
draft: null,
|
||||
draft_sequence: 0
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user