Skip to content

Decouple Blog from JetpackFeaturesRemovalCoordinator #24393

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

Closed
wants to merge 5 commits into from

Conversation

mokagio
Copy link
Contributor

@mokagio mokagio commented Apr 2, 2025

I don't remember where, but we discussed that it was safe to replace [JetpackFeaturesRemovalCoordinator jetpackFeaturesEnabled] in Blog with a check for BuildSettings.current.brand == .jetpack.

However, BuildSettings is only available to Swift, which means moving the logic that accesses JetpackFeaturesRemovalCoordinator to Swift. I started down that route in #24332 but I run into UI test failures and got worried about the surface area and combine lack of unit tests.

This PR targets only the JetpackFeaturesRemovalCoordinator decoupling, and with tests.

Notice that to do this I added a fixture extension to BuildSettings, so we can create ad hoc values in the unit tests to inject.

Part of #24165.

@dangermattic
Copy link
Collaborator

dangermattic commented Apr 2, 2025

1 Warning
⚠️ This PR is assigned to the milestone 25.9. The due date for this milestone has already passed.
Please assign it to a milestone with a later deadline or check whether the release for this milestone has already been finished.

Generated by 🚫 Danger

@mokagio mokagio added this to the 25.9 milestone Apr 2, 2025
@mokagio mokagio added the Core Data Issues related to Core Data label Apr 2, 2025
@mokagio mokagio self-assigned this Apr 2, 2025
@wpmobilebot
Copy link
Contributor

wpmobilebot commented Apr 2, 2025

App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number27055
VersionPR #24393
Bundle IDcom.jetpack.alpha
Commita51b038
Installation URL5e1sq0jfmlvtg
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Apr 2, 2025

App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number27055
VersionPR #24393
Bundle IDorg.wordpress.alpha
Commita51b038
Installation URL6s3scgaoh9u70
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@mokagio mokagio marked this pull request as ready for review April 2, 2025 07:10
@mokagio mokagio enabled auto-merge April 2, 2025 07:10
@mokagio mokagio requested review from kean and crazytonyli and removed request for kean April 2, 2025 07:10
Comment on lines 571 to +574
case BlogFeatureStockPhotos:
return [self supportsRestApi] && [JetpackFeaturesRemovalCoordinator jetpackFeaturesEnabled];
return [self supportsStockPhotos];
case BlogFeatureTenor:
return [JetpackFeaturesRemovalCoordinator jetpackFeaturesEnabled];
return [self supportsTenor];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As an aside, I'm not sure how useful it is for us to have all this logic living in the Blog model, in particular checks such as whether the app is Jetpack.

We could explode this method in per-feature ones that take a Blog and the relevant app state as input and return true or false.

Copy link
Contributor

@kean kean left a comment

Choose a reason for hiding this comment

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

Hey, I opened a PR that moves JetpackFeaturesRemovalCoordinator usages to the app #24395. I'd suggest keeping any app-specific checks out of Blog or WordPressData in general.

In the future, we'll might want to introduce another abstraction for features or somehow integrate it with FeatureFlag, but this will do for now.

XCTAssertTrue(blog.supportsRestApi())
}

func testSupportsStockPhotos() {
Copy link
Contributor

@kean kean Apr 2, 2025

Choose a reason for hiding this comment

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

I'd suggest avoiding writing tests for configuration. In this case, the tests are more complicated than the implementation and match the logic one-to-one.

@mokagio
Copy link
Contributor Author

mokagio commented Apr 2, 2025

Closing in favor of #24395

@kean

I'd suggest keeping any app-specific checks out of Blog or WordPressData in general.

Yeah. I thought that too, I was coming the point of view of just getting this to compile. But I appreciate you going the extra mile and making the design better for the future. 🙇‍♂️

@mokagio mokagio closed this Apr 2, 2025
auto-merge was automatically disabled April 2, 2025 19:55

Pull request was closed

@mokagio mokagio deleted the mokagio/blog-swift-some-alternative branch April 2, 2025 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core Data Issues related to Core Data
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants