Skip to content

Conversation

@jaclync
Copy link
Contributor

@jaclync jaclync commented Jul 11, 2025

For WOOMOB-835
Just one review is required.

Why

This PR adds Yosemite level support for retrying plugin related checks in the POS eligibility check WOOMOB-799. The integration with the eligibility checker will be in a separate PR because this PR is already close to 500 diffs.

Description

This PR introduces POSSystemStatusService in Yosemite to efficiently load both WooCommerce plugin information and POS feature switch value from a single system status API request. This improves performance by reducing API calls when refreshing POS eligibility.

The implementation includes:

  • New POSSystemStatusServiceProtocol with loadWooCommercePluginAndPOSFeatureSwitch method with POSSystemStatusService implementation
  • Generic loadSystemStatus method in SystemStatusRemote for reusable system status requests
  • Test coverage for POSSystemStatusService

Steps to reproduce

The new POSSystemStatusService isn't used in the app yet. Some confidence testing on the refactored SystemStatusRemote methods would be helpful:

SystemStatusRemote.loadSystemInformation usage

This method is called throughout the app via SystemStatusAction.synchronizeSystemInformation. Example testing steps:

  • Launch the app
  • Go to Menu > Settings --> the WC plugin version should be shown correctly as before
  • Tap on Plugins --> plugins should be shown correctly as before

SystemStatusRemote.fetchSystemStatusReport usage

This method is called throughout the app via SystemStatusAction.fetchSystemStatusReport.

  • Launch the app
  • Go to Menu > Settings > Help & Support -> System Status Report --> the SSR should be shown correctly as before

Testing information

I tested the steps above in iPad A16 iOS 18.4 simulator.


  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@jaclync jaclync added the type: task An internally driven task. label Jul 11, 2025
@jaclync jaclync added this to the 22.9 milestone Jul 11, 2025
@jaclync jaclync changed the title Add POSSystemStatusService to load WooCommerce plugin and POS feature switch from system status API [POS as a tab i2] Support loading WC plugin and POS feature switch from system status endpoint Jul 11, 2025
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jul 11, 2025

App Icon📲 You can test the changes from this Pull Request in WooCommerce iOS Prototype by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS Prototype
Build Numberpr15906-4520838
Version22.8
Bundle IDcom.automattic.alpha.woocommerce
Commit4520838
Installation URL6d14okt99vbh0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@jaclync jaclync requested review from iamgabrielma and staskus July 12, 2025 01:14
@iamgabrielma iamgabrielma self-assigned this Jul 14, 2025
Copy link
Contributor

@iamgabrielma iamgabrielma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

do {
let mapper = SystemStatusMapper(siteID: siteID)
let systemStatus = try await loadSystemStatus(for: siteID,
fields: [Field.environment, Field.activePlugins, Field.inactivePlugins],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently unused, but I think we're missing the settings field here?

Suggested change
fields: [Field.environment, Field.activePlugins, Field.inactivePlugins],
fields: [Field.environment, Field.activePlugins, Field.inactivePlugins, Field.settings],

Copy link
Contributor Author

@jaclync jaclync Jul 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SystemStatusMapper/SystemStatus currently does not need the settings field for the use case of this remote method (as in the fields in the deleted line 21), thus I don't think we need to fetch it for performance reason.


// Finds WooCommerce plugin from active plugins response.
guard let wcPlugin = systemStatus.activePlugins.first(where: { $0.plugin == Constants.wcPluginPath }) else {
return POSPluginAndFeatureInfo(wcPlugin: nil, featureValue: nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If no WooCommerce plugin path is found at this point of execution, should we throw here rather than returning a POSPluginAndFeatureInfo with nil values?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question - I thought about it before, and decided to keep this service simple and just return data if available and throw errors when the app fails to retrieve the data. The use case determines how to handle when the plugin / feature value isn't available.

Ideally, all the plugin related checks can be in Yosemite. However, right now VersionHelpers exists in the app layer and it'd require some refactoring to move it to Yosemite. If I have some time before the i2 release next Friday, I will tackle this.

Comment on lines +75 to +76
// As `settings.enable_features` was introduced in WC version 9.9.0, this field is optional.
// Ref: https://github.com/woocommerce/woocommerce/pull/57168
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 💯

Comment on lines +68 to +78
@Test func loadWooCommercePluginAndPOSFeatureSwitch_returns_nil_plugin_and_nil_feature_when_woocommerce_plugin_not_found() async throws {
// Given
network.simulateResponse(requestUrlSuffix: "system_status", filename: "system-status-wc-plugin-missing")

// When
let result = try await sut.loadWooCommercePluginAndPOSFeatureSwitch(siteID: sampleSiteID)

// Then
#expect(result.wcPlugin == nil)
#expect(result.featureValue == nil)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linked to the comment above regarding not finding the WooCommerce path at this point, is this a expected scenario? Or should we throw an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Responded in #15906 (comment).

@jaclync jaclync merged commit 0ea5d32 into trunk Jul 14, 2025
14 checks passed
@jaclync jaclync deleted the feat/WOOMOB-835-load-wc-plugin-pos-feature-switch-from-system-status branch July 14, 2025 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: task An internally driven task.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants