Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[MBL-2062] Cleanup NoShippingAtCheckout Feature Flag #2269

Merged
merged 9 commits into from
Feb 3, 2025
Merged

Conversation

scottkicks
Copy link
Contributor

@scottkicks scottkicks commented Jan 30, 2025

📲 What

1st step in cleaning up legacy checkout code. Code that isn't prefaced with NoShipping)

Because we're defaulting behavior to this No Shipping flow, and removing the legacy classes in my next PR, you'll find that the legacy view controller snapshots have changes. This is because they are reacting to the No Shipping flow behavior. Since, those will be deleted in my next PR it's no big deal, but it does make the # of file changes a lot here.

🤔 Why

Part of our effort to cleanup our checkout code and remove the now legacy checkout classes.

🛠 How

Deletes featureNoShippingEnabled() from RemoteConfigFeature and cleans up all uses of it.

✅ Acceptance criteria

  • No Shipping At Checkout is now the only version of checkout
  • No Shipping Flow experiences no change functionally or visually
  • No Shipping Feature Flag has been removed from Remote Config Feature Flags menu
  • There's no way to enter the non "no shipping" flow
  • All tests pass

@scottkicks scottkicks self-assigned this Jan 30, 2025
@nativeksr
Copy link
Collaborator

1 Warning
⚠️ Big PR

Generated by 🚫 Danger

