Skip to content

Commit

Permalink
[No Ticket] Full MockOptimizely Removal PR Fixes/Cleanup (#1825)
Browse files Browse the repository at this point in the history
* add tests for RemoteConfigClientConfiguredNotification & RemoteConfigClientConfigurationFailedNotification

* remove redunant test

* simplify paymentSheetEnabled properties

* simplify campaignTabEnabled property

* cleanup test name

* remove snapshots associated with the test: testLoggedIn_Backer_LiveProject_NotShowingCampaign_Success

* remove snapshot tests for: testView_CurrentUser_LoggedIn_IsBacking
  • Loading branch information
scottkicks committed Jun 12, 2023
1 parent 0e92dd6 commit 7015f3b
Show file tree
Hide file tree
Showing 26 changed files with 33 additions and 40 deletions.
28 changes: 28 additions & 0 deletions Kickstarter-iOS/AppDelegateViewModelTests.swift
Expand Up @@ -2448,6 +2448,34 @@ final class AppDelegateViewModelTests: TestCase {
self.presentViewController.assertValues([1])
}
}

func testRemoteConfigClientConfiguredNotification_Success() {
let mockService = MockService(serverConfig: ServerConfig.staging)

withEnvironment(apiService: mockService) {
self.postNotificationName.assertDidNotEmitValue()

self.vm.inputs.applicationDidFinishLaunching(application: UIApplication.shared, launchOptions: nil)

self.vm.inputs.didUpdateRemoteConfigClient()

self.postNotificationName.assertValues([.ksr_remoteConfigClientConfigured])
}
}

func testRemoteConfigClientConfigurationFailedNotification() {
let mockService = MockService(serverConfig: ServerConfig.staging)

withEnvironment(apiService: mockService) {
self.postNotificationName.assertDidNotEmitValue()

self.vm.inputs.applicationDidFinishLaunching(application: UIApplication.shared, launchOptions: nil)

self.vm.inputs.remoteConfigClientConfigurationFailed()

self.postNotificationName.assertValues([.ksr_remoteConfigClientConfigurationFailed])
}
}
}

private let backingForCreatorPushData: [String: Any] = [
Expand Down
Expand Up @@ -174,35 +174,6 @@ internal final class CommentsViewControllerTests: TestCase {
}
}

func testView_CurrentUser_LoggedIn_IsBacking() {
let mockService =
MockService(fetchProjectCommentsEnvelopeResult: .success(CommentsEnvelope.multipleCommentTemplate))

let project = Project.template
|> \.personalization.isBacking .~ true

combos(Language.allLanguages, [Device.phone4_7inch, Device.pad]).forEach {
language, device in
withEnvironment(
apiService: mockService,
currentUser: .template,
language: language
) {
let controller = CommentsViewController.configuredWith(project: project)
let (parent, _) = traitControllers(device: device, orientation: .portrait, child: controller)
parent.view.frame.size.height = 1_100

self.scheduler.run()

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

func testView_NoComments_ShouldShowEmptyState() {
AppEnvironment.pushEnvironment(
apiService: MockService(
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 1 addition & 3 deletions Library/ViewModels/PaymentMethodsViewModel.swift
Expand Up @@ -53,9 +53,7 @@ public final class PaymentMethodsViewModel: PaymentMethodsViewModelType,
.materialize()
}

lazy var paymentSheetEnabled: Bool = {
true
}()
let paymentSheetEnabled: Bool = true

let deletePaymentMethodEvents = self.didDeleteCreditCardSignal
.map(first)
Expand Down
4 changes: 1 addition & 3 deletions Library/ViewModels/PledgePaymentMethodsViewModel.swift
Expand Up @@ -72,9 +72,7 @@ public final class PledgePaymentMethodsViewModel: PledgePaymentMethodsViewModelT
let context = configureWithValue.map { $0.context }
let availableCardTypes = project.map { $0.availableCardTypes }.skipNil()

lazy var paymentSheetEnabled: Bool = {
true
}()
let paymentSheetEnabled: Bool = true

let storedCardsEvent = configureWithValue
.switchMap { _ in
Expand Down
Expand Up @@ -894,7 +894,7 @@ final class PledgePaymentMethodsViewModelTests: TestCase {
}
}

func testGoToAddNewStripeCard_WithPaymentSheetEnabled_NoStoredCards_Success() {
func testGoToAddNewStripeCard_NoStoredCards_Success() {
let project = Project.template
let graphUser = GraphUser.template |> \.storedCards .~ UserCreditCards.withCards([])
let response = UserEnvelope<GraphUser>(me: graphUser)
Expand Down
6 changes: 2 additions & 4 deletions Library/ViewModels/ProjectPamphletMainCellViewModel.swift
Expand Up @@ -281,7 +281,7 @@ public final class ProjectPamphletMainCellViewModel: ProjectPamphletMainCellView
}

self.campaignTabShown = project.ignoreValues()
.map(campaignTabEnabled)
.map(value: campaignTabEnabled)
}

private let awakeFromNibProperty = MutableProperty(())
Expand Down Expand Up @@ -412,9 +412,7 @@ private func fundingStatus(forProject project: Project) -> String {
}
}

private func campaignTabEnabled() -> Bool {
true
}
private let campaignTabEnabled: Bool = true

typealias ConvertedCurrrencyProjectData = (pledgedAmount: Int, goalAmount: Int, country: Project.Country)

Expand Down

0 comments on commit 7015f3b

Please sign in to comment.