-
Notifications
You must be signed in to change notification settings - Fork 118
[Woo POS][Historical Orders] Order Details: Email Receipt action (Wireframe UI) (1/1) #16110
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
Merged
staskus
merged 26 commits into
trunk
from
woomob-1140-woo-poshistorical-orders-order-details-email-receipt-action
Sep 12, 2025
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
cc339f2
Add Email receipt action with action section to point of sale order d…
staskus 1bf4399
Conditional actions presentation
staskus e4e58e6
Extract receipt related logic to POSReceiptController
staskus fcc4550
Move receipt-related tests to POSReceiptControllerTests
staskus c2dfab9
Update POSSendReceiptView to allow injecting receipt-sending logic
staskus acb223b
Update POSTabCoordinator dependency injection
staskus 68b8aca
Create updatePOSOrderEmail in OrdersRemote for targeted email update …
staskus c60ac56
Remove dependency of Order from POSOrderService updatePOSOrder email
staskus 3be0b8c
Remove Order dependency from POSReceiptService sendReceipt method
staskus 348d86e
Update POSReceiptController to rely on orderID and not Order
staskus 134e27b
Send receipt from PointOfSaleOrderDetailsView
staskus c6c2999
Allow modifying posHeaderBackButton through a view modifier
staskus 5f87a42
Speed up POS Receipt Sending - only update order when sending with le…
staskus 76e692f
Remove unused code
staskus 9b2d86b
Only modify back button icon from POSPageHeaderView
staskus b39f801
Merge branch 'trunk' into woomob-1140-woo-poshistorical-orders-order-…
staskus f259d64
Make POSReceiptControllerTests properties private
staskus ac9435a
Fix OrdersRemote formatting
staskus b16a96b
Fix POSOrderServiceTests formatting
staskus 199d2f4
Remove import Observation from POSReceiptController
staskus 95f5b26
Name posHeaderBackButtonIcon with systemName
staskus 4a397e7
Make error throw from mocks more reusable
staskus 274c455
Rename POSReceiptController to POSReceiptSender
staskus 9504721
Use site timezone for order date formatting
staskus 9c6c91e
Hold orderListModel in PointOfSaleEntryPointView as aggregateModel
staskus 4ae1b3c
Update PointOfSaleEntryPointView.swift
staskus 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -129,29 +129,33 @@ final class ReceiptRemoteTests: XCTestCase { | |
// Given | ||
let remote = ReceiptRemote(network: network) | ||
let posReceiptTemplateID = "customer_pos_completed_order" | ||
let testEmail = "[email protected]" | ||
|
||
network.simulateResponse( | ||
requestUrlSuffix: "orders/\(sampleOrderID)/actions/send_email", | ||
filename: "orders-actions-send-email-success" | ||
) | ||
|
||
// When | ||
try await remote.sendPOSReceipt(siteID: sampleSiteID, orderID: sampleOrderID) | ||
try await remote.sendPOSReceipt(siteID: sampleSiteID, orderID: sampleOrderID, emailAddress: testEmail) | ||
|
||
// Then the send email request was made with correct parameters. | ||
let sendEmailRequest = try XCTUnwrap(network.requestsForResponseData.last as? JetpackRequest) | ||
XCTAssertEqual(sendEmailRequest.method, .post) | ||
XCTAssertEqual(sendEmailRequest.path, "orders/\(sampleOrderID)/actions/send_email") | ||
XCTAssertEqual(sendEmailRequest.parameters["template_id"] as? String, posReceiptTemplateID) | ||
XCTAssertEqual(sendEmailRequest.parameters["email"] as? String, testEmail) | ||
XCTAssertEqual(sendEmailRequest.parameters["force_email_update"] as? Bool, true) | ||
} | ||
|
||
func test_sendPOSReceipt_when_no_reponse_exist_throws_error() async { | ||
// Given | ||
let remote = ReceiptRemote(network: network) | ||
let testEmail = "[email protected]" | ||
|
||
await assertThrowsError({ | ||
// When | ||
try await remote.sendPOSReceipt(siteID: sampleSiteID, orderID: sampleOrderID) | ||
try await remote.sendPOSReceipt(siteID: sampleSiteID, orderID: sampleOrderID, emailAddress: testEmail) | ||
}, errorAssert: { error in | ||
// Then | ||
return error is NetworkError | ||
|
This file contains hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -166,6 +166,35 @@ struct POSOrderServiceTests { | |
return true | ||
}) | ||
} | ||
|
||
@Test func updatePOSOrder_calls_remote_updatePOSOrderEmail_with_correct_parameters() async throws { | ||
// Given | ||
let siteID: Int64 = 123 | ||
let orderID: Int64 = 456 | ||
let recipientEmail = "[email protected]" | ||
|
||
// When | ||
try await sut.updatePOSOrder(orderID: orderID, recipientEmail: recipientEmail) | ||
|
||
// Then | ||
#expect(mockOrdersRemote.updatePOSOrderEmailCalled == true) | ||
#expect(mockOrdersRemote.spyUpdatePOSOrderEmailSiteID == siteID) | ||
#expect(mockOrdersRemote.spyUpdatePOSOrderEmailOrderID == orderID) | ||
#expect(mockOrdersRemote.spyUpdatePOSOrderEmailAddress == recipientEmail) | ||
} | ||
|
||
@Test func updatePOSOrder_throws_error_when_remote_call_fails() async throws { | ||
// Given | ||
mockOrdersRemote.updatePOSOrderEmailResult = .failure(NSError(domain: "", code: 0)) | ||
|
||
// When/Then | ||
await #expect(performing: { | ||
try await sut.updatePOSOrder(orderID: 456, recipientEmail: "[email protected]") | ||
}, throws: { _ in | ||
// The actual error `POSOrderServiceError.updateOrderFailed` is private, thus we cannot check against the exact error. | ||
return true | ||
}) | ||
} | ||
} | ||
|
||
private func makePOSCartItem( | ||
|
This file contains hidden or 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 |
---|---|---|
|
@@ -20,7 +20,7 @@ struct POSReceiptServiceTests { | |
let email = "[email protected]" | ||
|
||
// When | ||
try await sut.sendReceipt(order: order, recipientEmail: email, isEligibleForPOSReceipt: false) | ||
try await sut.sendReceipt(orderID: order.orderID, recipientEmail: email, isEligibleForPOSReceipt: false) | ||
|
||
// Then | ||
#expect(receiptsRemote.sendReceiptCalled) | ||
|
@@ -36,7 +36,7 @@ struct POSReceiptServiceTests { | |
|
||
// When/Then | ||
do { | ||
try await sut.sendReceipt(order: order, recipientEmail: "[email protected]", isEligibleForPOSReceipt: false) | ||
try await sut.sendReceipt(orderID: order.orderID, recipientEmail: "[email protected]", isEligibleForPOSReceipt: false) | ||
XCTFail("Expected error to be thrown") | ||
} catch { | ||
guard case POSReceiptService.POSReceiptServiceError.sendReceiptFailed = error else { | ||
|
@@ -48,10 +48,17 @@ struct POSReceiptServiceTests { | |
|
||
@Test | ||
func sendReceipt_calls_remote_when_isEligibleForPOSReceipt_is_true() async throws { | ||
// Given | ||
let email = "[email protected]" | ||
let orderID: Int64 = 789 | ||
|
||
// When | ||
try await sut.sendReceipt(order: Order.fake(), recipientEmail: "[email protected]", isEligibleForPOSReceipt: true) | ||
try await sut.sendReceipt(orderID: orderID, recipientEmail: email, isEligibleForPOSReceipt: true) | ||
|
||
// Then | ||
#expect(receiptsRemote.sendPOSReceiptCalled) | ||
#expect(receiptsRemote.spySiteID == 123) | ||
#expect(receiptsRemote.spyOrderID == orderID) | ||
#expect(receiptsRemote.spyEmail == email) | ||
} | ||
} |
Oops, something went wrong.
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.
just wondering, does this affect other billing fields than the email field like the address? I'm guessing/hoping it doesn't. If it does, we might want to stay with the previous order remote update.
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.
No, it doesn't affect other billing fields. I tested. It targets only the email address.