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

[Bug] <LinkTo> fails to generate href in integration tests if linked route has a dynamic segment and no model is provided. #19856

Open
lougreenwood opened this issue Nov 30, 2021 · 0 comments

Comments

@lougreenwood
Copy link

lougreenwood commented Nov 30, 2021

🐞 Describe the Bug

Prior to 3.24, when testing a component which contains a <LinkTo /> linked to a route with a dynamic segment, but a model was not provided the user would see the following error:

You attempted to generate a link for the "with-dynamic-segment" route, but did not pass the models required for
generating its dynamic segments

Since 3.24 there is no error and instead a LinkTo without an href is rendered.

This is very confusing since it seems like some links are just not working. It took quite a bit of debugging to realise that the lack of model arg was the problem. The old error message made it very obvious that something needed fixing to get linkto working as expected.

One possible solution would be to render an href with undefined in place of dynamic segment parts of the path.

for example:

<LinkTo @route="some-route-with-dynamic-section" />

// outputs
href="/some-route-with-dynamic-section/undefined"

🔬 Minimal Reproduction

https://github.com/lougreenwood/no-href-for-routes-with-dynamic-segments

  • Run the tests

  • See that links are generated with no href

  • Change to version < 3.24

  • See that we see an error

😕 Actual Behavior

Links in integration tests are missing href when <LinkTo /> without model for a route with a dynamic sections is rendered

🤔 Expected Behavior

A best effort to construct a href is made and missing dynamic sections are undefined in the generated URL.

🌍 Environment

  • Ember: -
  • Node.js/npm: -
  • OS: -
  • Browser: -

➕ Additional Context

Related:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants