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

[MBL-1899] Checkout screen PLOT Badge #2223

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7fda0e7
Add functionality for the Pledge Over Time option selected
jovaniks Dec 5, 2024
5169766
Fix Tests
jovaniks Dec 5, 2024
ed401ec
Adding project to make the currency convertions and increments table …
jovaniks Dec 11, 2024
eff7fa4
Test timestamp with constant
jovaniks Dec 11, 2024
a334555
Add ineligible option
jovaniks Dec 11, 2024
b5aab6c
Format
jovaniks Dec 11, 2024
1c0df65
Fix test and add a new for ineligible
jovaniks Dec 11, 2024
43bd0a5
PR feedback
jovaniks Dec 11, 2024
5db01cb
Merge branch 'main' into jluna/MBL-1815/plot-plan-selector-selected-s…
jovaniks Dec 11, 2024
0f4c23e
Merge branch 'jluna/MBL-1815/plot-plan-selector-selected-state' into …
jovaniks Dec 11, 2024
2bcd664
minor nit
jovaniks Dec 11, 2024
acc641d
Minor nits
jovaniks Dec 12, 2024
7d6faa3
Merge branch 'jluna/MBL-1815/plot-plan-selector-selected-state' into …
jovaniks Dec 12, 2024
ee2bca5
Format
jovaniks Dec 12, 2024
809c848
update ineligible arg position
jovaniks Dec 13, 2024
9b07ae4
Add PLOT badge in to the pledge summary view
jovaniks Dec 14, 2024
9f506db
Fixing tests and improve how the PLOT data is manage
jovaniks Dec 15, 2024
52a6aa2
More tests
jovaniks Dec 15, 2024
8893498
PR Feedback
jovaniks Dec 17, 2024
8589d20
Merge branch 'main' into jluna/MBL-1815/plot-plan-selector-selected-s…
jovaniks Dec 17, 2024
d38cfa3
Merge branch 'main' into jluna/MBL-1815/plot-plan-selector-selected-s…
jovaniks Dec 17, 2024
26845e1
Merge conflicts and PR feedback
jovaniks Dec 17, 2024
581c945
Formatting
jovaniks Dec 17, 2024
d1da37d
Merge conflicts
jovaniks Dec 17, 2024
306337b
Merge branch 'main' into jluna/MBL-1816/plot-ineligible-state
jovaniks Dec 17, 2024
d42d885
Update GraphAPI file
jovaniks Dec 17, 2024
fc98638
Merge branch 'jluna/MBL-1816/plot-ineligible-state' into jluna/MBL-18…
jovaniks Dec 17, 2024
8f0e337
add missing field on test
jovaniks Dec 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ protocol PledgePaymentPlansViewControllerDelegate: AnyObject {
_ viewController: PledgePaymentPlansViewController,
didSelectPaymentPlan paymentPlan: PledgePaymentPlansType
)
func pledgePaymentPlansViewController(
_ viewController: PledgePaymentPlansViewController,
didTapTermsOfUseWith helpType: HelpType
)
}

final class PledgePaymentPlansViewController: UIViewController {
Expand Down Expand Up @@ -39,11 +43,11 @@ final class PledgePaymentPlansViewController: UIViewController {
self.pledgeInFullOption.delegate = self
self.pledgeOverTimeOption.delegate = self

self.rootStackView.addArrangedSubviews([
self.rootStackView.addArrangedSubviews(
self.pledgeInFullOption,
self.separatorView,
self.pledgeOverTimeOption
])
)
}

private func setupConstraints() {
Expand Down Expand Up @@ -81,12 +85,18 @@ final class PledgePaymentPlansViewController: UIViewController {
guard let self = self else { return }

self.pledgeInFullOption.configureWith(value: PledgePaymentPlanOptionData(
ineligible: data.ineligible,
type: .pledgeInFull,
selectedType: data.selectedPlan
selectedType: data.selectedPlan,
paymentIncrements: data.paymentIncrements,
project: data.project
))
self.pledgeOverTimeOption.configureWith(value: PledgePaymentPlanOptionData(
ineligible: data.ineligible,
type: .pledgeOverTime,
selectedType: data.selectedPlan
selectedType: data.selectedPlan,
paymentIncrements: data.paymentIncrements,
project: data.project
))
}

Expand All @@ -97,6 +107,13 @@ final class PledgePaymentPlansViewController: UIViewController {

self.delegate?.pledgePaymentPlansViewController(self, didSelectPaymentPlan: paymentPlan)
}
self.viewModel.outputs.notifyDelegateTermsOfUseTapped
.observeForUI()
.observeValues { [weak self] helpType in
guard let self = self else { return }

self.delegate?.pledgePaymentPlansViewController(self, didTapTermsOfUseWith: helpType)
}
}

// MARK: - Configuration
Expand All @@ -115,6 +132,13 @@ extension PledgePaymentPlansViewController: PledgePaymentPlanOptionViewDelegate
) {
self.viewModel.inputs.didSelectPlanType(paymentPlanType)
}

