Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLEANUP beta] Remove Application Controller Router Properties #19707

Merged
merged 1 commit into from Aug 22, 2021

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
Sponsor 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
Sponsor 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
Sponsor 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.

@@ -129,9 +128,6 @@ moduleFor(
let location = initialRouter.get('location');

assert.equal(location.getURL(), '/one');
expectDeprecation(() => {
assert.equal(get(initialApplicationController, 'currentPath'), 'one');
Copy link
Sponsor 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.

@@ -160,9 +156,6 @@ moduleFor(
);

assert.equal(location.getURL(), '/one');
expectDeprecation(() => {
assert.equal(get(applicationController, 'currentPath'), 'one');
Copy link
Sponsor 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
Sponsor 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
Sponsor 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.

None yet

2 participants