From 92af202d297c085f12640b4538419c1128a96b61 Mon Sep 17 00:00:00 2001 From: Bianca Nenciu Date: Wed, 14 Nov 2018 19:01:29 +0200 Subject: [PATCH] DEV: Add test for edit conflicts. --- .../composer-edit-conflict-test.js.es6 | 51 ++++++++++++++++--- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/test/javascripts/acceptance/composer-edit-conflict-test.js.es6 b/test/javascripts/acceptance/composer-edit-conflict-test.js.es6 index 9cd0eb104b1..e1025ffc588 100644 --- a/test/javascripts/acceptance/composer-edit-conflict-test.js.es6 +++ b/test/javascripts/acceptance/composer-edit-conflict-test.js.es6 @@ -1,17 +1,16 @@ import { acceptance } from "helpers/qunit-helpers"; acceptance("Composer - Edit conflict", { - loggedIn: true, - - pretend(server, helper) { - server.put("/posts/18", () => { - return helper.response(409, { errors: ["edit conflict"] }); - }); - } + loggedIn: true }); QUnit.skip("Edit a post that causes an edit conflict", async assert => { - await visit("/t/this-is-a-test-topic/9"); + // prettier-ignore + server.put("/posts/398", () => [ // eslint-disable-line no-undef + 409, { "Content-Type": "application/json" }, { errors: ["edit conflict"] } + ]); + + 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 click("#reply-control button.create"); @@ -23,3 +22,39 @@ QUnit.skip("Edit a post that causes an edit conflict", async assert => { "it shows the overwrite button" ); }); + +QUnit.test( + "Should not send originalText when posting a new reply", + async assert => { + // prettier-ignore + server.post("/draft.json", request => { // eslint-disable-line no-undef + assert.equal(request.requestBody.indexOf("originalText"), -1, request.requestBody); + return [ 200, { "Content-Type": "application/json" }, { success: true } ]; + }); + + 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 => { + // prettier-ignore + server.post("/draft.json", request => { // eslint-disable-line no-undef + if (request.requestBody.indexOf("%22reply%22%3A%22%22") === -1) { + assert.notEqual(request.requestBody.indexOf("originalText"), -1); + } + return [ 200, { "Content-Type": "application/json" }, { success: true } ]; + }); + + 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" + ); +});