Skip to content
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

AnchorTester should support Anchors having query parameters #1811

Closed
joelpop opened this issue Jul 8, 2024 · 0 comments · Fixed by #1812
Closed

AnchorTester should support Anchors having query parameters #1811

joelpop opened this issue Jul 8, 2024 · 0 comments · Fixed by #1812
Labels
UITest JUnit testing the UI

Comments

@joelpop
Copy link
Collaborator

joelpop commented Jul 8, 2024

Currently AnchorTester fails when click-testing an Anchor having query parameters in its href because the location parameter of the navigate method does not accept them.

So instead of calling

UI.getCurrent().navigate(getComponent().getHref());

the path and the query parameters should be passed separately, as in

UI.getCurrent().navigate(getPath(), getQueryParameters());

where the following methods are present

    /**
     * Gets the path for the router-link.
     * Returns an empty {@link String} if there is no corresponding navigation target.
     *
     * @return a {@link String} containing the navigation target path or empty if not present
     */
    public String getPath() {
        return URI.create(getHref()).getPath();
    }

    /**
     * Gets the query parameters for the router-link.
     *
     * @return a {@link QueryParameters} containing the navigation target's query parameters
     */
    public QueryParameters getQueryParameters() {
        return QueryParameters.fromString(URI.create(getHref()).getQuery());
    }

which is how RouterLinkTester is implemented.

@joelpop joelpop added the UITest JUnit testing the UI label Jul 8, 2024
mcollovati added a commit that referenced this issue Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
UITest JUnit testing the UI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant