-
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.
chore: add ignored test for long polling and @PreserveOnRefresh (#10317)
* add IT to isolate the problem * ignore until flow issue #10103 is fixed
- Loading branch information
Showing
3 changed files
with
122 additions
and
1 deletion.
There are no files selected for viewing
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
46 changes: 46 additions & 0 deletions
46
...ext/src/main/java/com/vaadin/flow/uitest/ui/PushLongPollingWithPreserveOnRefreshView.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,46 @@ | ||
/* | ||
* Copyright 2000-2021 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.page.Push; | ||
import com.vaadin.flow.router.PreserveOnRefresh; | ||
import com.vaadin.flow.router.Route; | ||
import com.vaadin.flow.shared.ui.Transport; | ||
|
||
@PreserveOnRefresh | ||
@Push(transport = Transport.LONG_POLLING) | ||
@Route("com.vaadin.flow.uitest.ui.PushLongPollingWithPreserveOnRefreshView") | ||
public class PushLongPollingWithPreserveOnRefreshView extends Div { | ||
|
||
public static final String ADD_BUTTON_ID = "add-button-id"; | ||
public static final String TEST_DIV_ID = "test-div-id"; | ||
public static final String TEXT_IN_DIV = "text in div"; | ||
|
||
public PushLongPollingWithPreserveOnRefreshView() { | ||
NativeButton button = new NativeButton("Open Dialog", | ||
e -> e.getSource().getUI().ifPresent(ui -> { | ||
Div div = new Div(); | ||
div.setText(TEXT_IN_DIV); | ||
div.setId(TEST_DIV_ID); | ||
ui.add(div); | ||
})); | ||
button.setId(ADD_BUTTON_ID); | ||
add(button); | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
...ntext/src/test/java/com/vaadin/flow/uitest/ui/PushLongPollingWithPreserveOnRefreshIT.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,76 @@ | ||
/* | ||
* Copyright 2000-2021 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.Ignore; | ||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.NoSuchElementException; | ||
|
||
import com.vaadin.flow.testcategory.IgnoreOSGi; | ||
import com.vaadin.flow.testutil.ChromeBrowserTest; | ||
|
||
import static com.vaadin.flow.uitest.ui.PushLongPollingWithPreserveOnRefreshView.ADD_BUTTON_ID; | ||
import static com.vaadin.flow.uitest.ui.PushLongPollingWithPreserveOnRefreshView.TEST_DIV_ID; | ||
import static com.vaadin.flow.uitest.ui.PushLongPollingWithPreserveOnRefreshView.TEXT_IN_DIV; | ||
|
||
@Category(IgnoreOSGi.class) | ||
public class PushLongPollingWithPreserveOnRefreshIT extends ChromeBrowserTest { | ||
|
||
@Ignore("https://github.com/vaadin/flow/issues/10103") | ||
@Test | ||
public void addDiv_refreshThePage_ensureNoErrorHappensAndDivIsPresent() { | ||
|
||
open(); | ||
|
||
waitPageLoad(); | ||
|
||
findElement(By.id(ADD_BUTTON_ID)).click(); | ||
|
||
ensureDivIsPresent(); | ||
|
||
// refresh the browser | ||
getDriver().navigate().refresh(); | ||
|
||
waitPageLoad(); | ||
|
||
ensureNoErrorIsDisplayed(); | ||
|
||
ensureDivIsPresent(); | ||
} | ||
|
||
private void waitPageLoad() { | ||
WebElement loadingIndicator = findElement( | ||
By.className("v-loading-indicator")); | ||
waitUntil(driver -> !loadingIndicator.isDisplayed()); | ||
} | ||
|
||
private void ensureNoErrorIsDisplayed() { | ||
Assert.assertThrows(NoSuchElementException.class, | ||
() -> findElement(By.className("v-system-error"))); | ||
} | ||
|
||
private void ensureDivIsPresent() { | ||
WebElement div = findElement(By.id(TEST_DIV_ID)); | ||
|
||
Assert.assertNotNull(div); | ||
Assert.assertEquals(TEXT_IN_DIV, div.getText()); | ||
} | ||
} |