Skip to content

Commit 38215f2

Browse files
committed
Add a test that verifies @model is stable between route transitions
This test doesn't actually reproduce the problem since a Glimmer component seems needed for that.
1 parent 482e62c commit 38215f2

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

packages/@ember/-internals/glimmer/tests/integration/application/rendering-test.js

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,99 @@ moduleFor(
398398
});
399399
}
400400

401+
async ['@test @model should be stable when transitioning out of the route']() {
402+
let assert = this.assert;
403+
404+
this.router.map(function () {
405+
this.route('a', function () {
406+
this.route('b');
407+
this.route('c');
408+
});
409+
this.route('d', function () {
410+
this.route('e');
411+
});
412+
this.route('f');
413+
});
414+
415+
this.addComponent('foo', {
416+
// TODO: use a Glimmer Component instead, since that's the requirement to make it fail
417+
ComponentClass: class extends Component {
418+
willDestroy() {
419+
assert.step(this.model);
420+
}
421+
},
422+
});
423+
this.add(
424+
'route:a',
425+
class extends Route {
426+
model() {
427+
return 'a';
428+
}
429+
}
430+
);
431+
this.add(
432+
'route:a.b',
433+
class extends Route {
434+
model() {
435+
return 'b';
436+
}
437+
}
438+
);
439+
this.addTemplate('a.b', '<Foo @model={{@model}} @controller={{this}} />');
440+
this.add(
441+
'route:a.c',
442+
class extends Route {
443+
model() {
444+
return 'c';
445+
}
446+
}
447+
);
448+
this.add(
449+
'route:d',
450+
class extends Route {
451+
model() {
452+
return 'd';
453+
}
454+
}
455+
);
456+
this.add(
457+
'route:d.e',
458+
class extends Route {
459+
model() {
460+
return 'e';
461+
}
462+
}
463+
);
464+
this.add(
465+
'route:f',
466+
class extends Route {
467+
model() {
468+
return 'f';
469+
}
470+
}
471+
);
472+
473+
await this.visit('/a/b');
474+
await this.visit('/a');
475+
476+
await this.visit('/a/b');
477+
await this.visit('/a/c');
478+
479+
await this.visit('/a/b');
480+
await this.visit('/d');
481+
482+
await this.visit('/a/b');
483+
await this.visit('/d/e');
484+
485+
await this.visit('/a/b');
486+
await this.visit('/f');
487+
488+
this.assert.verifySteps(
489+
['b', 'b', 'b', 'b', 'b'],
490+
'The @model property of the Foo component should be stable in the willDestroy hook'
491+
);
492+
}
493+
401494
['@test it should produce a stable DOM when the model changes']() {
402495
this.router.map(function () {
403496
this.route('color', { path: '/colors/:color' });

0 commit comments

Comments
 (0)