Skip to content

Conversation

@salimbraksa
Copy link
Contributor

@salimbraksa salimbraksa commented Jan 8, 2024

Fixes #22268

Description

This PR resolves an issue where users purchasing a domain, linked to a site that already has a plan, through the All Domains flow get stuck in the Plans flow.

Test Instructions

N.B: Sandboxing is required to test domain checkout

Case 1: Site with Existing Plan

  1. Log into the site that already has a plan
  2. Navigate to Me > All Domains
  3. Tap "+"
  4. Select a domain
  5. Tap "Choose Site" button
  6. Expect the Checkout web view to appear
  7. Purchase the domain to verify the checkout flow works.

Case 2: Site without plan ( Regression )

  1. Log into the site that doesn't have a plan
  2. Navigate to Me > All Domains
  3. Tap "+"
  4. Select a domain
  5. Tap "Get Domain" button
  6. Expect the Plans web view to appear
  7. Select a plan, go verify the checkout flow works as expected.

Case 3: Domain with No-Site ( Regression )

  1. Log into the site that already has a plan
  2. Navigate to Me > All Domains
  3. Tap "+"
  4. Select a domain
  5. Tap "Get Domain" button
  6. Expect the Checkout web view to appear
  7. Purchase the domain to verify the checkout flow works.

Next

  • Address the // TODO: I added in RegisterDomainCoordinator.swift.
  • Add Unit Tests for RegisterDomainCoordinator.

Regression Notes

  1. Potential unintended areas of impact
    Purchasing a domain through the All Domains flow.

  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)
    None.

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.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Jan 8, 2024

WordPress Alpha📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
App NameWordPress Alpha WordPress Alpha
ConfigurationRelease-Alpha
Build Numberpr22343-b8b430f
Version24.0
Bundle IDorg.wordpress.alpha
Commitb8b430f
App Center BuildWPiOS - One-Offs #8551
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Jan 8, 2024

Jetpack Alpha📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
App NameJetpack Alpha Jetpack Alpha
ConfigurationRelease-Alpha
Build Numberpr22343-b8b430f
Version24.0
Bundle IDcom.jetpack.alpha
Commitb8b430f
App Center Buildjetpack-installable-builds #7578
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@salimbraksa salimbraksa marked this pull request as ready for review January 8, 2024 17:13
@salimbraksa salimbraksa changed the title Fix an issue where the All Domains flow wasn't taking into consideration sites with existing plan Fix an issue where the All Domains flow wasn't taking into account sites with existing plan Jan 8, 2024
@salimbraksa salimbraksa force-pushed the task/22268-all-domains-existing-site-with-plan-bug branch from 467aca8 to beda8a0 Compare January 8, 2024 18:09

// MARK: Helpers

private func purchaseDomain(for site: Blog?, on viewController: UIViewController, completion: @escaping (Result<Void, Swift.Error>) -> Void) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think a VM would be a better fit for these service calls but it doesn't have to be part of this PR.

@hassaanelgarem
Copy link
Contributor

@salimbraksa Can you briefly explain how these changes fixed the issue? 🙏

self.domainPurchasedCallback = domainPurchasedCallback
self.crashLogger = crashLogger
self.analyticsSource = analyticsSource
self.domainRegistrationService = domainRegistrationService
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This service was instantiated within the createCart method, but I've moved to init for better dependency injection, allowing easier unit testing.

func handlePurchaseDomainOnly(on viewController: UIViewController,
onSuccess: @escaping () -> (),
onFailure: @escaping () -> ()) {
// TODO: Refactor `handlePurchaseDomainOnly` to use `purchaseDomain` helper.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will be addressed in another PR.

func addDomainToCartLinkedToCurrentSite(on viewController: UIViewController,
onSuccess: @escaping () -> (),
onFailure: @escaping () -> ()) {
// TODO: Refactor `addDomainToCartLinkedToCurrentSite` to use `purchaseDomain` helper.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will be addressed in another PR.

self.domainAddedToCartAndLinkedToSiteCallback?(viewController, domain.domainName, site)
} else {
self.presentCheckoutWebview(on: viewController, title: TextContent.checkoutTitle)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is exactly the change that fixes the issue:

  1. If site.canRegisterDomainWithPaidPlan is true, then we show the Plans web view.
  2. Else, the Checkout web view is shown.

cc @hassaanelgarem

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for clarifying 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@staskus Do you confirm this logic is correct? 🙏

Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't checked the rest of the PR but if site.canRegisterDomainWithPaidPlan it means that the site has a domain credit, therefore we just allow to make domain registration without any plan selection or checkout:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@staskus Re-reading SiteDomainsViewModel and SiteDomainsView logic, I understand that:

  • The Register domain screen is shown when site.canRegisterDomainWithPaidPlan is true.
  • The Plans web view is shown when site.canRegisterDomainWithPaidPlan is false and user doesn't have domains.
  • The checkout web view is shown when site.canRegisterDomainWithPaidPlan is false and user has domains.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, sounds right!

let analyticsSource: String

// TODO: This can cause Core Data crashes. Pass `NSManagedObjectID` instead.
var site: Blog?
Copy link
Contributor Author

@salimbraksa salimbraksa Jan 17, 2024

Choose a reason for hiding this comment

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

FYI @hassaanelgarem I'll address this in a separate PR.

@salimbraksa salimbraksa modified the milestones: 24.1, Pending Jan 17, 2024
@salimbraksa salimbraksa marked this pull request as draft January 17, 2024 15:50
@salimbraksa
Copy link
Contributor Author

Following Povilas' comment, it appears these changes don't resolve the issue. I'm converting this PR to a Draft and deprioritizing it to focus on the In-App Feedback Prompt UI instead.

@hassaanelgarem hassaanelgarem removed their request for review January 19, 2024 00:38
…github.com:wordpress-mobile/WordPress-iOS into task/22268-all-domains-existing-site-with-plan-bug
@jkmassel jkmassel closed this Jun 26, 2024
@jkmassel jkmassel deleted the task/22268-all-domains-existing-site-with-plan-bug branch July 26, 2024 18:21
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.

All Domains: Existing site flow doesn't handle the case when the site already has a plan

7 participants