func pledgePaymentPlansViewController(
_: PledgePaymentPlanOptionView,
didTapTermsOfUseWith helpType: HelpType
) {
self.viewModel.inputs.didTapTermsOfUse(with: helpType)
}
}

// MARK: Styles
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@testable import Kickstarter_Framework
@testable import KsApi
@testable import Library
import Prelude
import SnapshotTesting
Expand All @@ -19,11 +20,12 @@ final class PledgePaymentPlansViewControllerTest: TestCase {
}

func testView_PledgeInFullSelected() {
let project = Project.template
orthogonalCombos([Language.en], [Device.pad, Device.phone4_7inch]).forEach { language, device in
withEnvironment(language: language) {
let controller = PledgePaymentPlansViewController.instantiate()

let data = PledgePaymentPlansAndSelectionData(selectedPlan: .pledgeInFull)
let data = PledgePaymentPlansAndSelectionData(selectedPlan: .pledgeInFull, project: project)
controller.configure(with: data)

let (parent, _) = traitControllers(device: device, orientation: .portrait, child: controller)
Expand All @@ -37,20 +39,69 @@ final class PledgePaymentPlansViewControllerTest: TestCase {
}

func testView_PledgeOverTimeSelected() {
let project = Project.template
let testIncrements = testPledgePaymentIncrement()
orthogonalCombos([Language.en], [Device.pad, Device.phone4_7inch]).forEach { language, device in
withEnvironment(language: language) {
let controller = PledgePaymentPlansViewController.instantiate()

let data = PledgePaymentPlansAndSelectionData(selectedPlan: .pledgeOverTime)
let data = PledgePaymentPlansAndSelectionData(
selectedPlan: .pledgeOverTime,
increments: testIncrements,
ineligible: false,
project: project
)
controller.configure(with: data)

controller.pledgePaymentPlanOptionView(
PledgePaymentPlanOptionView(),
didSelectPlanType: .pledgeOverTime
)

let (parent, _) = traitControllers(device: device, orientation: .portrait, child: controller)
parent.view.frame.size.height = 400

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

assertSnapshot(matching: parent.view, as: .image, named: "lang_\(language)_device_\(device)")
}
}
}

func testView_PledgeOverTimeIneligible() {
orthogonalCombos([Language.en], [Device.pad, Device.phone4_7inch]).forEach { language, device in
withEnvironment(language: language) {
let controller = PledgePaymentPlansViewController.instantiate()

let data = PledgePaymentPlansAndSelectionData(
selectedPlan: .pledgeInFull,
ineligible: true,
project: Project.template
)

controller.configure(with: data)

let (parent, _) = traitControllers(device: device, orientation: .portrait, child: controller)
parent.view.frame.size.height = 120

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

assertSnapshot(matching: parent.view, as: .image, named: "lang_\(language)_device_\(device)")
}
}
}
}

private func testPledgePaymentIncrement() -> [PledgePaymentIncrement] {
var increments: [PledgePaymentIncrement] = []
var timeStamp = TimeInterval(1_733_931_903)
for _ in 1...4 {
timeStamp += 30 * 24 * 60 * 60
increments.append(PledgePaymentIncrement(
amount: PledgePaymentIncrementAmount(amount: 250.0, currency: "USD"),
scheduledCollection: timeStamp
))
}

return increments
}
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