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+BUGFIX] Refactor query params tests #14433

Merged
merged 4 commits into from
Oct 12, 2016

Conversation

trentmwillis
Copy link
Member

@trentmwillis trentmwillis commented Oct 7, 2016

This PR refactors the Query Param tests to use a setup similar to the ember-glimmer tests. It also adds a few tests that were identified as gaps in the original coverage. The primary goal is to provide a set of abstractions to make writing/maintaining these tests easier.

The follow-up to this PR will be to better organize these tests so that we can more easily identify potential gaps in coverage.

@trentmwillis trentmwillis force-pushed the qp-tests branch 2 times, most recently from 9e79817 to 685f81f Compare October 10, 2016 21:18
@trentmwillis trentmwillis changed the title [WIP][CLEANUP] Refactor query params tests [CLEANUP] Refactor query params tests Oct 10, 2016
@trentmwillis
Copy link
Member Author

This PR is ready to review now. There are a couple skipped tests / fixmes which I am unsure how to address. They've been brought up in #dev-router on Slack and will try to get resolution before moving forward on this.

@trentmwillis trentmwillis changed the title [CLEANUP] Refactor query params tests [CLEANUP+BUGFIX] Refactor query params tests Oct 11, 2016
@trentmwillis
Copy link
Member Author

trentmwillis commented Oct 11, 2016

This should be ready to go now. I fixed the above issues based on discussions in Slack (documented as separate commits).

Edit: I can break out the commits into separate PRs if needed/desired.

let queryParams = getQueryParamsFor(route, state);

return Object.keys(queryParams).reduce((params, key) => {
assert(`The route '${this.routeName}' has both a dynamic segment and query param with name '${key}'. Please rename one to avoid collisions.`, !params[key]);
Copy link
Contributor

@ef4 ef4 Oct 11, 2016

Choose a reason for hiding this comment

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

Could people have gotten away with this before? New assertions smell like new public API that may need to get documented.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sort of. This assertion used to be done during _serializeQueryParams, which means that it caught the issue the majority of the time, but would miss it if landing on a route with colliding params first (since we didn't serialize the params, they were just given).

Additionally, this should be a slight performance win since this will cache after the first attempt to look up the QPs for a given route. Previously, the collision check happened for every serialization of every link.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh nevermind, thought this was on a different part of the code. Yeah this is a new assertion, we can drop this if needed, but the behavior in this case has never really been defined

@rwjblue rwjblue merged commit ae0ca0f into emberjs:master Oct 12, 2016
@rwjblue
Copy link
Member

rwjblue commented Oct 12, 2016

Thanks @trentmwillis!

return {
location: 'test'
};
}
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Extend both from the same place?

Copy link
Member Author

Choose a reason for hiding this comment

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

Will address this in my next PR.

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.

4 participants