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

Fix WP.com post deeplink not opening in app #20304

Merged
merged 1 commit into from
Mar 13, 2023

Conversation

dvdchr
Copy link
Contributor

@dvdchr dvdchr commented Mar 10, 2023

Fixes #20293
Refs #20213, p1678384048655429-slack-C011BKNU1V5, p1678278001563359-slack-C0180B5PRJ4

Warning:
The PR temporarily targets release/21.8.1, but it should be updated to target release/21.8.2 once it's available.

This fixes an issue where post links with subdomain hosts (i.e., *.wordpress.com) no longer open in the app after #20213 is merged. This is due to the canHandle method in UniversalLinkRouter checking if the host is exactly wordpress.com or jetpack.com:

// If there's a hostname, check if it's WordPress.com or jetpack.com/app.
return scheme == "https"
&& (host == "wordpress.com" || host == "jetpack.com")
&& matcherCanHandle

To prevent further side effects, the issue is fixed by avoiding the usage of canHandle, thus bringing the logic closer to before #20213 is merged while still solving the original issue.

To Test

This will be using a similar test scenario from #20213, but with an added test case for better coverage.

Note that the recommended way is to compile the app under test to your device, and have the counterpart app installed from TestFlight or AppStore. If you wish to fully test from the simulator, I'd recommend temporarily modifying these values in UIApplication+AppAvailability:

  • wordpress:// -> wpdebug://
  • jetpack:// -> jpdebug://

enum AppScheme: String {
case wordpress = "wordpress://"
case wordpressMigrationV1 = "wordpressmigration+v1://"
case jetpack = "jetpack://"
}

And don't forget to also compile both apps to the Simulator when testing for Environment 1 below.

Environment 1: Both apps are installed

  • Have both WordPress and Jetpack apps installed on the device or simulator.
  • As there are test cases involving private sites, to make things easier, log in to your WordPress.com account and ensure that you use an account that has access to a private site.
  • Tap the links as described by the table below, and verify the expectation column is correct:
No. Link Expectation
1 A valid "edit post" link with site URL (wordpress.com/post/:siteURL/:postID) Opens wp-admin link in Safari
2 A valid "edit post" link with site ID (wordpress.com/post/:siteID/:postID) Opens wp-admin link in Safari
3 An invalid "edit post" link, e.g. with a wrong site ID. Does nothing
4 Any *.wordpress.com link that leads to a private site with insufficient access, e.g. https://dvcyp2general.wordpress.com/2023/03/10/looking-back-at-wordpress/ Shows "Error Loading Post"
5 Any *.wordpress.com link that you have read access to, e.g. https://dvdchrtest.wordpress.com/2023/03/10/hello-wordpress/ Opens the post in the app
6 Any valid wordpress.com deeplink route, e.g.: https://wordpress.com/me Deeplinks into the feature
7 Invalid wordpress.com deeplink route, e.g.: https://wordpress.com/read/feeds/000000 Does nothing, or shows some kind of error state1

Environment 2: Only one app installed

  • Have only one app installed (either WordPress or Jetpack).
  • Log in to your WordPress.com account.
  • Tap the links as described by the table below, and verify the expectation column is correct:
No. Link Expectation
1 A valid "edit post" link with site URL (/post/:siteURL/:postID) Opens the link in Safari
2 A valid "edit post" link with site ID (/post/:siteID/:postID) Opens the link in Safari
3 An invalid "edit post" link, e.g. with a wrong site ID. Opens the link in Safari
4 Any *.wordpress.com link that leads to a private site with insufficient access, e.g. https://dvcyp2general.wordpress.com/2023/03/10/looking-back-at-wordpress/ Shows "Error Loading Post"
5 Any *.wordpress.com link that you have read access to, e.g. https://dvdchrtest.wordpress.com/2023/03/10/hello-wordpress/ Opens the post in the app
6 Any valid wordpress.com deeplink route, for example: https://wordpress.com/me Deeplinks into the feature
7 Invalid wordpress.com deeplink route, e.g.: https://wordpress.com/read/feeds/000000 Does nothing, or shows some kind of error state1
  • Repeat the steps above, but now testing with the other app.

Regression Notes

  1. Potential unintended areas of impact
    Should be none. The implementation is now closer to before Fix: Do not bounce to Safari when both apps are installed #20213 is implemented.

  2. What I did to test those areas of impact (or what existing automated tests I relied on)
    Manually tested various deeplink scenarios.

  3. What automated tests I added (or what prevented me from doing so)
    N/A.

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding unit tests for my changes.
  • 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.

Footnotes

  1. This depends on how the error is handled on the specific route. But the key point here is that the infinite redirect between WP and JP should no longer be happening. 2

@wpmobilebot
Copy link
Contributor

You can test the changes in Jetpack from this Pull Request by:
  • Clicking here or scanning the QR code below to access App Center
  • Then installing the build number pr20304-82b6e0d on your iPhone

If you need access to App Center, please ask a maintainer to add you.

@wpmobilebot
Copy link
Contributor

You can test the changes in WordPress from this Pull Request by:
  • Clicking here or scanning the QR code below to access App Center
  • Then installing the build number pr20304-82b6e0d on your iPhone

If you need access to App Center, please ask a maintainer to add you.

@salimbraksa
Copy link
Contributor

salimbraksa commented Mar 10, 2023

Environment 1: Both apps are installed

@dvdchr I've tested all cases and most of them worked as expected. The 4th case however, didn't open the Jetpack app, nor WordPress. Instead, it just opened Safari with a page saying that I don't have access to read that post. This is definitely not issue but it's not the expected behavior mentioned in the table.

Environment 2: Only one app installed

I deleted Jetpack and kept WordPress. Tested all cases and everything worked as expected. But the 4th case behaved the same way as in Environment 1.

Although the 4th case didn't open Jetpack or WordPress, I guess that should be fine. LGTM! 🚀

Update

Turns out the 4th case behaved that way because tampermonkey interfered with the post link. @dvdchr DMed me another link and the case worked as expected.

@dvdchr
Copy link
Contributor Author

dvdchr commented Mar 10, 2023

Turns out the 4th case behaved that way because tampermonkey interfered with the post link.

Yep. Turns out the original P2 link got automatically shorthanded by the extension. I've now updated the URL in case no. 4. Thanks @salimbraksa!

@mokagio mokagio changed the base branch from release/21.8.1 to release/21.8.2 March 13, 2023 10:00
@mokagio
Copy link
Contributor

mokagio commented Mar 13, 2023

I haven't tested this PR after changing the base branch from release/21.8.1 to release/21.8.2 but the difference between the two branches is only the version number.

Merging to get the hotfix shipped.

@mokagio mokagio merged commit 8cbd8b3 into release/21.8.2 Mar 13, 2023
@mokagio mokagio deleted the fix/post-deeplink-not-working branch March 13, 2023 10:06
@mokagio mokagio mentioned this pull request Mar 15, 2023
3 tasks
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.

4 participants