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

Fix frost toggle click handler #438

Merged
merged 17 commits into from
Apr 27, 2017
Merged

Fix frost toggle click handler #438

merged 17 commits into from
Apr 27, 2017

Conversation

job13er
Copy link
Contributor

@job13er job13er commented Apr 26, 2017

This project uses semver, please check the scope of this pr:

  • #none# - documentation fixes and/or test additions
  • #patch# - backwards-compatible bug fix
  • #minor# - adding functionality in a backwards-compatible manner
  • #major# - incompatible API change

Since I made a few, unrelated changes in this PR, I tried to group my commits in a meaningful way. By looking at the diffs per commit, you should be able to understand what changes were needed for what effect. If it's unclear, just ask.

CHANGELOG

  • Upgraded to [email protected]
  • Upgraded to [email protected] (using a pinned [email protected] so as to avoid overwriting require and breaking ember-cli-code-coverage)
  • Enabled code coverage gating in PRs.
  • Added onToggle callback which is called with the new value whenever toggled
  • Deprecated onClick callback, which wasn't handling raw functions very well when going through the event proxy
  • Fixed #439 Properly handle falsy trueValue/falseValue when trueLabel/falseLabel are set

@@ -0,0 +1,19 @@
module.exports = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No actual change in this guy, just reformatting from .eslintrc to .eslintrc.js b/c javascript > json 😉

package.json Outdated
@@ -46,7 +46,7 @@
"ember-cli-notifications": "^4.1.6",
"ember-cli-test-loader": "^1.1.1",
"ember-cli-uglify": "^1.2.0",
"ember-code-snippet": "^1.8.0",
"ember-code-snippet": "ciena-blueplanet/ember-code-snippet#remove-browserify",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did raise an issue with ember-code-snippet to make them aware of the issue, but in the meantime, we can just use our fork.

package.json Outdated
@@ -98,5 +98,8 @@
"ember-spread": "^1.1.1",
"fs-extra-promise": "^0.4.0",
"npm-install-security-check": "^1.0.0"
},
"pr-bumper": {
"coverage": 92.72
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will help ensure that code coverage doesn't drop as the result of a PR

@sglanzer-deprecated
Copy link
Contributor

sglanzer-deprecated commented Apr 26, 2017

Approved

Approved with PullApprove

@sglanzer-deprecated
Copy link
Contributor

Looks like a few tests need to be updated to deal with true/false CPs in the toggle being readOnly - I'd probably recommend removing those unit tests since we've agreed that integration tests should cover components in a black-box approach

@job13er
Copy link
Contributor Author

job13er commented Apr 26, 2017

Looks like a few tests need to be updated to deal with true/false CPs in the toggle being readOnly - I'd probably recommend removing those unit tests since we've agreed that integration tests should cover components in a black-box approach

Sounds good. I was gonna refactor the unit tests, but just updating the integration tests to make sure all the use-cases are covered sounds much better.

@job13er
Copy link
Contributor Author

job13er commented Apr 27, 2017

@sglanzer Worth taking another look, this is a bit different since you approved last. It now implements the onToggle as we discussed in slack, and deprecates onClick

@job13er
Copy link
Contributor Author

job13er commented Apr 27, 2017

Hold on, just found another bug, closing this while I fix it. Will re-open once I have the new tests/fix in place.

@job13er job13er closed this Apr 27, 2017
@job13er job13er reopened this Apr 27, 2017
@job13er
Copy link
Contributor Author

job13er commented Apr 27, 2017

OK @sglanzer I think it's ready for review again. Sorry for the hold-up.

@job13er
Copy link
Contributor Author

job13er commented Apr 27, 2017

Hmm.

pr-bumper: ERROR: Code Coverage: 91.94% (dropped 0.78% from 92.72%)

Looks like I need to add a couple more tests. Coming right up.

@@ -53,45 +58,44 @@ export default Component.extend(SpreadMixin, PropTypeMixin, FrostEventsProxyMixi
},

getDefaultProps () {
const falseLabel = this.get('falseLabel')
const trueLabel = this.get('trueLabel')
const validTypes = ['string', 'number', 'boolean']
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm honestly not sure why we would care about the type of the label - I know this was there in the previous code, I just can't think of any reason for it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Me either. The label should always be a string, and spec'd that way in propTypes in my opinion, but I didn't want to change functionality in this PR, just clean up the code :)

_trueValue (trueValue, _trueLabel) { // eslint-disable-line
return trueValue || _trueLabel
_trueValue (trueValue, _trueLabel) {
return (trueValue === undefined) ? _trueLabel : trueValue
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably another case where we can't change this due to backwards compatibility, but it probably makes more sense to default to true instead of using the label as the value (typically we would use the value as a label, not the other way around)

_falseValue (falseValue, _falseLabel) { // eslint-disable-line
return falseValue || _falseLabel
_falseValue (falseValue, _falseLabel) {
return (falseValue === undefined) ? _falseLabel : falseValue
Copy link
Contributor

Choose a reason for hiding this comment

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

Same obviously - likely we can't do anything about these comments, but maybe we can make an LTS issue pointing to this PR so that we can cleanup in the next release

@sglanzer-deprecated
Copy link
Contributor

sglanzer-deprecated commented Apr 27, 2017

Approved - all good from my end - re-kicked a few failed builds (3 passed, it's probably just travis)

Approved with PullApprove

@job13er
Copy link
Contributor Author

job13er commented Apr 27, 2017

Could be the code coverage still. I'll take a look and either adjust the baseline (since I'm only enabling it in this PR anyway) or add some missing tests elsewhere to increase coverage. I did make sure I was covering toggle well. The only bit not covered was some code I couldn't figure out how to reach, but didn't want to delete for backwards compatibility.

@sglanzer-deprecated
Copy link
Contributor

Raised an issue to track the comments we can't address currently #440

@sglanzer-deprecated
Copy link
Contributor

@job13er yeah, you're getting code coverage drops, but only in 2 of the builds (used to be 3) - we may need to be careful about that strategy

@job13er
Copy link
Contributor Author

job13er commented Apr 27, 2017

Yeah, should only be checking in one build, I'll fix it.

@juwara0
Copy link
Contributor

juwara0 commented Apr 27, 2017

@job13er
Copy link
Contributor Author

job13er commented Apr 27, 2017

Something screwy is going on. I shouldn't be getting different coverage numbers for different builds. We don't have conditional code based on ember/noe version (to the best of my knowledge)

@sglanzer-deprecated
Copy link
Contributor

Yeah, I'm not sure what that's about - maybe we only want to run coverage numbers against the LTS release build?

@@ -0,0 +1,15 @@
#!/bin/bash
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should let us only check coverage on the same build where we bump.

@sglanzer-deprecated
Copy link
Contributor

sglanzer-deprecated commented Apr 27, 2017

Approved

Approved with PullApprove

@job13er
Copy link
Contributor Author

job13er commented Apr 27, 2017

I'm stuck behind bunsen builds, so it may be a while :(

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 38d0bc9 on job13er:fix-frost-toggle-click-handler into ** on ciena-frost:master**.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 44d3c17 on job13er:fix-frost-toggle-click-handler into ** on ciena-frost:master**.

@job13er
Copy link
Contributor Author

job13er commented Apr 27, 2017

Approved

Approved with PullApprove

@job13er job13er merged commit dccc7a3 into ciena-frost:master Apr 27, 2017
@sglanzer-deprecated
Copy link
Contributor

Woooh, finally got it merged - good stuff 👍

@job13er job13er deleted the fix-frost-toggle-click-handler branch April 28, 2017 15:28
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.

5 participants