@@ -367,7 +367,7 @@ public func rewardsCarouselCanNavigateToReward(_ reward: Reward, in project: Pro

let isBacking = userIsBacking(reward: reward, inProject: project)
let isAvailableForNewBacker = rewardIsAvailable(reward) && !isBacking
let isAvailableForExistingBackerToEdit = (isBacking && (reward.hasAddOns || featureNoShippingAtCheckout()))
let isAvailableForExistingBackerToEdit = isBacking
Copy link
Contributor Author

@scottkicks scottkicks Jan 30, 2025

Choose a reason for hiding this comment

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

In the new “no shipping” flow that is now the standard, backers should be able to edit rewards regardless of whether that reward hasAddOns. This is because backers need access to change their bonus or pledge amount.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you throw this in as a comment? It'd be also good to have it as a test somewhere, if that's not already covered in NoShippingPledgeViewModelTests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updatePledge is not available in the no shipping flow, so we can remove it completely now

@scottkicks scottkicks marked this pull request as ready for review February 3, 2025 14:31
@@ -50,17 +50,12 @@ final class PledgeRewardsSummaryTotalViewControllerTests: TestCase {
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, good to see these tests cleaned up. Did any other tests change or break now that the feature flag is permanently on?

Copy link
Contributor

@amy-at-kickstarter amy-at-kickstarter left a comment

Choose a reason for hiding this comment

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

WOW, that's a lotta deleted code! This LGTM. I've got two non-blocking comments:

First: are you confident that the critical paths for backing and updating in the no-shipping pathway are covered by the remaining tests? It's a little hard to tell just from the deletes, but now that this is the "real" pledge flow it would be good to double-check. Anywhere we were testing update should also have tests for updateReward and changePaymentMethod, for example.

Second: Wow, this ended up being a bigger change than I expected! Too late now, but in the future, I'd submit a change like this view-controller-by-view-controller. My guess is that you started by deleting the flag and figuring out which files needed to change, right? A nice way around that would be to split up your changes by commit like

commit1 Remove feature flag
commit2 Delete feature flag from FooViewModel
commit3 Delete feature flag from BarViewModel

Then you could cherry-pick commit2 and commit3 into their own individual branches, and they can be reviewed separately. Deleting the feature flag (commit1) could be submitted for review last, and would just be a one or two line change.

Thanks for fighting the good fight, looking forward to seeing this go out 🫡

@@ -31,17 +31,12 @@ final class PostCampaignCheckoutViewControllerTests: TestCase {
let mockService = MockService(fetchGraphUserResult: .success(response))
let project = Project.template
|> \.availableCardTypes .~ [CreditCardType.discover.rawValue]
let mockConfigClient = MockRemoteConfigClient()
mockConfigClient.features = [
RemoteConfigFeature.noShippingAtCheckout.rawValue: true
Copy link
Contributor

Choose a reason for hiding this comment

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

Huh, why were there tests with noShippingAtCheckout in PostCampaignCheckoutViewControllerTests? This VC should only ever have been used in the flow with shipping.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I'm not sure how this ended up here either. Glad it's being removed though.

@@ -19,10 +19,6 @@ public func featureDarkModeEnabled() -> Bool {
return featureEnabled(feature: .darkModeEnabled)
}

public func featureNoShippingAtCheckout() -> Bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

🎉 🙌 🎉

@@ -367,7 +367,7 @@ public func rewardsCarouselCanNavigateToReward(_ reward: Reward, in project: Pro

let isBacking = userIsBacking(reward: reward, inProject: project)
let isAvailableForNewBacker = rewardIsAvailable(reward) && !isBacking
let isAvailableForExistingBackerToEdit = (isBacking && (reward.hasAddOns || featureNoShippingAtCheckout()))
let isAvailableForExistingBackerToEdit = isBacking
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you throw this in as a comment? It'd be also good to have it as a test somewhere, if that's not already covered in NoShippingPledgeViewModelTests.

@@ -531,11 +523,6 @@ private func actionSheetMenuOptionsFor(

var actions = ManagePledgeAlertAction.allCases.filter { $0 != .viewRewards }

// TODO: Remove 'update pledge' from ManagePledgeAlertAction after feature rollout.
Copy link
Contributor

Choose a reason for hiding this comment

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

🎉

@@ -679,103 +670,6 @@ internal final class ManagePledgeViewModelTests: TestCase {
}
}

func testGoToUpdatePledge() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there tests for the other goTo... methods in this file? Specifically updateReward and changePaymentMethod.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea! There are existing tests that cover these outputs...
Screenshot 2025-02-03 at 10 45 02 AM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When it comes to updating rewards/pledge and bonus amounts and changing payment methods, the No Shipping feature work didn't change much except removing the "Update Pledge" menu option. We did that because the pledge/bonus amount selectors were removed from the checkout screen, rendering that menu option unnecessary.

Backed vs. unbacked reward card availability and the rest of the "Edit Reward" and "Change Payment" cases are still covered. I've also spent a decent amount of time testing various edge cases with the changes in this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome!

"Continue",
"Continue"
])
}
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@jovaniks jovaniks merged commit 45775a2 into main Feb 3, 2025
5 checks passed
@jovaniks jovaniks deleted the scott/mbl-2062 branch February 3, 2025 19:31
Copy link
Contributor

@ifosli ifosli left a comment

Choose a reason for hiding this comment

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

Overall, very exciting! I left a bunch of nits - up to you what you want to bother dealing with at this point. My main comment for future prs like this - make them smaller, please! If you go class by class (ex hardcode the flag to "true" first instead of deleting it entirely), it'll be easier to just delete tests that we don't need anymore, instead of accidentally modifying them, the way that we see in this pr.

let vc = PledgeViewController.instantiate()
vc.configure(with: data)
vc.delegate = self
/// Render rewards carousel that has the shipping location dropdown
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: This comment doesn't seem relevant anymore

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: These snapshots are only new because the test names changed. It would be nice to mark them as moved instead of added (I don't think that's worth doing now but definitely keep it in mind when you rename files!). Do please delete the old snapshots, though!

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like the shipping location got deleted again... That's not ideal but I don't think it's worth fixing if we're deleting the entire class anyways.

let vc = RewardsCollectionViewController.controller(with: project, refTag: refTag)
self.present(vc, animated: true)
}
/// Render rewards carousel that has the shipping location dropdown
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here; this comment doesn't seem helpful anymore

Copy link
Contributor

Choose a reason for hiding this comment

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

This is another example of tests that would've been easier to review if they'd been deleted immediately, instead of being changed now and deleted later.

if featureNoShippingAtCheckout() {
stackViews.insert(self.estimatedShippingStackView, at: 4)
}
stackViews.insert(self.estimatedShippingStackView, at: 4)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here; no need to insert after list has been created.

if featureNoShippingAtCheckout() {
baseSubviews.insert(self.estimatedShippingStackView, at: 4)
}
baseSubviews.insert(self.estimatedShippingStackView, at: 4)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here; this could've been added to the initial list

@@ -54,18 +54,11 @@ public final class PledgeShippingLocationViewModel: PledgeShippingLocationViewMo
.map { $0.3 }

let shippingShouldBeginLoading = reward
.map { featureNoShippingAtCheckout() ? true : $0.shipping.enabled }
.mapConst(true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Can we get rid of this signal entirely now? Probably in a separate pr?

])
self.pledgeButtonEnabled.assertValues(
[true, false, false, false, false, false, false, false, false, false]
[true, true, true, true, true, true, true, true, true, true]
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: All of the assertValues in this test are super repetitive; it'd be nice to replace them with assertLastValue instead.

"Selected"
])
}
// func testLive_BackedProject_BackedReward_Errored() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this commented out? I'm guessing this is an accident, but if it's on purpose, please add a comment explaining why/link a ticket to fix/update/delete the test!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants