2020-05-14 10:04:08 -04:00
|
|
|
import I18n from "I18n";
|
2018-10-17 23:05:47 -04:00
|
|
|
import { acceptance } from "helpers/qunit-helpers";
|
2020-03-02 14:24:31 -05:00
|
|
|
import pretender from "helpers/create-pretender";
|
2018-10-17 09:35:32 -04:00
|
|
|
|
2018-10-17 23:05:47 -04:00
|
|
|
acceptance("Composer - Edit conflict", {
|
2018-11-14 12:01:29 -05:00
|
|
|
loggedIn: true
|
2018-10-17 23:05:47 -04:00
|
|
|
});
|
2018-10-17 09:35:32 -04:00
|
|
|
|
2019-04-19 03:18:01 -04:00
|
|
|
QUnit.test("Edit a post that causes an edit conflict", async assert => {
|
2018-11-14 12:01:29 -05:00
|
|
|
await visit("/t/internationalization-localization/280");
|
2018-10-17 23:05:47 -04:00
|
|
|
await click(".topic-post:eq(0) button.show-more-actions");
|
|
|
|
await click(".topic-post:eq(0) button.edit");
|
2020-03-02 14:24:31 -05:00
|
|
|
await fillIn(".d-editor-input", "this will 409");
|
2018-10-17 23:05:47 -04:00
|
|
|
await click("#reply-control button.create");
|
|
|
|
assert.equal(
|
|
|
|
find("#reply-control button.create")
|
|
|
|
.text()
|
|
|
|
.trim(),
|
|
|
|
I18n.t("composer.overwrite_edit"),
|
|
|
|
"it shows the overwrite button"
|
|
|
|
);
|
2019-04-19 03:18:01 -04:00
|
|
|
assert.ok(
|
|
|
|
find("#draft-status .d-icon-user-edit"),
|
|
|
|
"error icon should be there"
|
|
|
|
);
|
|
|
|
await click(".modal .btn-primary");
|
2018-10-17 23:05:47 -04:00
|
|
|
});
|
2018-11-14 12:01:29 -05:00
|
|
|
|
2020-03-02 14:24:31 -05:00
|
|
|
function handleDraftPretender(assert) {
|
|
|
|
pretender.post("/draft.json", request => {
|
|
|
|
if (
|
|
|
|
request.requestBody.indexOf("%22reply%22%3A%22%22") === -1 &&
|
|
|
|
request.requestBody.indexOf("Any+plans+to+support+localization") !== -1
|
|
|
|
) {
|
|
|
|
assert.notEqual(request.requestBody.indexOf("originalText"), -1);
|
|
|
|
}
|
|
|
|
if (
|
|
|
|
request.requestBody.indexOf(
|
|
|
|
"draft_key=topic_280&sequence=4&data=%7B%22reply%22%3A%22hello+world+hello+world+hello+world+hello+world+hello+world%22%2C%22action%22%3A%22reply%22%2C%22categoryId%22%3A2%2C%22archetypeId%22%3A%22regular%22%2C%22metaData"
|
|
|
|
) !== -1
|
|
|
|
) {
|
|
|
|
assert.equal(
|
|
|
|
request.requestBody.indexOf("originalText"),
|
|
|
|
-1,
|
|
|
|
request.requestBody
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return [200, { "Content-Type": "application/json" }, { success: true }];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-11-14 12:01:29 -05:00
|
|
|
QUnit.test(
|
|
|
|
"Should not send originalText when posting a new reply",
|
|
|
|
async assert => {
|
2020-03-02 14:24:31 -05:00
|
|
|
handleDraftPretender(assert);
|
2018-11-14 12:01:29 -05:00
|
|
|
|
|
|
|
await visit("/t/internationalization-localization/280");
|
|
|
|
await click(".topic-post:eq(0) button.reply");
|
|
|
|
await fillIn(
|
|
|
|
".d-editor-input",
|
|
|
|
"hello world hello world hello world hello world hello world"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
QUnit.test("Should send originalText when editing a reply", async assert => {
|
2020-03-02 14:24:31 -05:00
|
|
|
handleDraftPretender(assert);
|
2018-11-14 12:01:29 -05:00
|
|
|
|
|
|
|
await visit("/t/internationalization-localization/280");
|
|
|
|
await click(".topic-post:eq(0) button.show-more-actions");
|
|
|
|
await click(".topic-post:eq(0) button.edit");
|
|
|
|
await fillIn(
|
|
|
|
".d-editor-input",
|
|
|
|
"hello world hello world hello world hello world hello world"
|
|
|
|
);
|
|
|
|
});
|