-
Notifications
You must be signed in to change notification settings - Fork 118
Remove pointOfSaleReceipts
feature flag
#16103
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
Open
iamgabrielma
wants to merge
2
commits into
trunk
Choose a base branch
from
task/remove-pos-receipts-FF
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -182,11 +182,8 @@ struct PointOfSaleOrderControllerTests { | |
|
||
@Test func sendReceipt_when_there_is_no_order_then_will_not_trigger() async throws { | ||
// Given | ||
let mockFeatureFlagService = MockFeatureFlagService() | ||
mockFeatureFlagService.isFeatureFlagEnabledReturnValue[.pointOfSaleReceipts] = true | ||
let sut = PointOfSaleOrderController(orderService: mockOrderService, | ||
receiptService: mockReceiptService, | ||
featureFlagService: mockFeatureFlagService) | ||
receiptService: mockReceiptService) | ||
let email = "[email protected]" | ||
|
||
// When | ||
|
@@ -202,11 +199,8 @@ struct PointOfSaleOrderControllerTests { | |
|
||
@Test func sendReceipt_calls_both_updateOrder_and_sendReceipt() async throws { | ||
// Given | ||
let mockFeatureFlagService = MockFeatureFlagService() | ||
mockFeatureFlagService.isFeatureFlagEnabledReturnValue[.pointOfSaleReceipts] = true | ||
let sut = PointOfSaleOrderController(orderService: mockOrderService, | ||
receiptService: mockReceiptService, | ||
featureFlagService: mockFeatureFlagService) | ||
receiptService: mockReceiptService) | ||
let order = Order.fake() | ||
let recipientEmail = "[email protected]" | ||
mockOrderService.orderToReturn = order | ||
|
@@ -638,13 +632,9 @@ struct PointOfSaleOrderControllerTests { | |
version: "10.0.0-dev", | ||
active: true)) | ||
|
||
let mockFeatureFlagService = MockFeatureFlagService() | ||
mockFeatureFlagService.isFeatureFlagEnabledReturnValue[.pointOfSaleReceipts] = true | ||
|
||
let sut = PointOfSaleOrderController(orderService: orderService, | ||
receiptService: receiptService, | ||
analytics: analytics, | ||
featureFlagService: mockFeatureFlagService, | ||
pluginsService: mockPluginsService) | ||
let order = Order.fake() | ||
orderService.orderToReturn = order | ||
|
@@ -664,20 +654,17 @@ struct PointOfSaleOrderControllerTests { | |
|
||
@Test func sendReceipt_without_order_tracks_failure_without_eligible_for_pos_receipt() async throws { | ||
// Given | ||
let mockFeatureFlagService = MockFeatureFlagService() | ||
mockFeatureFlagService.isFeatureFlagEnabledReturnValue[.pointOfSaleReceipts] = true | ||
let sut = PointOfSaleOrderController(orderService: orderService, | ||
receiptService: receiptService, | ||
analytics: analytics, | ||
featureFlagService: mockFeatureFlagService) | ||
analytics: analytics) | ||
|
||
// When | ||
do { | ||
try await sut.sendReceipt(recipientEmail: "[email protected]") | ||
} catch { | ||
// Then | ||
let indexOfEvent = try #require(analyticsProvider.receivedEvents.firstIndex(where: { $0 == "receipt_email_failed" })) | ||
#expect(analyticsProvider.receivedProperties[indexOfEvent]["eligible_for_pos_receipt"] == nil) | ||
#expect(analyticsProvider.receivedProperties[indexOfEvent]["eligible_for_pos_receipt"] as? Bool == false) | ||
} | ||
} | ||
|
||
|
@@ -689,12 +676,9 @@ struct PointOfSaleOrderControllerTests { | |
version: "10.0.0-dev", | ||
active: true)) | ||
|
||
let mockFeatureFlagService = MockFeatureFlagService() | ||
mockFeatureFlagService.isFeatureFlagEnabledReturnValue[.pointOfSaleReceipts] = true | ||
let sut = PointOfSaleOrderController(orderService: orderService, | ||
receiptService: receiptService, | ||
analytics: analytics, | ||
featureFlagService: mockFeatureFlagService, | ||
pluginsService: mockPluginsService) | ||
|
||
receiptService.sendReceiptResult = .failure(DotcomError.unknown(code: "test_error", message: "Test error")) | ||
|
@@ -723,13 +707,11 @@ struct PointOfSaleOrderControllerTests { | |
struct ReceiptTests { | ||
private let mockOrderService = MockPOSOrderService() | ||
|
||
@Test("Eligible core plugin versions with feature flag enabled", arguments: Constants.eligibleWCPluginVersions) | ||
func sendReceipt_when_feature_flag_enabled_and_eligible_plugin_version_sets_isEligibleForPOSReceipt_true(wcPluginVersion: String) async throws { | ||
@Test("Eligible core plugin versions", arguments: Constants.eligibleWCPluginVersions) | ||
func sendReceipt_when_eligible_plugin_version_sets_isEligibleForPOSReceipt_true(wcPluginVersion: String) async throws { | ||
// Given | ||
let mockReceiptService = MockReceiptService() | ||
let mockFeatureFlagService = MockFeatureFlagService() | ||
let mockPluginsService = MockPluginsService() | ||
mockFeatureFlagService.isFeatureFlagEnabledReturnValue[.pointOfSaleReceipts] = true | ||
mockPluginsService.setMockPlugin(.wooCommerce, | ||
systemPlugin: SystemPlugin.fake().copy(plugin: "woocommerce/woocommerce.php", | ||
version: wcPluginVersion, | ||
|
@@ -738,7 +720,6 @@ struct PointOfSaleOrderControllerTests { | |
let sut = PointOfSaleOrderController(orderService: mockOrderService, | ||
receiptService: mockReceiptService, | ||
analytics: ServiceLocator.analytics, | ||
featureFlagService: mockFeatureFlagService, | ||
pluginsService: mockPluginsService) | ||
mockOrderService.orderToReturn = Order.fake() | ||
|
||
|
@@ -753,47 +734,11 @@ struct PointOfSaleOrderControllerTests { | |
#expect(mockReceiptService.spyIsEligibleForPOSReceipt == true) | ||
} | ||
|
||
@Test( | ||
"All core plugin versions with feature flag disabled", | ||
arguments: Constants.eligibleWCPluginVersions + Constants.ineligibleWCPluginVersions | ||
) | ||
func sendReceipt_when_feature_flag_disabled_and_eligible_plugin_version_sets_isEligibleForPOSReceipt_false(wcPluginVersion: String) async throws { | ||
// Given | ||
let mockReceiptService = MockReceiptService() | ||
let mockFeatureFlagService = MockFeatureFlagService() | ||
let mockPluginsService = MockPluginsService() | ||
mockFeatureFlagService.isFeatureFlagEnabledReturnValue[.pointOfSaleReceipts] = false | ||
// Plugin setup is irrelevant when feature flag is disabled | ||
mockPluginsService.setMockPlugin(.wooCommerce, | ||
systemPlugin: SystemPlugin.fake().copy(plugin: "woocommerce/woocommerce.php", | ||
version: wcPluginVersion, | ||
active: true)) | ||
|
||
let sut = PointOfSaleOrderController(orderService: mockOrderService, | ||
receiptService: mockReceiptService, | ||
analytics: ServiceLocator.analytics, | ||
featureFlagService: mockFeatureFlagService, | ||
pluginsService: mockPluginsService) | ||
mockOrderService.orderToReturn = Order.fake() | ||
|
||
// We need an existing order before we can update its email, and send a receipt: | ||
await sut.syncOrder(for: .init(purchasableItems: [makeItem()]), retryHandler: { }) | ||
|
||
// When | ||
try await sut.sendReceipt(recipientEmail: "[email protected]") | ||
|
||
// Then | ||
#expect(mockReceiptService.sendReceiptWasCalled == true) | ||
#expect(mockReceiptService.spyIsEligibleForPOSReceipt == false) | ||
} | ||
|
||
@Test("Ineligible core plugin versions with feature flag enabled", arguments: Constants.ineligibleWCPluginVersions) | ||
func sendReceipt_when_feature_flag_enabled_and_ineligible_plugin_version_sets_isEligibleForPOSReceipt_false(wcPluginVersion: String) async throws { | ||
func sendReceipt_when_ineligible_plugin_version_sets_isEligibleForPOSReceipt_false(wcPluginVersion: String) async throws { | ||
// Given | ||
let mockReceiptService = MockReceiptService() | ||
let mockFeatureFlagService = MockFeatureFlagService() | ||
let mockPluginsService = MockPluginsService() | ||
mockFeatureFlagService.isFeatureFlagEnabledReturnValue[.pointOfSaleReceipts] = true | ||
mockPluginsService.setMockPlugin(.wooCommerce, | ||
systemPlugin: SystemPlugin.fake().copy(plugin: "woocommerce/woocommerce.php", | ||
version: wcPluginVersion, | ||
|
@@ -802,7 +747,6 @@ struct PointOfSaleOrderControllerTests { | |
let sut = PointOfSaleOrderController(orderService: mockOrderService, | ||
receiptService: mockReceiptService, | ||
analytics: ServiceLocator.analytics, | ||
featureFlagService: mockFeatureFlagService, | ||
pluginsService: mockPluginsService) | ||
mockOrderService.orderToReturn = Order.fake() | ||
|
||
|
@@ -817,23 +761,20 @@ struct PointOfSaleOrderControllerTests { | |
#expect(mockReceiptService.spyIsEligibleForPOSReceipt == false) | ||
} | ||
|
||
@Test("Unavailable core plugin with feature flag enabled", | ||
@Test("Unavailable core plugin", | ||
arguments: [ | ||
SystemPlugin.fake().copy(plugin: "woocommerce/woocommerce.php", active: false), | ||
nil | ||
]) | ||
func sendReceipt_when_feature_flag_enabled_and_plugin_unavailable_sets_isEligibleForPOSReceipt_false(plugin: SystemPlugin?) async throws { | ||
func sendReceipt_when_plugin_unavailable_sets_isEligibleForPOSReceipt_false(plugin: SystemPlugin?) async throws { | ||
// Given | ||
let mockReceiptService = MockReceiptService() | ||
let mockFeatureFlagService = MockFeatureFlagService() | ||
let mockPluginsService = MockPluginsService() | ||
mockFeatureFlagService.isFeatureFlagEnabledReturnValue[.pointOfSaleReceipts] = true | ||
mockPluginsService.setMockPlugin(.wooCommerce, systemPlugin: plugin) | ||
|
||
let sut = PointOfSaleOrderController(orderService: mockOrderService, | ||
receiptService: mockReceiptService, | ||
analytics: ServiceLocator.analytics, | ||
featureFlagService: mockFeatureFlagService, | ||
pluginsService: mockPluginsService) | ||
mockOrderService.orderToReturn = Order.fake() | ||
|
||
|
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.
AFAU we have no reason for this to be nil, since it's either eligible or it isn't. Also allows to simplify the value we pass to the catch block and the track event.
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.
Previously, if there was no order, or
orderService.updatePOSOrder
threw an error, we'd track thereceiptEmailFailed
event withouteligible_for_pos_receipt
(thanks to the compactMapValues.)Now we'll log it as false even if the real answer would have been true.
Perhaps we should just set the
isEligible
at the top instead of after updating the order. The only thing it uses is the siteID, which isn't going to change from the order update, surely.