-
Notifications
You must be signed in to change notification settings - Fork 111
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
[Mobile Payments] Show description for trial tap to pay line items #14022
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
74a25b0
Show description for trial tap to pay line items
joshheald 5d2f923
Add TTP trial payment name to 20.6 release notes
joshheald 4ac7845
Fix lint issues
joshheald 0fc6343
Merge branch 'trunk' into hack/name-ttp-test-amounts
joshheald aa099f9
Move name for TTP test amounts to 20.7 release
joshheald File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1165,6 +1165,7 @@ final class OrderStoreTests: XCTestCase { | |
// Given | ||
let feeID: Int64 = 1234 | ||
let amount = "100.00" | ||
let amountName = "A simple amount" | ||
let taxable = true | ||
let note = "This is a note" | ||
let email = "[email protected]" | ||
|
@@ -1178,6 +1179,7 @@ final class OrderStoreTests: XCTestCase { | |
feeID: feeID, | ||
status: .pending, | ||
amount: amount, | ||
amountName: amountName, | ||
taxable: taxable, | ||
orderNote: note, | ||
email: email) { _ in } | ||
|
@@ -1188,7 +1190,7 @@ final class OrderStoreTests: XCTestCase { | |
let receivedFees = try XCTUnwrap(request.parameters["fee_lines"] as? [[String: AnyHashable]]).first | ||
let expectedFees: [String: AnyHashable] = [ | ||
"id": 1234, | ||
"name": "Simple Payments", | ||
"name": "A simple amount", | ||
"tax_status": "taxable", | ||
"tax_class": "", | ||
"total": "100.00" | ||
|
@@ -1212,6 +1214,42 @@ final class OrderStoreTests: XCTestCase { | |
assertEqual(receivedNote, note) | ||
} | ||
|
||
func test_update_simple_payments_order_sends_default_name_when_none_provided() throws { | ||
// Given | ||
let feeID: Int64 = 1234 | ||
let amount = "100.00" | ||
let taxable = true | ||
let note = "This is a note" | ||
let email = "[email protected]" | ||
|
||
let store = OrderStore(dispatcher: dispatcher, storageManager: storageManager, network: network) | ||
network.simulateResponse(requestUrlSuffix: "orders/963", filename: "order") | ||
|
||
// When | ||
let action = OrderAction.updateSimplePaymentsOrder(siteID: sampleSiteID, | ||
orderID: sampleOrderID, | ||
feeID: feeID, | ||
status: .pending, | ||
amount: amount, | ||
amountName: nil, | ||
taxable: taxable, | ||
orderNote: note, | ||
email: email) { _ in } | ||
store.onAction(action) | ||
|
||
// Then | ||
let request = try XCTUnwrap(network.requestsForResponseData.last as? JetpackRequest) | ||
let receivedFees = try XCTUnwrap(request.parameters["fee_lines"] as? [[String: AnyHashable]]).first | ||
let expectedFees: [String: AnyHashable] = [ | ||
"id": 1234, | ||
"name": "Simple Payments", | ||
"tax_status": "taxable", | ||
"tax_class": "", | ||
"total": "100.00" | ||
] | ||
assertEqual(expectedFees, receivedFees) | ||
} | ||
|
||
func test_create_order_sends_expected_fields() throws { | ||
// Given | ||
let store = OrderStore(dispatcher: dispatcher, storageManager: storageManager, network: network) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 came up from the
test_update_simple_payments_order_sends_default_name_when_none_provided
test, as we setamountName: nil
but we assert againstname: "Simple Payments"
:By this property I would assume that a Simple Payments order either has a given string as name, or has no name, but without this property they still get the "Simple Payment" name by default, given in the
OrderFactory
. Should we rename this to some sort of "overrideFeeLineName", or similar? Perhaps move the default value somewhere else outside the factory? Perhaps make it non-nil? 🤔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 don't think so... I don't feel super strongly, but I think it's best just to leave this as is.
At risk of bikeshedding a minor point in a part of the code which should be removed (because we don't do Simple Payments any more): the default is implemented in business logic. The UI/view model doesn't need to care about what happens in business logic in this case, just that the user has the option of providing an amount name, or not.
It makes sense to me to have a default in business logic – an unnamed fee would be confusing when reviewed.
Naming it
overrideFeeLineName
makes the view model harder to read/understand, and prompting questions that the callers probably don't need to care about or intuit – what's it overriding? Is it theOverrideFee
's line name, or is it an override for theFee
's line name? Why's there a fee anyway, this is a payment? It feels like we're leaking implementation details with this sort of approach.Making it non-nillable is simple, but would mean that we lose the ability to rely on a default value, and have to provide it separately for anything that uses that order action.
Putting the default value elsewhere in code is probably the most compelling alternative, and I wouldn't be against doing that. It does mean that every caller of the relevant order action needs to look up or have its own default 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.
That makes sense, and I have no strong opinion about it neither, just cached my attention because of the test, and changing it feels too much hassle for such a little detail.
PD: Learned a new word today with
bikeshedding
, gonna use that one 😂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.
https://en.wikipedia.org/wiki/Law_of_triviality