-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: properly initialize HTML value when using RTE in dialog (#6638)
Co-authored-by: Serhii Kulykov <[email protected]>
- Loading branch information
1 parent
a0ae361
commit 2e506cf
Showing
3 changed files
with
77 additions
and
2 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
...rc/main/java/com/vaadin/flow/component/richtexteditor/tests/RichTextEditorDialogPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Copyright 2000-2024 Vaadin Ltd. | ||
* | ||
* This program is available under Vaadin Commercial License and Service Terms. | ||
* | ||
* See {@literal <https://vaadin.com/commercial-license-and-service-terms>} for the full | ||
* license. | ||
*/ | ||
package com.vaadin.flow.component.richtexteditor.tests; | ||
|
||
import com.vaadin.flow.component.dialog.Dialog; | ||
import com.vaadin.flow.component.html.Div; | ||
import com.vaadin.flow.component.richtexteditor.RichTextEditor; | ||
import com.vaadin.flow.router.Route; | ||
|
||
@Route("vaadin-rich-text-editor/dialog") | ||
public class RichTextEditorDialogPage extends Div { | ||
public RichTextEditorDialogPage() { | ||
RichTextEditor editor = new RichTextEditor(); | ||
editor.setValue("<ul><li>Item 1</li><li>Item 2</li></ul>"); | ||
|
||
Dialog dialog = new Dialog(); | ||
dialog.add(editor); | ||
dialog.open(); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
.../src/test/java/com/vaadin/flow/component/richtexteditor/tests/RichTextEditorDialogIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Copyright 2000-2024 Vaadin Ltd. | ||
* | ||
* This program is available under Vaadin Commercial License and Service Terms. | ||
* | ||
* See {@literal <https://vaadin.com/commercial-license-and-service-terms>} for the full | ||
* license. | ||
*/ | ||
package com.vaadin.flow.component.richtexteditor.tests; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import com.vaadin.flow.component.richtexteditor.testbench.RichTextEditorElement; | ||
import com.vaadin.flow.testutil.TestPath; | ||
import com.vaadin.tests.AbstractComponentIT; | ||
|
||
@TestPath("vaadin-rich-text-editor/dialog") | ||
public class RichTextEditorDialogIT extends AbstractComponentIT { | ||
private RichTextEditorElement editor; | ||
|
||
@Before | ||
public void init() { | ||
open(); | ||
editor = $(RichTextEditorElement.class).waitForFirst(); | ||
} | ||
|
||
@Test | ||
public void setHtmlValue_correctlyConvertsHtmlToDeltaValue() { | ||
// Wait until delta value has been updated | ||
waitUntil(driver -> !editor.getPropertyString("value").isEmpty()); | ||
|
||
String expectedHtml = "<ul><li>Item 1</li><li>Item 2</li></ul>"; | ||
String expectedDelta = "[{\"insert\":\"Item 1\"},{\"attributes\":{\"list\":\"bullet\"},\"insert\":\"\\n\"},{\"insert\":\"Item 2\"},{\"attributes\":{\"list\":\"bullet\"},\"insert\":\"\\n\"}]"; | ||
|
||
Assert.assertEquals(expectedHtml, | ||
editor.getEditor().getProperty("innerHTML")); | ||
Assert.assertEquals(expectedDelta, editor.getProperty("value")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters