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

[misc] Code formatting

(cherry picked from commit 1d0c7b56)
parent 58247dc1
No related branches found
No related tags found
No related merge requests found
......@@ -269,7 +269,7 @@ void editWithSelf(TestReference testReference, TestUtils setup, MultiUserTestUti
// Verify that clicking on the coeditor indicator scrolls the editing area to the coeditor position.
// But first we need to add enough paragraphs to make the editing area scrollable.
for (int i = 0; i< 20; i++) {
for (int i = 0; i < 20; i++) {
firstTextArea.sendKeys(Keys.ENTER);
}
firstTextArea.sendKeys("end");
......@@ -403,13 +403,15 @@ void editDifferentParagraphs(TestReference testReference, TestUtils setup, Multi
secondTextArea.waitUntilTextContains("Start.");
secondTextArea.sendKeys(Keys.END, Keys.ENTER);
String firstUserText = "The five boxing wizards jump quickly. The quick brown fox jumps over the lazy dog. First";
String secondUserText = "The quick brown fox jumps over the lazy dog. The five boxing wizards jump quickly. Second";
String firstUserText =
"The five boxing wizards jump quickly. The quick brown fox jumps over the lazy dog. First";
String secondUserText =
"The quick brown fox jumps over the lazy dog. The five boxing wizards jump quickly. Second";
String[] firstUserWords = firstUserText.split(" ");
String[] secondUserWords = secondUserText.split(" ");
for(int i = 0; i < Math.min(firstUserWords.length, secondUserWords.length); i++) {
for (int i = 0; i < Math.min(firstUserWords.length, secondUserWords.length); i++) {
//
// First Tab
//
......@@ -465,7 +467,7 @@ void editSameParagraph(TestReference testReference, TestUtils setup, MultiUserTe
String text = "The quick brown fox jumps over the lazy dog.";
String[] words = text.split(" ");
for(int i = 0; i < words.length; i++) {
for (int i = 0; i < words.length; i++) {
//
// First Tab
//
......@@ -586,7 +588,8 @@ void applyInlineStylesOnTheSameParagraph(TestReference testReference, TestUtils
@Test
@Order(7)
void imageWithCaption(TestReference testReference, TestUtils setup, MultiUserTestUtils multiUserSetup) throws Exception
void imageWithCaption(TestReference testReference, TestUtils setup, MultiUserTestUtils multiUserSetup)
throws Exception
{
// Start fresh.
setup.deletePage(testReference);
......@@ -1337,7 +1340,7 @@ void editPageTranslations(TestUtils setup, TestReference testReference, MultiUse
assertEquals("superadmin", firstEditor.getToolBar().getCoeditors().stream().map(Coeditor::getName)
.reduce((a, b) -> a + ", " + b).get());
}
@Test
@Order(17)
void editSource(TestUtils setup, TestReference testReference, MultiUserTestUtils multiUserSetup)
......@@ -1354,7 +1357,7 @@ void editSource(TestUtils setup, TestReference testReference, MultiUserTestUtils
RealtimeCKEditor firstEditor = firstEditPage.getContenEditor();
RealtimeCKEditorToolBar firstEditorToolbar = firstEditor.getToolBar();
RealtimeRichTextAreaElement firstTextArea = firstEditor.getRichTextArea();
// Check that the source button is available.
assertTrue(firstEditorToolbar.canToggleSourceMode());
......@@ -1379,8 +1382,6 @@ void editSource(TestUtils setup, TestReference testReference, MultiUserTestUtils
// Switch back to the first tab
setup.getDriver().switchTo().window(multiUserSetup.getFirstTabHandle());
// Type in the first tab to have some content.
firstTextArea.sendKeys("one", Keys.ENTER, "two", Keys.ENTER, "three");
......@@ -1394,21 +1395,20 @@ void editSource(TestUtils setup, TestReference testReference, MultiUserTestUtils
secondTextArea.waitUntilTextContains("three");
assertEquals("one\ntwo\nthree", secondTextArea.getText());
// Save to make sure the editor is not marked as dirty.
secondEditPage.clickSaveAndContinue();
// Switch to source mode and check that we are not in the realtime session anymore.
secondEditorToolbar.toggleSourceMode();
assertFalse(secondEditPage.isRealtimeEditing());
// Check that we can still switch back to wysiwyg mode.
assertTrue(secondEditorToolbar.canToggleSourceMode());
// Check the contents of the source mode.
assertEquals("one\n\ntwo\n\nthree", secondEditor.getSourceTextArea().getAttribute("value"));
//
// First Tab
//
......@@ -1417,7 +1417,7 @@ void editSource(TestUtils setup, TestReference testReference, MultiUserTestUtils
setup.getDriver().switchTo().window(multiUserSetup.getFirstTabHandle());
firstTextArea.sendKeys(Keys.ENTER, "four");
//
// Second Tab
//
......@@ -1425,32 +1425,32 @@ void editSource(TestUtils setup, TestReference testReference, MultiUserTestUtils
// Switch to the second tab and switch back to view mode.
setup.getDriver().switchTo().window(secondTabHandle);
secondEditorToolbar.toggleSourceMode();
// After switching back to view mode, we need to recreate the textArea.
secondTextArea = secondEditor.getRichTextArea();
// Check that the second user re-joined the realtime editing session.
assertTrue(secondEditPage.isRealtimeEditing());
assertTrue(secondEditorToolbar.canToggleSourceMode());
secondTextArea.waitUntilContentContains("four");
assertEquals("one\ntwo\nthree\nfour", secondTextArea.getText());
// Check that we can still switch to source mode.
assertTrue(secondEditorToolbar.canToggleSourceMode());
// Save again to make the editor not dirty.
secondEditPage.clickSaveAndContinue();
// Switch to source mode.
secondEditorToolbar.toggleSourceMode();
assertFalse(secondEditPage.isRealtimeEditing());
// Check the contents of the source mode.
assertEquals("one\n\ntwo\n\nthree\n\nfour", secondEditor.getSourceTextArea().getAttribute("value"));
// Add some content.
secondEditor.getSourceTextArea().sendKeys(Keys.ENTER, Keys.ENTER, "five");
//
// First Tab
//
......@@ -1459,7 +1459,7 @@ void editSource(TestUtils setup, TestReference testReference, MultiUserTestUtils
setup.getDriver().switchTo().window(multiUserSetup.getFirstTabHandle());
firstTextArea.sendKeys(Keys.ENTER, "six");
//
// Second Tab
//
......@@ -1467,38 +1467,39 @@ void editSource(TestUtils setup, TestReference testReference, MultiUserTestUtils
// Switch to the second tab and switch back to view mode.
setup.getDriver().switchTo().window(secondTabHandle);
secondEditorToolbar.toggleSourceMode();
// After switching back to view mode, we need to recreate the textArea.
secondTextArea = secondEditor.getRichTextArea();
// Check that the second user did not re-join the realtime editing session.
assertFalse(secondEditPage.isRealtimeEditing());
assertTrue(secondEditorToolbar.canToggleSourceMode());
assertEquals("one\ntwo\nthree\nfour\nfive", secondTextArea.getText());
// Join the realtime session again and wait to be in sync.
secondEditPage.joinRealtimeEditing();
secondTextArea.waitUntilContentContains("six");
assertEquals("one\ntwo\nthree\nfour\nsix", secondTextArea.getText());
// Check that we can still switch to source mode.
assertTrue(secondEditorToolbar.canToggleSourceMode());
// Make the editor dirty by editing the content without saving.
secondTextArea.sendKeys(Keys.ARROW_DOWN, Keys.END, Keys.ENTER, "seven");
// Switch to source mode and back to wysiwyg edit mode.
secondEditorToolbar.toggleSourceMode();
assertFalse(secondEditPage.isRealtimeEditing());
assertEquals("one\n\ntwo\n\nthree\n\nfour\n\nsix\n\nseven", secondEditor.getSourceTextArea().getAttribute("value"));
assertEquals("one\n\ntwo\n\nthree\n\nfour\n\nsix\n\nseven",
secondEditor.getSourceTextArea().getAttribute("value"));
secondEditorToolbar.toggleSourceMode();
// Check that the second user did not re-join the realtime editing session.
assertFalse(secondEditPage.isRealtimeEditing());
// We keep the second user out of the realtime editing session now
// and we do more tests with the first user.
//
// First Tab
//
......@@ -1508,31 +1509,29 @@ void editSource(TestUtils setup, TestReference testReference, MultiUserTestUtils
// Check that the source button is available.
assertTrue(firstEditorToolbar.canToggleSourceMode());
// Saving might merge silently. Here is some bulletproofing cleanup.
firstEditPage.clickSaveAndContinue();
firstTextArea.clear();
// Make the editor not dirty by saving.
firstEditPage.clickSaveAndContinue();
firstEditPage.clickSaveAndContinue();
// Switch to source mode and back to wysiwyg.
firstEditorToolbar.toggleSourceMode();
assertFalse(firstEditPage.isRealtimeEditing());
firstEditorToolbar.toggleSourceMode();
assertTrue(firstEditPage.isRealtimeEditing());
// Bulletproofing: Save to make sure the editor is not dirty.
firstEditPage.clickSaveAndContinue();
// Switch to source mode, make a change, and switch back to wysiwyg.
firstEditorToolbar.toggleSourceMode();
assertFalse(firstEditPage.isRealtimeEditing());
firstEditor.getSourceTextArea().sendKeys(Keys.ENTER, Keys.ENTER, "eight");
firstEditorToolbar.toggleSourceMode();
firstTextArea = firstEditor.getRichTextArea();
// We are editing alone, so we should have joined the realtime session after switching back to wysiwyg.
assertTrue(firstEditPage.isRealtimeEditing());
......
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