-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added an IT for the long-polling push case
- Loading branch information
1 parent
c8a30cb
commit ef557a6
Showing
2 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
...-tests/test-root-context/src/main/java/com/vaadin/flow/uitest/ui/LongPollingPushView.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,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); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
flow-tests/test-root-context/src/test/java/com/vaadin/flow/uitest/ui/LongPollingPushIT.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,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(); | ||
} | ||
|
||
} |