Skip to content

Commit c595758

Browse files
test: replace popover IT with unit test (#7580) (#7603)
* test: replace popover IT with unit test * move test to PopoverAutoAddTest Co-authored-by: Sascha Ißbrücker <sissbruecker@vaadin.com>
1 parent 7fa010d commit c595758

File tree

4 files changed

+15
-38
lines changed

4 files changed

+15
-38
lines changed

vaadin-popover-flow-parent/vaadin-popover-flow-integration-tests/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@
4949
<groupId>com.vaadin</groupId>
5050
<artifactId>vaadin-dev-server</artifactId>
5151
</dependency>
52-
<dependency>
53-
<groupId>com.vaadin</groupId>
54-
<artifactId>vaadin-dialog-flow</artifactId>
55-
<version>${project.version}</version>
56-
</dependency>
5752
<dependency>
5853
<groupId>com.vaadin</groupId>
5954
<artifactId>vaadin-flow-components-test-util</artifactId>

vaadin-popover-flow-parent/vaadin-popover-flow-integration-tests/src/main/java/com/vaadin/flow/component/popover/tests/PopoverView.java

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
package com.vaadin.flow.component.popover.tests;
1717

18-
import com.vaadin.flow.component.dialog.Dialog;
1918
import com.vaadin.flow.component.html.Div;
2019
import com.vaadin.flow.component.html.NativeButton;
2120
import com.vaadin.flow.component.popover.Popover;
@@ -55,22 +54,7 @@ public PopoverView() {
5554
event -> popover.setCloseOnOutsideClick(false));
5655
disableCloseOnOutsideClick.setId("disable-close-on-outside-click");
5756

58-
NativeButton openDialog = new NativeButton("Open dialog and set target",
59-
event -> {
60-
var dialog = new Dialog();
61-
var close = new NativeButton("Close", e -> dialog.close());
62-
close.setId("close-dialog");
63-
dialog.add(close);
64-
dialog.open();
65-
popover.setTarget(target);
66-
});
67-
openDialog.setId("open-dialog");
68-
69-
NativeButton removePopover = new NativeButton("Remove popover",
70-
event -> remove(popover));
71-
removePopover.setId("remove-popover");
72-
7357
add(popover, clearTarget, detachTarget, attachTarget, disableCloseOnEsc,
74-
disableCloseOnOutsideClick, removePopover, openDialog, target);
58+
disableCloseOnOutsideClick, target);
7559
}
7660
}

vaadin-popover-flow-parent/vaadin-popover-flow-integration-tests/src/test/java/com/vaadin/flow/component/popover/tests/PopoverIT.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -135,22 +135,6 @@ public void disableCloseOnEsc_pressEsc_popoverDoesNotClose() {
135135
Assert.assertTrue(popover.isOpen());
136136
}
137137

138-
@Test
139-
public void openDialogAndSetTarget_closeDialog_popoverOpens() {
140-
// Clear the target and remove the popover first to ensure the popover
141-
// is auto-added when the dialog opens
142-
clickElementWithJs("clear-target");
143-
clickElementWithJs("remove-popover");
144-
145-
clickElementWithJs("open-dialog");
146-
clickElementWithJs("close-dialog");
147-
148-
waitForElementNotPresent(By.tagName("vaadin-dialog-overlay"));
149-
150-
clickTarget();
151-
checkPopoverIsOpened();
152-
}
153-
154138
private void clickTarget() {
155139
clickElementWithJs("popover-target");
156140
}

vaadin-popover-flow-parent/vaadin-popover-flow/src/test/java/com/vaadin/flow/component/popover/PopoverAutoAddTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,20 @@ public void setTarget_changeUI_autoAdded() {
153153
Assert.assertEquals(ui.getElement(), popover.getElement().getParent());
154154
}
155155

156+
@Test
157+
public void setTarget_openModal_popoverIsAttachedToUi() {
158+
Div target = new Div();
159+
Popover popover = new Popover();
160+
popover.setTarget(target);
161+
ui.add(target);
162+
163+
Div modalElement = new Div();
164+
ui.setChildComponentModal(modalElement, true);
165+
fakeClientResponse();
166+
167+
Assert.assertEquals(ui, popover.getParent().orElseThrow());
168+
}
169+
156170
private void fakeClientResponse() {
157171
ui.getInternals().getStateTree().runExecutionsBeforeClientResponse();
158172
ui.getInternals().getStateTree().collectChanges(ignore -> {

0 commit comments

Comments
 (0)