Skip to content
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

[JP Content Migration Flow] Check Wordpress version compatibility #17536

Merged
merged 11 commits into from
Nov 25, 2022

Conversation

antonis
Copy link
Contributor

@antonis antonis commented Nov 24, 2022

Description

This PR adds checks for confirming that the WordPress app is installed and is compatible with the migration flow

To test:

Enable the Jetpack Content Migration Flow

Enable the following flags in the build.gradle

        buildConfigField "boolean", "JETPACK_POWERED_BOTTOM_SHEET", "true"
        buildConfigField "boolean", "JETPACK_SHARED_LOGIN", "true"
        buildConfigField "boolean", "JETPACK_LOCAL_USER_FLAGS", "true"
        buildConfigField "boolean", "JETPACK_BLOGGING_REMINDERS_SYNC", "true"
        buildConfigField "boolean", "JETPACK_READER_SAVED_POSTS", "true"
        buildConfigField "boolean", "JETPACK_PROVIDER_SYNC", "true"
        buildConfigField "boolean", "JETPACK_MIGRATION_FLOW", "true"

WordPress app not present

  1. Enable the Jetpack Content Migration Flow
  2. Uninstall the WordPress app (of this flavor) if exists on the device
  3. Uninstall the Jetpack app or log out of Jetpack and delete all data.
  4. Run the Jetpack app from this branch
  5. Expect to NOT see the migration flow

Not eligible WordPress app version

  1. Enable the Jetpack Content Migration Flow
  2. Install the WordPress app flavor from this branch
  3. Login to the WordPress app and select a site
  4. Uninstall the Jetpack app or log out of Jetpack and delete all data.
  5. Run the Jetpack app from this branch
  6. Expect to NOT see the migration flow

Eligible WordPress app version

  1. Enable the Jetpack Content Migration Flow
  2. Change the minimumSupportedVersion to 21.2 in JetpackAppMigrationFlowUtils.kt
  3. Install the WordPress app flavor from this branch
  4. Login to the WordPress app and select a site
  5. Uninstall the Jetpack app or log out of Jetpack and delete all data.
  6. Run the Jetpack app from this branch
  7. Expect to see the migration flow

Regression Notes

  1. Potential unintended areas of impact
    N/A

  2. What I did to test those areas of impact (or what existing automated tests I relied on)
    Manual testing

  3. What automated tests I added (or what prevented me from doing so)
    Added unit tests

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Sorry, something went wrong.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Nov 24, 2022

Jetpack📲 You can test these changes on Jetpack by downloading jetpack-installable-build-pr17536-6dd4699.apk
💡 Scan this QR code with your Android phone to download and install the APK directly on it.
AppJetpack
Build FlavorJalapeno
Build TypeDebug
Commit6dd4699
Note: This installable build uses the JalapenoDebug build flavor, and does not support Google Login.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Nov 24, 2022

WordPress📲 You can test these changes on WordPress by downloading wordpress-installable-build-pr17536-6dd4699.apk
💡 Scan this QR code with your Android phone to download and install the APK directly on it.
AppWordPress
Build FlavorJalapeno
Build TypeDebug
Commit6dd4699
Note: This installable build uses the JalapenoDebug build flavor, and does not support Google Login.

@antonis antonis marked this pull request as ready for review November 24, 2022 20:12
@RenanLukas RenanLukas self-assigned this Nov 25, 2022
Copy link
Contributor

@RenanLukas RenanLukas left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, @antonis . All the scenarios work as expected.

I've left a couple of comments with optional suggestions so you can see it they make sense, but I'm approving it as it is. :shipit:

@@ -21,4 +21,18 @@ class WordPressPublicData @Inject constructor() {
Wasabi.type -> Wasabi.value
else -> throw IllegalArgumentException("Failed to get Jetpack package ID: build flavor not found.")
}

fun currentPackageVersion() = packageManagerWrapper.getPackageInfo(currentPackageId())?.versionName
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: would it make sense to add the explicit return type for this public function?

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 point 👍
Added with 398ff12

val rawVersion = currentPackageVersion()

// Clean app semantic versioning info. E.g 21.2-rc-3 turns to 21.2
val wordPressVersion = rawVersion?.split("-")?.getOrNull(0) ?: rawVersion ?: ""
Copy link
Contributor

Choose a reason for hiding this comment

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

I was wondering if it makes sense to use RegEx here too? I don't see any problem with this approach, I just wanted to suggest in case you find it more readable.

e.g.

    val rawVersion = "21.2-rc-3"
    val majorMinorRegex = "^(\\d*)(\\.(\\d*))".toRegex()
    val wordPressVersion = 
    majorMinorRegex.find(rawVersion) // 21.2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's indeed cleaner. Thank you for the suggestion @RenanLukas 🙇
I've added this with 02fec9c

}

@Test
fun `Invalid versions should return a null non semantic version`() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice tests 👍

@antonis antonis enabled auto-merge November 25, 2022 09:33
@peril-wordpress-mobile
Copy link

Warnings
⚠️ This PR is assigned to a milestone which is closing in less than 4 days Please, make sure to get it merged by then or assign it to a later expiring milestone

Generated by 🚫 dangerJS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants