-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: multiple fast navigate calls #20446
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
da85da1
fix: multiple fast navigate calls
caalador cf17bd6
Merge branch 'main' into issues/20404-multiple-navigate-break-blocker
caalador c849bf2
Queue new navigations during ongoing navigation.
caalador 7848db7
Merge branch 'main' into issues/20404-multiple-navigate-break-blocker
mshabarov 64fce83
fix blocker nav for basepath
caalador 0dcd547
Merge branch 'main' into issues/20404-multiple-navigate-break-blocker
caalador 39c2e51
Remove test class and selenium dependency.
caalador e60dba1
Formatter
caalador File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(); | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm worrying about maintenance for this: future Chrome updates can be incompatible with the ChromeDriver, so we have to bump this version all the time.
If the test always passes, maybe we can disable it, so it will show case the failing scenario, but won't run in CI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed test and added doc on the view class.