[Bug] `<LinkTo>` fails to generate href in integration tests if linked route has a dynamic segment and no model is provided.
- Dominant language
- TypeScript
- Stars
- 22.6k
- Forks
- 4.2k
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 15
Description
### 🐞 Describe the Bug
Prior to 3.24, when testing a component which contains a `` 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:
```
// 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 `` 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:
- https://discord.com/channels/480462759797063690/480523424121356298/913107904826048592
- https://github.com/emberjs/ember.js/issues/19364
- https://github.com/emberjs/ember.js/pull/19387#issuecomment-978226102
Contributor guide
Assessment
This issue has not been assessed yet.