Skip to content

Commit

Permalink
Revert Pledge Redemption M1 Work (#2100)
Browse files Browse the repository at this point in the history
* Revert "[MBL-1631] Remove Shipping Dropdown From Add-Ons (#2097)"

This reverts commit b9398aa.

* Revert "[MBL-1599] Adds the Shipping Dropdown Selector to the Rewards Carousel. (#2095)"

This reverts commit e495aca.
  • Loading branch information
scottkicks authored Jul 24, 2024
1 parent f130ccd commit 773c817
Show file tree
Hide file tree
Showing 401 changed files with 413 additions and 763 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,14 @@ final class PledgeViewControllerTests: TestCase {
let project = Project.template
|> \.availableCardTypes .~ [CreditCardType.discover.rawValue]

orthogonalCombos(Language.allLanguages, Device.allCases).forEach { language, device in
combos(Language.allLanguages, Device.allCases).forEach { language, device in
withEnvironment(apiService: mockService, currentUser: User.template, language: language) {
let controller = PledgeViewController.instantiate()

let reward = Reward.template
let data = PledgeViewData(
project: project,
rewards: [reward],
selectedShippingRule: ShippingRule.template,
selectedQuantities: [reward.id: 1],
selectedLocationId: nil,
refTag: nil,
Expand Down Expand Up @@ -88,7 +87,6 @@ final class PledgeViewControllerTests: TestCase {
let data = PledgeViewData(
project: project,
rewards: [reward],
selectedShippingRule: ShippingRule.template,
selectedQuantities: [reward.id: 1],
selectedLocationId: nil,
refTag: nil,
Expand All @@ -114,7 +112,7 @@ final class PledgeViewControllerTests: TestCase {
func testView_PledgeContext_NeedsConversion_IsFalse() {
let response = UserEnvelope<GraphUser>(me: self.userWithCards)
let mockService = MockService(fetchGraphUserResult: .success(response))
orthogonalCombos(Language.allLanguages, [Device.phone4_7inch, Device.pad], [nil, User.template])
combos(Language.allLanguages, [Device.phone4_7inch, Device.pad], [nil, User.template])
.forEach { language, device, currentUser in
withEnvironment(apiService: mockService, currentUser: currentUser, language: language) {
let controller = PledgeViewController.instantiate()
Expand All @@ -123,7 +121,6 @@ final class PledgeViewControllerTests: TestCase {
let data = PledgeViewData(
project: project,
rewards: [reward],
selectedShippingRule: ShippingRule.template,
selectedQuantities: [reward.id: 1],
selectedLocationId: nil,
refTag: nil,
Expand Down Expand Up @@ -167,14 +164,13 @@ final class PledgeViewControllerTests: TestCase {
|> Project.lens.stats.currentCurrency .~ Project.Country.gb.currencyCode
|> Project.lens.stats.currentCurrencyRate .~ .some(2.0)

orthogonalCombos(Language.allLanguages, [Device.phone4_7inch, Device.pad], [nil, User.template])
combos(Language.allLanguages, [Device.phone4_7inch, Device.pad], [nil, User.template])
.forEach { language, device, currentUser in
withEnvironment(apiService: mockService, currentUser: currentUser, language: language) {
let controller = PledgeViewController.instantiate()
let data = PledgeViewData(
project: project,
rewards: [reward],
selectedShippingRule: ShippingRule.template,
selectedQuantities: [reward.id: 1],
selectedLocationId: nil,
refTag: nil,
Expand Down Expand Up @@ -224,7 +220,6 @@ final class PledgeViewControllerTests: TestCase {
let data = PledgeViewData(
project: project,
rewards: [reward],
selectedShippingRule: ShippingRule.template,
selectedQuantities: [reward.id: 1],
selectedLocationId: nil,
refTag: nil,
Expand Down Expand Up @@ -269,7 +264,6 @@ final class PledgeViewControllerTests: TestCase {
let data = PledgeViewData(
project: project,
rewards: [reward],
selectedShippingRule: ShippingRule.template,
selectedQuantities: [reward.id: 1],
selectedLocationId: nil,
refTag: nil,
Expand Down Expand Up @@ -314,7 +308,6 @@ final class PledgeViewControllerTests: TestCase {
let data = PledgeViewData(
project: project,
rewards: [reward],
selectedShippingRule: ShippingRule.template,
selectedQuantities: [reward.id: 1],
selectedLocationId: nil,
refTag: nil,
Expand Down Expand Up @@ -360,7 +353,6 @@ final class PledgeViewControllerTests: TestCase {
let data = PledgeViewData(
project: project,
rewards: [reward],
selectedShippingRule: ShippingRule.template,
selectedQuantities: [reward.id: 1],
selectedLocationId: nil,
refTag: nil,
Expand Down Expand Up @@ -403,13 +395,12 @@ final class PledgeViewControllerTests: TestCase {
|> Backing.lens.amount .~ 700.0
)

orthogonalCombos(Language.allLanguages, [Device.phone4_7inch, Device.pad]).forEach { language, device in
combos(Language.allLanguages, [Device.phone4_7inch, Device.pad]).forEach { language, device in
withEnvironment(apiService: mockService, currentUser: .template, language: language) {
let controller = PledgeViewController.instantiate()
let data = PledgeViewData(
project: project,
rewards: [reward],
selectedShippingRule: ShippingRule.template,
selectedQuantities: [reward.id: 1],
selectedLocationId: nil,
refTag: nil,
Expand Down Expand Up @@ -453,13 +444,12 @@ final class PledgeViewControllerTests: TestCase {
let response = UserEnvelope<GraphUser>(me: self.userWithCards)
let mockService = MockService(fetchGraphUserResult: .success(response))

orthogonalCombos(Language.allLanguages, [Device.phone4_7inch, Device.pad]).forEach { language, device in
combos(Language.allLanguages, [Device.phone4_7inch, Device.pad]).forEach { language, device in
withEnvironment(apiService: mockService, currentUser: .template, language: language) {
let controller = PledgeViewController.instantiate()
let data = PledgeViewData(
project: project,
rewards: [reward],
selectedShippingRule: ShippingRule.template,
selectedQuantities: [reward.id: 1],
selectedLocationId: nil,
refTag: nil,
Expand Down Expand Up @@ -497,13 +487,12 @@ final class PledgeViewControllerTests: TestCase {

let reward = Reward.template

orthogonalCombos(Language.allLanguages, Device.allCases).forEach { language, device in
combos(Language.allLanguages, Device.allCases).forEach { language, device in
withEnvironment(apiService: mockService, currentUser: User.template, language: language) {
let controller = PledgeViewController.instantiate()
let data = PledgeViewData(
project: project,
rewards: [reward],
selectedShippingRule: ShippingRule.template,
selectedQuantities: [reward.id: 1],
selectedLocationId: nil,
refTag: nil,
Expand All @@ -529,14 +518,13 @@ final class PledgeViewControllerTests: TestCase {
let reward = Reward.template
|> (Reward.lens.shipping .. Reward.Shipping.lens.enabled) .~ true

orthogonalCombos(Language.allLanguages, [Device.phone4_7inch, Device.pad], [nil, User.template])
combos(Language.allLanguages, [Device.phone4_7inch, Device.pad], [nil, User.template])
.forEach { language, device, currentUser in
withEnvironment(language: language) {
let controller = PledgeViewController.instantiate()
let data = PledgeViewData(
project: .template,
rewards: [reward],
selectedShippingRule: ShippingRule.template,
selectedQuantities: [reward.id: 1],
selectedLocationId: nil,
refTag: nil,
Expand Down Expand Up @@ -566,14 +554,13 @@ final class PledgeViewControllerTests: TestCase {
let reward = Reward.template
|> (Reward.lens.shipping .. Reward.Shipping.lens.enabled) .~ true

orthogonalCombos(Language.allLanguages, [Device.phone4_7inch, Device.pad], [nil, User.template])
combos(Language.allLanguages, [Device.phone4_7inch, Device.pad], [nil, User.template])
.forEach { language, device, currentUser in
withEnvironment(language: language) {
let controller = PledgeViewController.instantiate()
let data = PledgeViewData(
project: .template,
rewards: [reward, .noReward],
selectedShippingRule: ShippingRule.template,
selectedQuantities: [reward.id: 1, Reward.noReward.id: 1],
selectedLocationId: nil,
refTag: nil,
Expand Down Expand Up @@ -605,14 +592,13 @@ final class PledgeViewControllerTests: TestCase {
|> (Reward.lens.shipping .. Reward.Shipping.lens.preference) .~ .local
|> Reward.lens.localPickup .~ Location.losAngeles

orthogonalCombos(Language.allLanguages, [Device.phone4_7inch, Device.pad], [nil, User.template])
combos(Language.allLanguages, [Device.phone4_7inch, Device.pad], [nil, User.template])
.forEach { language, device, currentUser in
withEnvironment(language: language) {
let controller = PledgeViewController.instantiate()
let data = PledgeViewData(
project: .template,
rewards: [reward, .noReward],
selectedShippingRule: ShippingRule.template,
selectedQuantities: [reward.id: 1, Reward.noReward.id: 1],
selectedLocationId: nil,
refTag: nil,
Expand Down Expand Up @@ -653,14 +639,13 @@ final class PledgeViewControllerTests: TestCase {
let data = PledgeViewData(
project: project,
rewards: [reward, addOnReward1, addOnReward2],
selectedShippingRule: ShippingRule.template,
selectedQuantities: [reward.id: 1, addOnReward1.id: 2, addOnReward2.id: 1],
selectedLocationId: ShippingRule.template.id,
refTag: .projectPage,
context: .pledge
)

orthogonalCombos(Language.allLanguages, [Device.phone4_7inch, Device.pad], [nil, User.template])
combos(Language.allLanguages, [Device.phone4_7inch, Device.pad], [nil, User.template])
.forEach { language, device, currentUser in
withEnvironment(language: language) {
let controller = PledgeViewController.instantiate()
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ final class RewardAddOnSelectionViewController: UIViewController {
private lazy var headerLabel: UILabel = UILabel(frame: .zero)
private lazy var headerView: UIView = UIView(frame: .zero)
private lazy var headerRootStackView: UIStackView = UIStackView(frame: .zero)
private lazy var pledgeShippingLocationViewController: PledgeShippingLocationViewController = {
PledgeShippingLocationViewController.instantiate()
|> \.delegate .~ self
}()

private lazy var continueCTAView: RewardAddOnSelectionContinueCTAView = {
RewardAddOnSelectionContinueCTAView(frame: .zero)
Expand Down Expand Up @@ -92,8 +96,11 @@ final class RewardAddOnSelectionViewController: UIViewController {
|> ksr_addSubviewToParent()
|> ksr_constrainViewToEdgesInParent(priority: UILayoutPriority(rawValue: 999))

_ = ([self.headerLabel], self.headerRootStackView)
_ = ([self.headerLabel, self.pledgeShippingLocationViewController.view], self.headerRootStackView)
|> ksr_addArrangedSubviewsToStackView()

self.addChild(self.pledgeShippingLocationViewController)
self.pledgeShippingLocationViewController.didMove(toParent: self)
}

private func setupConstraints() {
Expand Down Expand Up @@ -139,12 +146,21 @@ final class RewardAddOnSelectionViewController: UIViewController {
override func bindViewModel() {
super.bindViewModel()

self.pledgeShippingLocationViewController.view.rac.hidden
= self.viewModel.outputs.shippingLocationViewIsHidden

self.viewModel.outputs.configureContinueCTAViewWithData
.observeForUI()
.observeValues { [weak self] data in
self?.continueCTAView.configure(with: data)
}

self.viewModel.outputs.configurePledgeShippingLocationViewControllerWithData
.observeForUI()
.observeValues { [weak self] data in
self?.pledgeShippingLocationViewController.configureWith(value: data)
}

self.viewModel.outputs.loadAddOnRewardsIntoDataSourceAndReloadTableView
.observeForUI()
.observeValues { [weak self] items in
Expand Down Expand Up @@ -211,6 +227,25 @@ final class RewardAddOnSelectionViewController: UIViewController {
}
}

// MARK: - PledgeShippingLocationViewControllerDelegate

extension RewardAddOnSelectionViewController: PledgeShippingLocationViewControllerDelegate {
func pledgeShippingLocationViewController(
_: PledgeShippingLocationViewController,
didSelect shippingRule: ShippingRule
) {
self.viewModel.inputs.shippingRuleSelected(shippingRule)
}

func pledgeShippingLocationViewControllerLayoutDidUpdate(_: PledgeShippingLocationViewController) {
self.tableView.ksr_sizeHeaderFooterViewsToFit()
}

func pledgeShippingLocationViewControllerFailedToLoad(_: PledgeShippingLocationViewController) {
self.viewModel.inputs.shippingLocationViewDidFailToLoad()
}
}

// MARK: - RewardAddOnCardViewDelegate

extension RewardAddOnSelectionViewController: RewardAddOnCardViewDelegate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,13 @@ final class RewardAddOnSelectionViewControllerTests: TestCase {

let mockService = MockService(fetchRewardAddOnsSelectionViewRewardsResult: .success(project))

orthogonalCombos(Language.allLanguages, Device.allCases).forEach { language, device in
combos(Language.allLanguages, Device.allCases).forEach { language, device in
withEnvironment(apiService: mockService) {
let controller = RewardAddOnSelectionViewController.instantiate()

let data = PledgeViewData(
project: project,
rewards: [reward],
selectedShippingRule: ShippingRule.template,
selectedQuantities: [:],
selectedLocationId: nil,
refTag: nil,
Expand Down Expand Up @@ -98,13 +97,12 @@ final class RewardAddOnSelectionViewControllerTests: TestCase {
fetchRewardAddOnsSelectionViewRewardsResult: .success(project)
)

orthogonalCombos(Language.allLanguages, Device.allCases).forEach { language, device in
combos(Language.allLanguages, Device.allCases).forEach { language, device in
withEnvironment(apiService: mockService) {
let controller = RewardAddOnSelectionViewController.instantiate()
let data = PledgeViewData(
project: project,
rewards: [reward],
selectedShippingRule: ShippingRule.template,
selectedQuantities: [:],
selectedLocationId: nil,
refTag: nil,
Expand All @@ -116,6 +114,13 @@ final class RewardAddOnSelectionViewControllerTests: TestCase {

self.scheduler.advance()

controller.pledgeShippingLocationViewController(
PledgeShippingLocationViewController.instantiate(),
didSelect: .template
)

self.scheduler.advance(by: .seconds(1))

assertSnapshot(
matching: parent.view,
as: .image(perceptualPrecision: 0.98),
Expand Down Expand Up @@ -196,13 +201,12 @@ final class RewardAddOnSelectionViewControllerTests: TestCase {
fetchRewardAddOnsSelectionViewRewardsResult: .success(project)
)

orthogonalCombos(Language.allLanguages, Device.allCases).forEach { language, device in
combos(Language.allLanguages, Device.allCases).forEach { language, device in
withEnvironment(apiService: mockService) {
let controller = RewardAddOnSelectionViewController.instantiate()
let data = PledgeViewData(
project: project,
rewards: [reward],
selectedShippingRule: ShippingRule.template,
selectedQuantities: [:],
selectedLocationId: nil,
refTag: nil,
Expand All @@ -214,6 +218,13 @@ final class RewardAddOnSelectionViewControllerTests: TestCase {

self.scheduler.advance()

controller.pledgeShippingLocationViewController(
PledgeShippingLocationViewController.instantiate(),
didSelect: shippingRule
)

self.scheduler.advance(by: .seconds(1))

assertSnapshot(
matching: parent.view,
as: .image(perceptualPrecision: 0.98),
Expand All @@ -231,14 +242,13 @@ final class RewardAddOnSelectionViewControllerTests: TestCase {

let mockService = MockService(fetchRewardAddOnsSelectionViewRewardsResult: .failure(.couldNotParseJSON))

orthogonalCombos(Language.allLanguages, Device.allCases).forEach { language, device in
combos(Language.allLanguages, Device.allCases).forEach { language, device in
withEnvironment(apiService: mockService) {
let controller = RewardAddOnSelectionViewController.instantiate()

let data = PledgeViewData(
project: project,
rewards: [reward],
selectedShippingRule: ShippingRule.template,
selectedQuantities: [:],
selectedLocationId: nil,
refTag: nil,
Expand Down Expand Up @@ -278,14 +288,13 @@ final class RewardAddOnSelectionViewControllerTests: TestCase {

let mockService = MockService(fetchRewardAddOnsSelectionViewRewardsResult: .success(project))

orthogonalCombos(Language.allLanguages, [Device.phone5_8inch, Device.pad]).forEach { language, device in
combos(Language.allLanguages, [Device.phone5_8inch, Device.pad]).forEach { language, device in
withEnvironment(apiService: mockService, language: language) {
let controller = RewardAddOnSelectionViewController.instantiate()

let data = PledgeViewData(
project: project,
rewards: [reward],
selectedShippingRule: ShippingRule.template,
selectedQuantities: [:],
selectedLocationId: nil,
refTag: nil,
Expand Down
Loading

0 comments on commit 773c817

Please sign in to comment.