diff --git a/flow-tests/test-root-context/src/main/java/com/vaadin/flow/uitest/ui/LongPollingPushView.java b/flow-tests/test-root-context/src/main/java/com/vaadin/flow/uitest/ui/LongPollingPushView.java new file mode 100644 index 00000000000..3411d9c9494 --- /dev/null +++ b/flow-tests/test-root-context/src/main/java/com/vaadin/flow/uitest/ui/LongPollingPushView.java @@ -0,0 +1,45 @@ +/* + * Copyright 2000-2018 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.flow.uitest.ui; + +import com.vaadin.flow.component.html.Div; +import com.vaadin.flow.component.html.NativeButton; +import com.vaadin.flow.component.html.Span; +import com.vaadin.flow.component.page.Push; +import com.vaadin.flow.router.Route; +import com.vaadin.flow.shared.ui.Transport; + +/** + * Class for reproducing the bug https://github.com/vaadin/flow/issues/4353 + */ +@Route("com.vaadin.flow.uitest.ui.LongPollingPushView") +@Push(transport = Transport.LONG_POLLING) +public class LongPollingPushView extends AbstractDivView { + + public LongPollingPushView() { + Div parent = new Div(); + Span child = new Span("Some text"); + child.setId("child"); + parent.add(child); + add(parent); + parent.setVisible(false); + + NativeButton visibility = new NativeButton("Toggle visibility", + e -> parent.setVisible(!parent.isVisible())); + visibility.setId("visibility"); + add(visibility); + } +} diff --git a/flow-tests/test-root-context/src/test/java/com/vaadin/flow/uitest/ui/LongPollingPushIT.java b/flow-tests/test-root-context/src/test/java/com/vaadin/flow/uitest/ui/LongPollingPushIT.java new file mode 100644 index 00000000000..9f5d9693c61 --- /dev/null +++ b/flow-tests/test-root-context/src/test/java/com/vaadin/flow/uitest/ui/LongPollingPushIT.java @@ -0,0 +1,44 @@ +/* + * Copyright 2000-2018 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.flow.uitest.ui; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.flow.testutil.ChromeBrowserTest; + +public class LongPollingPushIT extends ChromeBrowserTest { + + @Test + public void openPage_thereAreNoErrorsInTheConsole() { + open(); + checkLogsForErrors(); + + waitForElementNotPresent(By.id("child")); + + WebElement button = findElement(By.id("visibility")); + button.click(); + + waitForElementPresent(By.id("child")); + + WebElement span = findElement(By.id("child")); + Assert.assertEquals("Some text", span.getText()); + checkLogsForErrors(); + } + +}