You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The basic idea is that when a link doesn’t specify the value for a query
param, the current value is preserved.
So, given the hierarchy
```
qps // defines a QP named “string”
qps.details // defines a QP named “nestedString”
qps.details.more // defines a QP named “doubleNestedString”
```
Links inside `qps.details.more` that point to `qps.details` will contain
“nestedString=bar&string=foo”, but never “doubleNestedString”.
Links inside `qps.details` that point to `qps` will contain “string=foo”,
but never “nestedString” or “doubleNestedString”.
Links inside `qps.details` that point to `qps.details` with a different
will model will contain “string=foo” but never “nestedString” or “doubleNestedString”.
Links from a route to any descendant route will always include all the
query params defined in the path.
test('links without explicitly passed query params include query params of ancestor routes, but no those of child or sibling routes',function(assert){
110
+
visit('/qps');
111
+
112
+
andThen(function(){
113
+
assert.equal(currentURL(),'/qps');
114
+
assert.equal(find('#qps-href-to').attr('href'),'/qps','The link to the current route route has no query params');
115
+
assert.equal(find('.href-tos a:eq(0)').attr('href'),'/qps/1','The link to a child route has no query params');
116
+
fillIn('#qps-input-text','foo');
117
+
});
118
+
119
+
andThen(function(){
120
+
assert.equal(find('#qps-href-to').attr('href'),'/qps?string=foo','The link to a parent route has the query params defined on that route');
121
+
assert.equal(find('.href-tos a:eq(0)').attr('href'),'/qps/1?string=foo','The url the current route has the query params');
122
+
leftClick('.href-tos a:eq(0)');
123
+
});
124
+
125
+
andThen(function(){
126
+
assert.equal(currentURL(),'/qps/1?string=foo');
127
+
fillIn('#qps-input-nested-text','bar');
128
+
});
129
+
130
+
andThen(function(){
131
+
assert.equal(find('#qps-href-to').attr('href'),'/qps?string=foo','The link to a parent route has the query param defined on thar route but not in child routes');
132
+
assert.equal(find('.href-tos a:eq(0)').attr('href'),'/qps/1?nestedString=bar&string=foo','The url to the current route has the both the query params of parent routes and those in the current one');
133
+
assert.equal(find('.href-tos a:eq(1)').attr('href'),'/qps/2?string=foo','The url to the current route with a different model has only the query params in the parent');
134
+
assert.equal(find('#qps-details-more-href-to').attr('href'),'/qps/1/more?nestedString=bar&string=foo','The url to the current route has the both the query params of parent routes and those in the current one');
135
+
leftClick('#qps-details-more-href-to');
136
+
});
137
+
138
+
andThen(function(){
139
+
assert.equal(currentURL(),'/qps/1?string=foo');
140
+
fillIn('#qps-input-double-nested-text','qux');
141
+
});
142
+
143
+
andThen(function(){
144
+
assert.equal(find('#qps-href-to').attr('href'),'/qps?string=foo','The link to a parent route has the query param defined on thar route but not in child routes');
145
+
assert.equal(find('.href-tos a:eq(0)').attr('href'),'/qps/1?nestedString=bar&string=foo','The url to the parent route has his query params and those of the grandparent route, but not those in the current route');
146
+
assert.equal(find('.href-tos a:eq(1)').attr('href'),'/qps/2?string=foo','The url to the parent route with a different model has only the query params in the grand parent route');
147
+
assert.equal(find('#qps-details-more-href-to').attr('href'),'/qps/1/more?doubleNestedString=qux&nestedString=bar&string=foo','The url to the current route has the both the query params of parent routes and those in the current one');
0 commit comments