-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test view for manual testing. Test script doesn't fail on double click.
- Loading branch information
Showing
6 changed files
with
154 additions
and
2 deletions.
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
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
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
22 changes: 22 additions & 0 deletions
22
flow-tests/test-react-router/src/main/frontend/NavigateView.tsx
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,22 @@ | ||
import {useNavigate} from "react-router-dom"; | ||
import { | ||
ReactAdapterElement, | ||
RenderHooks | ||
} from "Frontend/generated/flow/ReactAdapter"; | ||
|
||
class NavigateView extends ReactAdapterElement { | ||
protected render(hooks: RenderHooks): React.ReactElement | null { | ||
const navigate = useNavigate(); | ||
|
||
return ( | ||
<> | ||
<p id="react">This is a simple view for a React route</p> | ||
<button id="react-navigate" onClick={() => navigate("com.vaadin.flow.RouterView"!)}> | ||
Navigate button | ||
</button> | ||
</> | ||
); | ||
} | ||
} | ||
|
||
customElements.define('navigate-view', NavigateView); |
29 changes: 29 additions & 0 deletions
29
flow-tests/test-react-router/src/main/java/com/vaadin/flow/ReactNavigateView.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,29 @@ | ||
/* | ||
* Copyright 2000-2024 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; | ||
|
||
import com.vaadin.flow.component.Tag; | ||
import com.vaadin.flow.component.dependency.JsModule; | ||
import com.vaadin.flow.component.react.ReactAdapterComponent; | ||
import com.vaadin.flow.router.Route; | ||
|
||
@Route("com.vaadin.flow.ReactNavigateView") | ||
@Tag("navigate-view") | ||
@JsModule("NavigateView.tsx") | ||
public class ReactNavigateView extends ReactAdapterComponent { | ||
|
||
} |
75 changes: 75 additions & 0 deletions
75
flow-tests/test-react-router/src/test/java/com/vaadin/flow/ReactNavigateIT.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,75 @@ | ||
/* | ||
* Copyright 2000-2024 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; | ||
|
||
import java.io.IOException; | ||
import java.time.Duration; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.openqa.selenium.chrome.ChromeDriver; | ||
import org.openqa.selenium.remote.CommandExecutor; | ||
import org.openqa.selenium.support.ui.ExpectedConditions; | ||
import org.openqa.selenium.remote.Command; | ||
|
||
import com.vaadin.flow.component.html.testbench.NativeButtonElement; | ||
import com.vaadin.flow.testutil.ChromeBrowserTest; | ||
import com.vaadin.testbench.TestBenchDriverProxy; | ||
|
||
public class ReactNavigateIT extends ChromeBrowserTest { | ||
|
||
@Test | ||
public void testSlowNavigation_clickReactNavigateButtonTwice_noExceptionInLogs() | ||
throws IOException { | ||
open(); | ||
ChromeDriver driver = (ChromeDriver) ((TestBenchDriverProxy) getDriver()) | ||
.getWrappedDriver(); | ||
|
||
CommandExecutor executor = driver.getCommandExecutor(); | ||
Map map = new HashMap(); | ||
map.put("offline", false); | ||
map.put("latency", 100); | ||
|
||
map.put("download_throughput", 1800); | ||
map.put("upload_throughput", 400); | ||
|
||
executor.execute(new Command(driver.getSessionId(), | ||
"setNetworkConditions", ImmutableMap.of("network_conditions", | ||
ImmutableMap.copyOf(map)))); | ||
|
||
waitUntil(drvr -> $(NativeButtonElement.class).id("react-navigate") | ||
.isDisplayed()); | ||
|
||
NativeButtonElement navigateButton = $(NativeButtonElement.class) | ||
.id("react-navigate"); | ||
|
||
// timout and requestAnimationFrame will give an undefined for the | ||
// button. | ||
driver.executeScript("arguments[0].click();arguments[0].click();", | ||
navigateButton); | ||
|
||
waitUntil(ExpectedConditions.stalenessOf(navigateButton)); | ||
|
||
checkLogsForErrors(); | ||
|
||
} | ||
|
||
} |