|
20 | 20 | package org.xwiki.realtime.wysiwyg.test.ui; |
21 | 21 |
|
22 | 22 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| 23 | +import static org.junit.jupiter.api.Assertions.assertFalse; |
| 24 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
| 25 | + |
| 26 | +import java.util.List; |
23 | 27 |
|
24 | 28 | import org.junit.jupiter.api.BeforeAll; |
25 | 29 | import org.junit.jupiter.api.Order; |
26 | 30 | import org.junit.jupiter.api.Test; |
27 | 31 | import org.xwiki.administration.test.po.WYSIWYGEditorAdministrationSectionPage; |
28 | 32 | import org.xwiki.realtime.wysiwyg.test.po.RealtimeCKEditor; |
| 33 | +import org.xwiki.realtime.wysiwyg.test.po.RealtimeRichTextAreaElement; |
| 34 | +import org.xwiki.realtime.wysiwyg.test.po.RealtimeRichTextAreaElement.CoeditorPosition; |
29 | 35 | import org.xwiki.realtime.wysiwyg.test.po.RealtimeWYSIWYGEditPage; |
30 | 36 | import org.xwiki.test.docker.junit5.TestReference; |
31 | 37 | import org.xwiki.test.docker.junit5.UITest; |
@@ -79,10 +85,50 @@ static void configure(TestUtils setup) |
79 | 85 | @Order(1) |
80 | 86 | void editAlone(TestReference testReference, TestUtils setup) |
81 | 87 | { |
| 88 | + // Start fresh. |
| 89 | + setup.deletePage(testReference); |
| 90 | + |
82 | 91 | RealtimeWYSIWYGEditPage editPage = RealtimeWYSIWYGEditPage.gotoPage(testReference); |
83 | 92 | RealtimeCKEditor editor = editPage.getContenEditor(); |
84 | | - editor.getRichTextArea().sendKeys("test"); |
85 | | - ViewPage viewPage = editPage.clickSaveAndView(); |
| 93 | + |
| 94 | + // Verify that the Allow Realtime Collaboration checkbox is checked. |
| 95 | + assertTrue(editPage.isRealtimeEditing()); |
| 96 | + |
| 97 | + // Verify that the Preview button is hidden. |
| 98 | + assertFalse(editPage.getPreviewButton().isDisplayed()); |
| 99 | + |
| 100 | + // The Autosave checkbox is also hidden because autosave is done by the realtime editor (you can't disable it |
| 101 | + // while editing in realtime). |
| 102 | + assertFalse(editPage.getAutoSaveCheckbox().isDisplayed()); |
| 103 | + |
| 104 | + // Verify that we're editing alone. |
| 105 | + assertTrue(editor.getToolBar().isEditingAlone()); |
| 106 | + |
| 107 | + RealtimeRichTextAreaElement textArea = editor.getRichTextArea(); |
| 108 | + textArea.sendKeys("test"); |
| 109 | + |
| 110 | + // Verify the cursor indicator on the left of the editing area. |
| 111 | + List<CoeditorPosition> coeditorPositions = textArea.getCoeditorPositions(); |
| 112 | + assertEquals(1, coeditorPositions.size()); |
| 113 | + |
| 114 | + CoeditorPosition selfPosition = coeditorPositions.get(0); |
| 115 | + assertEquals("John", selfPosition.getAvatarHint()); |
| 116 | + assertTrue(selfPosition.getAvatarURL().contains("noavatar.png"), |
| 117 | + "Unexpected avatar URL: " + selfPosition.getAvatarURL()); |
| 118 | + assertEquals(3, selfPosition.getLocation().getX()); |
| 119 | + assertEquals(18, selfPosition.getLocation().getY()); |
| 120 | + |
| 121 | + // Verify the action buttons (Save and Cancel). |
| 122 | + editPage.clickSaveAndContinue(); |
| 123 | + textArea.sendKeys(" alone"); |
| 124 | + ViewPage viewPage = editPage.clickCancel(); |
86 | 125 | assertEquals("test", viewPage.getContent()); |
| 126 | + |
| 127 | + // Edit again and verify the Save and View button. |
| 128 | + viewPage.edit(); |
| 129 | + editPage = new RealtimeWYSIWYGEditPage(); |
| 130 | + editPage.getContenEditor().getRichTextArea().sendKeys(" alone"); |
| 131 | + viewPage = editPage.clickSaveAndView(); |
| 132 | + assertEquals("test alone", viewPage.getContent()); |
87 | 133 | } |
88 | 134 | } |
0 commit comments