Skip to content
Snippets Groups Projects
Commit 54987e8a authored by Marius Dumitru Florea's avatar Marius Dumitru Florea
Browse files

XWIKI-21535: Content added by concurrent user editing is lost on "merge" if...

XWIKI-21535: Content added by concurrent user editing is lost on "merge" if save and view is done after save and continue

(cherry picked from commit 69d36e34)
parent 891fea91
No related branches found
No related tags found
No related merge requests found
......@@ -19,6 +19,10 @@
*/
package org.xwiki.edit.test.ui;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Order;
......@@ -30,10 +34,6 @@
import org.xwiki.test.docker.junit5.UITest;
import org.xwiki.test.ui.TestUtils;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests in-place page editing.
*
......@@ -220,4 +220,22 @@ void editInPlaceWithMandatoryVersionSummary(TestUtils setup, TestReference testR
setup.loginAndGotoPage("alice", "pa$$word", setup.getURL(testReference));
new InplaceEditablePage().editInplace().saveAndView();
}
@Test
@Order(4)
void saveWithMergeReloadsEditor(TestUtils setup, TestReference testReference) throws Exception
{
// Enter in-place edit mode.
InplaceEditablePage viewPage = new InplaceEditablePage().editInplace();
// Save the page outside the in-place editor to increase the version and trigger a merge conflict on save.
setup.rest().savePage(testReference, "new content", "new title");
// Save the page inside the in-place editor.
viewPage.save();
assertEquals("new title", viewPage.getDocumentTitle());
viewPage.saveAndView();
assertEquals("new content", viewPage.getContent());
}
}
......@@ -889,7 +889,13 @@
reloadEditor: function() {
var actionButtons = $('.inplace-editing-buttons');
if (actionButtons.is(':visible')) {
actionButtons.trigger('xwiki:actions:reload');
// This function is called after the document save confirmation is received, if the save was done by merge. We
// register our reload listener from a document saved listener, but we're using promises which are
// asynchronous so the reload listener is actually registered with a delay. For this reason we trigger the
// reload event with a delay to ensure our reload listener is called.
setTimeout(function() {
actionButtons.trigger('xwiki:actions:reload');
}, 0);
} else {
return originalAjaxSaveAndContinue.reloadEditor.apply(this, arguments);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment