Skip to content

Commit a77343f

Browse files
authored
Merge pull request #19450 from sly7-7/test-for-19449
2 parents 29199ea + d938005 commit a77343f

File tree

4 files changed

+94
-44
lines changed

4 files changed

+94
-44
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
"rollup-plugin-commonjs": "^9.3.4",
142142
"rollup-plugin-node-resolve": "^4.2.4",
143143
"route-recognizer": "^0.3.4",
144-
"router_js": "^7.2.0",
144+
"router_js": "^7.3.0",
145145
"rsvp": "^4.8.5",
146146
"serve-static": "^1.14.1",
147147
"simple-dom": "^1.4.0",

packages/@ember/-internals/routing/lib/system/router.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,12 @@ class EmberRouter extends EmberObject {
286286

287287
routeWillChange(transition: Transition) {
288288
router.trigger('routeWillChange', transition);
289+
// in case of intermediate transition we update the current route
290+
// to make router.currentRoute.name consistent with router.currentRouteName
291+
// see https://github.com/emberjs/ember.js/issues/19449
292+
if (transition.isIntermediate) {
293+
router.set('currentRoute', transition.to);
294+
}
289295
}
290296

291297
routeDidChange(transition: Transition) {

packages/ember/tests/routing/router_service_test/currenturl_lifecycle_test.js

Lines changed: 83 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ let InstrumentedRoute = Route.extend({
1717
let service = get(this, 'routerService');
1818
service.on('routeWillChange', (transition) => {
1919
results.push([
20-
service.get('currentRouteName'),
20+
`${service.get('currentRouteName')} - ${service.get('currentRoute.name')}`,
2121
`${this.routeName} routeWillChange: ${transition.from && transition.from.name} - ${
2222
transition.to.name
2323
}`,
@@ -26,7 +26,7 @@ let InstrumentedRoute = Route.extend({
2626
});
2727
service.on('routeDidChange', (transition) => {
2828
results.push([
29-
service.get('currentRouteName'),
29+
`${service.get('currentRouteName')} - ${service.get('currentRoute.name')}`,
3030
`${this.routeName} routeDidChange: ${transition.from && transition.from.name} - ${
3131
transition.to.name
3232
}`,
@@ -38,7 +38,7 @@ let InstrumentedRoute = Route.extend({
3838
activate() {
3939
let service = get(this, 'routerService');
4040
results.push([
41-
service.get('currentRouteName'),
41+
`${service.get('currentRouteName')} - ${service.get('currentRoute.name')}`,
4242
`${this.routeName} activate`,
4343
service.get('currentURL'),
4444
]);
@@ -47,7 +47,7 @@ let InstrumentedRoute = Route.extend({
4747
redirect() {
4848
let service = get(this, 'routerService');
4949
results.push([
50-
service.get('currentRouteName'),
50+
`${service.get('currentRouteName')} - ${service.get('currentRoute.name')}`,
5151
`${this.routeName} redirect`,
5252
service.get('currentURL'),
5353
]);
@@ -56,7 +56,7 @@ let InstrumentedRoute = Route.extend({
5656
beforeModel() {
5757
let service = get(this, 'routerService');
5858
results.push([
59-
service.get('currentRouteName'),
59+
`${service.get('currentRouteName')} - ${service.get('currentRoute.name')}`,
6060
`${this.routeName} beforeModel`,
6161
service.get('currentURL'),
6262
]);
@@ -65,7 +65,7 @@ let InstrumentedRoute = Route.extend({
6565
model() {
6666
let service = get(this, 'routerService');
6767
results.push([
68-
service.get('currentRouteName'),
68+
`${service.get('currentRouteName')} - ${service.get('currentRoute.name')}`,
6969
`${this.routeName} model`,
7070
service.get('currentURL'),
7171
]);
@@ -77,7 +77,7 @@ let InstrumentedRoute = Route.extend({
7777
afterModel() {
7878
let service = get(this, 'routerService');
7979
results.push([
80-
service.get('currentRouteName'),
80+
`${service.get('currentRouteName')} - ${service.get('currentRoute.name')}`,
8181
`${this.routeName} afterModel`,
8282
service.get('currentURL'),
8383
]);
@@ -87,7 +87,7 @@ let InstrumentedRoute = Route.extend({
8787
willTransition(transition) {
8888
let service = get(this, 'routerService');
8989
results.push([
90-
service.get('currentRouteName'),
90+
`${service.get('currentRouteName')} - ${service.get('currentRoute.name')}`,
9191
`${this.routeName} willTransition: ${transition.from && transition.from.name} - ${
9292
transition.to.name
9393
}`,
@@ -98,7 +98,7 @@ let InstrumentedRoute = Route.extend({
9898
didTransition() {
9999
let service = get(this, 'routerService');
100100
results.push([
101-
service.get('currentRouteName'),
101+
`${service.get('currentRouteName')} - ${service.get('currentRoute.name')}`,
102102
`${this.routeName} didTransition`,
103103
service.get('currentURL'),
104104
]);
@@ -108,7 +108,7 @@ let InstrumentedRoute = Route.extend({
108108
});
109109

110110
moduleFor(
111-
'Router Service - currentURL | currentRouteName',
111+
'Router Service - currentURL | currentRouteName | currentRoute.name',
112112
class extends RouterTestCase {
113113
constructor() {
114114
super(...arguments);
@@ -189,18 +189,26 @@ moduleFor(
189189
return this.visit('/')
190190
.then(() => {
191191
assert.deepEqual(results, [
192-
[null, 'parent.index routeWillChange: null - parent.index', null],
193-
[null, 'parent.index beforeModel', null],
194-
[null, 'parent.index model', null],
195-
[null, 'parent.loading activate', null],
196-
[null, 'parent.loading routeWillChange: null - parent.loading', null],
197-
[null, 'parent.index routeWillChange: null - parent.loading', null],
198-
['parent.loading', 'parent.index afterModel', '/'],
199-
['parent.loading', 'parent.index redirect', '/'],
200-
['parent.loading', 'parent.index activate', '/'],
201-
['parent.loading', 'parent.index didTransition', '/'],
202-
['parent.index', 'parent.loading routeDidChange: null - parent.index', '/'],
203-
['parent.index', 'parent.index routeDidChange: null - parent.index', '/'],
192+
['null - undefined', 'parent.index routeWillChange: null - parent.index', null],
193+
['null - undefined', 'parent.index beforeModel', null],
194+
['null - undefined', 'parent.index model', null],
195+
['null - undefined', 'parent.loading activate', null],
196+
['null - undefined', 'parent.loading routeWillChange: null - parent.loading', null],
197+
['null - undefined', 'parent.index routeWillChange: null - parent.loading', null],
198+
['parent.loading - parent.loading', 'parent.index afterModel', '/'],
199+
['parent.loading - parent.loading', 'parent.index redirect', '/'],
200+
['parent.loading - parent.loading', 'parent.index activate', '/'],
201+
['parent.loading - parent.loading', 'parent.index didTransition', '/'],
202+
[
203+
'parent.index - parent.index',
204+
'parent.loading routeDidChange: null - parent.index',
205+
'/',
206+
],
207+
[
208+
'parent.index - parent.index',
209+
'parent.index routeDidChange: null - parent.index',
210+
'/',
211+
],
204212
]);
205213

206214
results = [];
@@ -209,27 +217,63 @@ moduleFor(
209217
})
210218
.then(() => {
211219
assert.deepEqual(results, [
212-
['parent.index', 'parent.index willTransition: parent.index - parent.child', '/'],
213-
['parent.index', 'parent.child routeWillChange: parent.index - parent.child', '/'],
214-
['parent.index', 'parent.loading routeWillChange: parent.index - parent.child', '/'],
215-
['parent.index', 'parent.index routeWillChange: parent.index - parent.child', '/'],
216-
['parent.index', 'parent.child beforeModel', '/'],
217-
['parent.index', 'parent.child model', '/'],
218-
['parent.index', 'parent.loading activate', '/'],
219-
['parent.index', 'parent.child routeWillChange: parent.index - parent.loading', '/'],
220-
['parent.index', 'parent.loading routeWillChange: parent.index - parent.loading', '/'],
221-
['parent.index', 'parent.index routeWillChange: parent.index - parent.loading', '/'],
222-
['parent.loading', 'parent.child afterModel', '/child'],
223-
['parent.loading', 'parent.child redirect', '/child'],
224-
['parent.loading', 'parent.child activate', '/child'],
225-
['parent.loading', 'parent.child didTransition', '/child'],
226-
['parent.child', 'parent.child routeDidChange: parent.index - parent.child', '/child'],
227220
[
228-
'parent.child',
221+
'parent.index - parent.index',
222+
'parent.index willTransition: parent.index - parent.child',
223+
'/',
224+
],
225+
[
226+
'parent.index - parent.index',
227+
'parent.child routeWillChange: parent.index - parent.child',
228+
'/',
229+
],
230+
[
231+
'parent.index - parent.index',
232+
'parent.loading routeWillChange: parent.index - parent.child',
233+
'/',
234+
],
235+
[
236+
'parent.index - parent.index',
237+
'parent.index routeWillChange: parent.index - parent.child',
238+
'/',
239+
],
240+
['parent.index - parent.index', 'parent.child beforeModel', '/'],
241+
['parent.index - parent.index', 'parent.child model', '/'],
242+
['parent.index - parent.index', 'parent.loading activate', '/'],
243+
[
244+
'parent.index - parent.index',
245+
'parent.child routeWillChange: parent.index - parent.loading',
246+
'/',
247+
],
248+
[
249+
'parent.index - parent.index',
250+
'parent.loading routeWillChange: parent.index - parent.loading',
251+
'/',
252+
],
253+
[
254+
'parent.index - parent.index',
255+
'parent.index routeWillChange: parent.index - parent.loading',
256+
'/',
257+
],
258+
['parent.loading - parent.loading', 'parent.child afterModel', '/child'],
259+
['parent.loading - parent.loading', 'parent.child redirect', '/child'],
260+
['parent.loading - parent.loading', 'parent.child activate', '/child'],
261+
['parent.loading - parent.loading', 'parent.child didTransition', '/child'],
262+
[
263+
'parent.child - parent.child',
264+
'parent.child routeDidChange: parent.index - parent.child',
265+
'/child',
266+
],
267+
[
268+
'parent.child - parent.child',
229269
'parent.loading routeDidChange: parent.index - parent.child',
230270
'/child',
231271
],
232-
['parent.child', 'parent.index routeDidChange: parent.index - parent.child', '/child'],
272+
[
273+
'parent.child - parent.child',
274+
'parent.index routeDidChange: parent.index - parent.child',
275+
'/child',
276+
],
233277
]);
234278
});
235279
}

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8907,10 +8907,10 @@ route-recognizer@^0.3.4:
89078907
resolved "https://registry.yarnpkg.com/route-recognizer/-/route-recognizer-0.3.4.tgz#39ab1ffbce1c59e6d2bdca416f0932611e4f3ca3"
89088908
integrity sha512-2+MhsfPhvauN1O8KaXpXAOfR/fwe8dnUXVM+xw7yt40lJRfPVQxV6yryZm0cgRvAj5fMF/mdRZbL2ptwbs5i2g==
89098909

8910-
router_js@^7.2.0:
8911-
version "7.2.0"
8912-
resolved "https://registry.yarnpkg.com/router_js/-/router_js-7.2.0.tgz#a7168155fe494f85f1e5058802a3a633c29ea243"
8913-
integrity sha512-kZBOqD/kRMDymmVbiVrX6OK3cGBoG1c9tO8egxkoxX2TgC78sBwFhvFqkAJLvK8oTEXYNcjk8+FbNIn9hg9VMA==
8910+
router_js@^7.3.0:
8911+
version "7.3.0"
8912+
resolved "https://registry.yarnpkg.com/router_js/-/router_js-7.3.0.tgz#6c061b6b097cfec537fa0d6c5a5c6e317730799f"
8913+
integrity sha512-A+iVTfG03XNks7oC/KGXq+EKp9kAac9BOYuomq2KouXUM4U57Io20/tuQq1kx+OwHB4gEY0XaRQjuHwljkbRHg==
89148914
dependencies:
89158915
"@glimmer/env" "^0.1.7"
89168916

0 commit comments

Comments
 (0)