Skip to content

[CLEANUP beta] Remove Application Controller Router Properties#19707

Merged
mixonic merged 1 commit intoemberjs:masterfrom
btecu:mouse
Aug 22, 2021
Merged

[CLEANUP beta] Remove Application Controller Router Properties#19707
mixonic merged 1 commit intoemberjs:masterfrom
btecu:mouse

Conversation

@btecu
Copy link
Contributor

@btecu btecu commented Aug 20, 2021

No description provided.

@mixonic mixonic changed the title [CLEANUP] Remove Application Controller Router Properties [CLEANUP beta] Remove Application Controller Router Properties Aug 21, 2021
Copy link
Member

@mixonic mixonic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@btecu I think in the testing suite in general (both in places I flagged and even in places I didn't flag) the right path here is to refactor the assertions to use the router service public API instead of the application controller API. Removing the assertions (or tests) entirely is too much of a change, and degrades out test coverage of how Ember reflect routing state.

Can you give it another look through that lens?


expectDeprecation(() => {
let currentRouteName = this.applicationInstance
.lookup('controller:application')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this test was specifically testing deprecated behavior, I think the deprecated API was only used during test of a legitimate behavior we want to retain.

I believe the right approach here is to refactor the test to use the router service instead of currentRouteName via the application controller, remove the expectDeprecation( code, and retain the test.

Can you dig into it?


expectDeprecation(() => {
let currentRouteName = this.applicationInstance
.lookup('controller:application')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, I this test should be retained with the other expectDeprecation left in place, but the code for the specific deprecated API removed here refactored.


assert.equal(location.getURL(), '/one');
expectDeprecation(() => {
assert.equal(get(initialApplicationController, 'currentPath'), 'one');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to above, can this assertion be changed to assert the router service with currentRoutePath? https://api.emberjs.com/ember/3.27/classes/RouterService/properties/currentRouteName?anchor=currentRouteName

This is an integration test, and I wouldn't want to lose the coverage that Ember's routing system in general is up to date after a visit call.


assert.equal(location.getURL(), '/one');
expectDeprecation(() => {
assert.equal(get(applicationController, 'currentPath'), 'one');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here as elsewhere in this file.

get currentPath() {
let currentPath;
expectDeprecation(() => {
currentPath = this.applicationInstance.lookup('controller:application').get('currentPath');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...and again here, use the router service.

(I'm surprised these were not all refactored when the deprecation was added.)

@mixonic mixonic mentioned this pull request Aug 22, 2021
58 tasks
@btecu btecu force-pushed the mouse branch 2 times, most recently from 4b70848 to 80b9a35 Compare August 22, 2021 17:49
@btecu
Copy link
Contributor Author

btecu commented Aug 22, 2021

@mixonic updated.

Copy link
Member

@mixonic mixonic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@btecu this is amazing!!

@mixonic mixonic merged commit b327ad8 into emberjs:master Aug 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants