mirror of
https://github.com/discourse/discourse.git
synced 2025-06-02 16:29:32 +08:00
DEV: Close modal so other JS tests don't randomly failed.
This commit is contained in:
@ -131,39 +131,43 @@ QUnit.test("replying to post - reply_as_new_topic", async assert => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("shared draft", async assert => {
|
QUnit.test("shared draft", async assert => {
|
||||||
toggleCheckDraftPopup(true);
|
try {
|
||||||
|
toggleCheckDraftPopup(true);
|
||||||
|
|
||||||
const composerActions = selectKit(".composer-actions");
|
const composerActions = selectKit(".composer-actions");
|
||||||
const tags = selectKit(".mini-tag-chooser");
|
const tags = selectKit(".mini-tag-chooser");
|
||||||
|
|
||||||
await visit("/");
|
await visit("/");
|
||||||
await click("#create-topic");
|
await click("#create-topic");
|
||||||
|
|
||||||
await fillIn(
|
await fillIn(
|
||||||
"#reply-title",
|
"#reply-title",
|
||||||
"This is the new text for the title using 'quotes'"
|
"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 fillIn(".d-editor-input", "This is the new text for the post");
|
||||||
await composerActions.selectRowByValue("shared_draft");
|
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(tags.header().value(), "monkey", "tags are not reset");
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
find("#reply-title").val(),
|
find("#reply-title").val(),
|
||||||
"This is the new text for the title using 'quotes'"
|
"This is the new text for the title using 'quotes'"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
find("#reply-control .btn-primary.create .d-button-label").text(),
|
find("#reply-control .btn-primary.create .d-button-label").text(),
|
||||||
I18n.t("composer.create_shared_draft")
|
I18n.t("composer.create_shared_draft")
|
||||||
);
|
);
|
||||||
assert.ok(find("#reply-control.composing-shared-draft").length === 1);
|
|
||||||
|
|
||||||
toggleCheckDraftPopup(false);
|
assert.ok(find("#reply-control.composing-shared-draft").length === 1);
|
||||||
|
await click(".modal-footer .btn.btn-default");
|
||||||
|
} finally {
|
||||||
|
toggleCheckDraftPopup(false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("hide component if no content", async assert => {
|
QUnit.test("hide component if no content", async assert => {
|
||||||
|
@ -599,87 +599,99 @@ QUnit.test(
|
|||||||
);
|
);
|
||||||
|
|
||||||
QUnit.test("Checks for existing draft", async assert => {
|
QUnit.test("Checks for existing draft", async assert => {
|
||||||
toggleCheckDraftPopup(true);
|
try {
|
||||||
|
toggleCheckDraftPopup(true);
|
||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
server.get("/draft.json", () => { // eslint-disable-line no-undef
|
server.get("/draft.json", () => { // eslint-disable-line no-undef
|
||||||
return [ 200, { "Content-Type": "application/json" }, {
|
return [ 200, { "Content-Type": "application/json" }, {
|
||||||
draft: "{\"reply\":\"This is a draft of the first post\",\"action\":\"reply\",\"categoryId\":1,\"archetypeId\":\"regular\",\"metaData\":null,\"composerTime\":2863,\"typingTime\":200}",
|
draft: "{\"reply\":\"This is a draft of the first post\",\"action\":\"reply\",\"categoryId\":1,\"archetypeId\":\"regular\",\"metaData\":null,\"composerTime\":2863,\"typingTime\":200}",
|
||||||
draft_sequence: 42
|
draft_sequence: 42
|
||||||
} ];
|
} ];
|
||||||
});
|
});
|
||||||
|
|
||||||
await visit("/t/internationalization-localization/280");
|
await visit("/t/internationalization-localization/280");
|
||||||
|
|
||||||
await click(".topic-post:eq(0) button.show-more-actions");
|
await click(".topic-post:eq(0) button.show-more-actions");
|
||||||
await click(".topic-post:eq(0) button.edit");
|
await click(".topic-post:eq(0) button.edit");
|
||||||
|
|
||||||
assert.equal(find(".modal-body").text(), I18n.t("drafts.abandon.confirm"));
|
assert.equal(find(".modal-body").text(), I18n.t("drafts.abandon.confirm"));
|
||||||
|
|
||||||
await click(".modal-footer .btn.btn-default");
|
await click(".modal-footer .btn.btn-default");
|
||||||
|
} finally {
|
||||||
toggleCheckDraftPopup(false);
|
toggleCheckDraftPopup(false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("Can switch states without abandon popup", async assert => {
|
QUnit.test("Can switch states without abandon popup", async assert => {
|
||||||
const composerActions = selectKit(".composer-actions");
|
try {
|
||||||
toggleCheckDraftPopup(true);
|
const composerActions = selectKit(".composer-actions");
|
||||||
|
toggleCheckDraftPopup(true);
|
||||||
|
|
||||||
await visit("/t/internationalization-localization/280");
|
await visit("/t/internationalization-localization/280");
|
||||||
|
|
||||||
const longText = "a".repeat(256);
|
const longText = "a".repeat(256);
|
||||||
|
|
||||||
await click(".btn-primary.create.btn");
|
await click(".btn-primary.create.btn");
|
||||||
|
|
||||||
await fillIn(".d-editor-input", longText);
|
await fillIn(".d-editor-input", longText);
|
||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
server.get("/draft.json", () => { // eslint-disable-line no-undef
|
server.get("/draft.json", () => { // eslint-disable-line no-undef
|
||||||
return [ 200, { "Content-Type": "application/json" }, {
|
return [ 200, { "Content-Type": "application/json" }, {
|
||||||
draft: "{\"reply\":\"This is a draft of the first post\",\"action\":\"reply\",\"categoryId\":1,\"archetypeId\":\"regular\",\"metaData\":null,\"composerTime\":2863,\"typingTime\":200}",
|
draft: "{\"reply\":\"This is a draft of the first post\",\"action\":\"reply\",\"categoryId\":1,\"archetypeId\":\"regular\",\"metaData\":null,\"composerTime\":2863,\"typingTime\":200}",
|
||||||
draft_sequence: 42
|
draft_sequence: 42
|
||||||
} ];
|
} ];
|
||||||
});
|
});
|
||||||
|
|
||||||
await click("article#post_3 button.reply");
|
await click("article#post_3 button.reply");
|
||||||
|
|
||||||
await composerActions.expand();
|
await composerActions.expand();
|
||||||
await composerActions.selectRowByValue("reply_to_topic");
|
await composerActions.selectRowByValue("reply_to_topic");
|
||||||
|
|
||||||
assert.equal(find(".modal-body").text(), "", "abandon popup shouldn't come");
|
assert.equal(
|
||||||
|
find(".modal-body").text(),
|
||||||
|
"",
|
||||||
|
"abandon popup shouldn't come"
|
||||||
|
);
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
find(".d-editor-input").val(),
|
find(".d-editor-input").val(),
|
||||||
longText,
|
longText,
|
||||||
"entered text should still be there"
|
"entered text should still be there"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.ok(
|
assert.ok(
|
||||||
find('.action-title a[href="/t/internationalization-localization/280"]'),
|
find('.action-title a[href="/t/internationalization-localization/280"]'),
|
||||||
"mode should have changed"
|
"mode should have changed"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.ok(find(".save-animation"), "save animation should show");
|
assert.ok(find(".save-animation"), "save animation should show");
|
||||||
|
} finally {
|
||||||
toggleCheckDraftPopup(false);
|
toggleCheckDraftPopup(false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("Loading draft also replaces the recipients", async assert => {
|
QUnit.test("Loading draft also replaces the recipients", async assert => {
|
||||||
toggleCheckDraftPopup(true);
|
try {
|
||||||
|
toggleCheckDraftPopup(true);
|
||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
server.get("/draft.json", () => { // eslint-disable-line no-undef
|
server.get("/draft.json", () => { // eslint-disable-line no-undef
|
||||||
return [ 200, { "Content-Type": "application/json" }, {
|
return [ 200, { "Content-Type": "application/json" }, {
|
||||||
"draft":"{\"reply\":\"hello\",\"action\":\"privateMessage\",\"title\":\"hello\",\"categoryId\":null,\"archetypeId\":\"private_message\",\"metaData\":null,\"usernames\":\"codinghorror\",\"composerTime\":9159,\"typingTime\":2500}",
|
"draft":"{\"reply\":\"hello\",\"action\":\"privateMessage\",\"title\":\"hello\",\"categoryId\":null,\"archetypeId\":\"private_message\",\"metaData\":null,\"usernames\":\"codinghorror\",\"composerTime\":9159,\"typingTime\":2500}",
|
||||||
"draft_sequence":0
|
"draft_sequence":0
|
||||||
} ];
|
} ];
|
||||||
});
|
});
|
||||||
|
|
||||||
await visit("/u/charlie");
|
await visit("/u/charlie");
|
||||||
await click("button.compose-pm");
|
await click("button.compose-pm");
|
||||||
await click(".modal .btn-default");
|
await click(".modal .btn-default");
|
||||||
|
|
||||||
assert.equal(find(".users-input .item:eq(0)").text(), "codinghorror");
|
assert.equal(find(".users-input .item:eq(0)").text(), "codinghorror");
|
||||||
|
} finally {
|
||||||
|
toggleCheckDraftPopup(false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test(
|
QUnit.test(
|
||||||
|
Reference in New Issue
Block a user