-
Notifications
You must be signed in to change notification settings - Fork 78
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
Add new card component #668
Conversation
8e6dc09
to
5f5acc5
Compare
I got further on this one, but I had trouble with testing and handling it properly. Turns out, Ember does not detect the promise Then again, I'm up for trying that as well. Either way, I got the process to complete, so now it would be a matter of rendering errors and deciding what to do on success. Do we want to just display a message, or redirect to a whole new route (ex. |
@begedin do we need to be fixing the Stripe service? Open an issue there? |
@begedin in particular we were already having conversations over there about this code-corps/ember-stripe-service#12 |
@joshsmith I took a look at that issue already. Really, it's how ember behaves. I'm not really sure if we can do anything about it. Ember handles tracks some type of async stuff correctly, but not all of it. I stubbed out the stripe service for now, and that does the trick, but the downside is, if we change this addon, we will have to update the stub. The upside is, we're maintaining the addon. |
fa3c421
to
4e8fb03
Compare
Updated the to-do list. It doesn't seem like much was checked, but I think we're past the hard work, so now it's a matter of writing the templates for errors and deciding what to do when the user successfully donates. |
@joshsmith This should finally be good to review. The "Thank you page just displays a message for now". We can add a template, which will be mostly static, separately. |
I've mostly implemented the thank you page. The layout matches the provided wireframe and all that's missing is setting the src of the icon image. Referring #477 here, since it's about 95% solved by this. |
Got as far as I could tonight.
The process of adding cards needs more work:
I hope this helps. |
Adding these flow notes here for extra reference:
|
I've gone about as far as I can tonight. Still a number of failing tests due to changes. I'm wondering how much we should try to close this PR out soon and put things into separate issues. It's not as though |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good so far. Let me know where I can help 👍
isSelected: alias('card.selected'), | ||
|
||
click() { | ||
this.sendAction('select'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are passing this in as a closure action: this.get('select')();
|
||
isSubmitting: false, | ||
|
||
date: computed('month', 'year', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on simply renaming this to dateString
so it is clear we expect it to be a string and not a date object?
|
||
export default Component.extend({ | ||
classNames: ['create-donation'], | ||
presetAmounts: [10, 15, 25, 50], | ||
amount: 15 | ||
amount: 10, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add customAmount: null
here as well, so it is clear it's a property set on this component?
}; | ||
}, | ||
|
||
_updateAddingCardState() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For clarity (not to be too nitpicky), could we do disableAddingCardState
? update
implies that it could be anything--whereas this function will only set it to false.
|
||
{{#unless isSubmitting}} | ||
{{!validation errors can be passed in from parent, using a block}} | ||
{{yield}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I like this.
projectDonatePage.creditCard.cardNumber('4242-4242-4242-4242'); | ||
projectDonatePage.creditCard.cardCVC('123'); | ||
projectDonatePage.creditCard.cardMonth('12'); | ||
projectDonatePage.creditCard.cardYear('2020'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on extracting this block to a helper function since it is re-used?
K | ||
} = Ember; | ||
|
||
let setHandler = function(context, submitHandler = K) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on extracting this to a helper file since we use it so often?
assert.notOk($(input).prop('disabled')); | ||
stubService(this, 'stripe', { | ||
card: { | ||
validateCardNumber: () => true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're importing Ember.K
already, we can change these to validateCardNumber: K
, as it does the same thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved in 37a6024 as Ember.K
is no longer needed.
3e90c9f
to
973dfce
Compare
@@ -50,6 +54,4 @@ test('it sends submit with credit card fields when button is clicked', function( | |||
.cardYear(expectedProps.year) | |||
.cardCVC(expectedProps.cvc) | |||
.clickSubmit(); | |||
|
|||
assert.ok(page.submitDisabled, 'Submit button got disabled.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The component is destroyed at this point, so the _afterSubmit
method returns early and does not disable the button.
d0b6748
to
ad8ce82
Compare
}); | ||
|
||
test('it renders donation amount and frequency', function(assert) { | ||
test('it handles clicking card submit button correctly', function(assert) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joshsmith I'm questioning what we are testing here. Most of the actions in this particular test are for the credit card component. This test fails because of the submit action on donation/credit-card
(the child component). I think the test coverage for submitting should be handled there and we should only worry about rendering what is appropriate here, as this is really just the container of the components that hold the logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sbatson5 agreed. Feel free to modify at your leisure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joshsmith Revised here: eb48a06. I think this focuses more on what the component is doing and not worrying about the state of the other components (which our acceptance test should cover)
eb48a06
to
47c9d1a
Compare
8d53747
to
4137e52
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just 1 minor comment. But this looks good to me.
} = Ember; | ||
|
||
export default Component.extend({ | ||
// canAddCard: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we delete this comment?
a30c9fc
to
5ffb26a
Compare
What's in this PR?
Should implement:
Copied stuff to add later into #669 so we do not have it listed under "incomplete subtasks" on the milestone.
References
Fixes #473