-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[NT-489] Default card selection improvement #931
Conversation
let cardIsSelected = cardAndSelectedCard | ||
.map(==) | ||
let cardIsSelected = Signal.merge( | ||
creditCard.mapConst(false), |
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.
Emitting false
here to ensure that the card has a title even though we're not setting a selected card.
guard let cardBrand = card.type?.rawValue else { return nil } | ||
|
||
let isAvailableCardType = availableCardTypes.contains(cardBrand) | ||
|
||
return (card, isAvailableCardType, project.location.displayableName) | ||
} | ||
|
||
guard let backing = project.personalization.backing else { |
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.
If this project hasn't been backed then we do just select the first card.
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.
Good job, Justin. I just left a couple of suggestions and questions 😄
backedCard = cards.first | ||
} | ||
|
||
return (data, backedCard) |
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.
Here I think we could simply use
let backedCard = cards.first(where: { $0.id == backing.paymentSource?.id })
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.
lol thanks that's much better
func testReloadPaymentMethods_LoggedIn_ApplePayCapable_isTrue_BackedCardRemoved() { | ||
let filteredCards = GraphUserCreditCard.template.storedCards.nodes | ||
.filter { $0.id != GraphUserCreditCard.visa.id | ||
} |
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 you put the }
on the same line?
self.applePayButtonHidden.assertValues([false]) | ||
self.reloadPaymentMethodsCards.assertValue(response.me.storedCards.nodes) | ||
self.reloadPaymentMethodsAvailableCardTypes.assertValues([ | ||
[true, true, true, true, true, false, 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.
Why is there an unavailable card? 🤔
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 just the Project template's available card types, I copied this test from the one above it.
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.
Oh cool!
📲 What
Fixes an issue where the first stored card was always selected in any context where the payment method could be set even when it was not used to back the project.
🤔 Why
Our logic for handling this was a bit shortsighted in that it would simply select the first card in the list every time. Instead we need to confirm that the card was in fact used to back the project and hasn't since been removed.
🛠 How
Updated our logic for this to take into account the
PaymentSource
of theBacking
and if it's set, check that the card is still an available payment source.✅ Acceptance criteria
Confirm
button should be disabled.