Skip to content

Commit

Permalink
[#22] Rebase fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
blyscuit committed Dec 16, 2022
1 parent ea4e2f3 commit 19bf25a
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 28 deletions.
4 changes: 4 additions & 0 deletions iosApp/Survey.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
09CE773428E2ED2300EAA9EE /* Typealias+Koin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09CE773128E2ED2300EAA9EE /* Typealias+Koin.swift */; };
09FE26CD294B1EE3005A7F85 /* SurveySelectionView+DataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09FE26CC294B1EE3005A7F85 /* SurveySelectionView+DataSource.swift */; };
09FE26D1294B26A0005A7F85 /* SurveySelectionViewDataSourceSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09FE26CF294B264B005A7F85 /* SurveySelectionViewDataSourceSpec.swift */; };
09FE26D3294C1906005A7F85 /* ViewDidLoadModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09FE26D2294C1905005A7F85 /* ViewDidLoadModifier.swift */; };
351F5715D07BB9ED3F8B15F8 /* Pods_Survey.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 315DBBA2E56D199C3AC672B5 /* Pods_Survey.framework */; };
3D0ADA9FBBF8D55D5F00610F /* OptionalUnwrapSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1EE1175F99D55A95E0995E9 /* OptionalUnwrapSpec.swift */; };
5BBBFAF49689F25A8C1D57AB /* AutoMockable.generated.swift in Sources */ = {isa = PBXBuildFile; fileRef = A88CA60577ABA5F7885E1DE7 /* AutoMockable.generated.swift */; };
Expand Down Expand Up @@ -225,6 +226,7 @@
09CE773128E2ED2300EAA9EE /* Typealias+Koin.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Typealias+Koin.swift"; sourceTree = "<group>"; };
09FE26CC294B1EE3005A7F85 /* SurveySelectionView+DataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SurveySelectionView+DataSource.swift"; sourceTree = "<group>"; };
09FE26CF294B264B005A7F85 /* SurveySelectionViewDataSourceSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SurveySelectionViewDataSourceSpec.swift; sourceTree = "<group>"; };
09FE26D2294C1905005A7F85 /* ViewDidLoadModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewDidLoadModifier.swift; sourceTree = "<group>"; };
122A6B9F6217729620D91A43 /* DebugProduction.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = DebugProduction.xcconfig; sourceTree = "<group>"; };
15C39F2CB60CF0314258019E /* Pods-Survey.debug production.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Survey.debug production.xcconfig"; path = "Target Support Files/Pods-Survey/Pods-Survey.debug production.xcconfig"; sourceTree = "<group>"; };
16E10E52E1F7EAF6527F4E27 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -436,6 +438,7 @@
09636AFF28D4860F00A5CB97 /* PrimaryTextField.swift */,
09636B0128D4876100A5CB97 /* PrimaryButton.swift */,
09636B0C28D4917200A5CB97 /* OverlayButton.swift */,
09FE26D2294C1905005A7F85 /* ViewDidLoadModifier.swift */,
);
path = ViewModifiers;
sourceTree = "<group>";
Expand Down Expand Up @@ -1475,6 +1478,7 @@
buildActionMask = 2147483647;
files = (
0982A80729278E9000FC1976 /* SurveyHeaderLoading.swift in Sources */,
09FE26D3294C1906005A7F85 /* ViewDidLoadModifier.swift in Sources */,
09CE772728E2C44D00EAA9EE /* View+BackButton.swift in Sources */,
0982A80329278E9000FC1976 /* SurveyHeaderView.swift in Sources */,
09636B0D28D4917200A5CB97 /* OverlayButton.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Shared
protocol LoginCoordinator {

func showResetPassword()
func showHomeLoading()
func showHome()
}

extension LoginView {
Expand Down Expand Up @@ -69,7 +69,7 @@ extension LoginView {
showingLoading = state.isLoading
showingErrorAlert = !state.error.string.isEmpty
if state.isSuccess {
coordinator.showHomeLoading()
coordinator.showHome()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ struct SurveySelectionView: View {
}
.accessibilityElement(children: .contain)
.accessibility(.surveySelection(.view))
.onAppear {
.onLoad {
dataSource.fetch()
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// ViewDidLoadModifier.swift
// Survey
//
// Created by Bliss on 16/12/22.
// Copyright © 2022 Nimble. All rights reserved.
//

import SwiftUI

struct ViewDidLoadModifier: ViewModifier {

@State private var didLoad = false

private let action: (() -> Void)?

init(perform action: (() -> Void)? = nil) {
self.action = action
}

func body(content: Content) -> some View {
content.onAppear {
if didLoad == false {
didLoad = true
action?()
}
}
}
}

extension View {

func onLoad(perform action: (() -> Void)? = nil) -> some View {
modifier(ViewDidLoadModifier(perform: action))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ final class LoginViewDataSourceSpec: QuickSpec {

it("coordinator shows home") {
try self.awaitPublisher(dataSource.$viewState.collectNext(3))
expect(loginCoordinator.showHomeLoadingCallsCount) == 1
expect(loginCoordinator.showHomeCallsCount) == 1
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ final class LoginSpec: QuickSpec {
}

it("shows home screen") {
let surveyLoadingScreen = SurveyLoadingScreen(in: app)
surveyLoadingScreen.waitForExistence(timeout: .default, with: .view)
let surveySelectionScreen = SurveySelectionScreen(in: app)
surveySelectionScreen.waitForExistence(timeout: .default, with: .view)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,36 @@ final class SurveySelectionSpec: QuickSpec {
}

it("it shows its ui components") {
let mainImage = surveySelectionScreen.find(\.images, with: .mainImage)
expect(mainImage.exists) == true

let titleText = surveySelectionScreen.find(\.staticTexts, with: .titleText)
expect(titleText.exists) == true

let detailText = surveySelectionScreen.find(\.staticTexts, with: .detailText)
expect(detailText.exists) == true

let nextButton = surveySelectionScreen.find(\.buttons, with: .nextButton)
expect(nextButton.exists) == true

let headerView = surveySelectionScreen.find(\.staticTexts, with: .header)
expect(headerView.exists) == true
surveySelectionScreen.waitForExistence(
timeout: .default,
\.images,
with: .mainImage
)
surveySelectionScreen.waitForExistence(
timeout: .instant,
\.staticTexts,
with: .titleText
)
surveySelectionScreen.waitForExistence(
timeout: .instant,
\.staticTexts,
with: .detailText
)
surveySelectionScreen.waitForExistence(
timeout: .instant,
\.buttons,
with: .nextButton
)
surveySelectionScreen.waitForExistence(
timeout: .instant,
\.staticTexts,
with: .header
)
surveySelectionScreen.waitForExistence(
timeout: .instant,
\.images,
with: .header
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ class TokenizedNetworkClient: NetworkClient {
BearerTokens(accessToken, refreshToken)
}
}
sendWithoutRequest { request ->
val builder = HttpRequestBuilder()
builder.url("${BuildKonfig.BASE_URL}")
request.url.host != builder.url.host
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import co.nimblehq.blisskmmic.domain.usecase.GetProfileUseCase
import io.kotest.matchers.shouldBe
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.newSingleThreadContext
Expand Down Expand Up @@ -93,7 +94,10 @@ class SurveySelectionViewModelTest : TestsWithMocks() {
fun `When calling fetch with fail date and success user- it changes viewState with correct item`() = runTest {
mocker.every {
getCurrentDateUseCase()
} returns flow { error("") }
} returns flow {
delay(50)
error("")
}
mocker.every {
getProfileUseCase()
} returns flowOf(user)
Expand All @@ -120,7 +124,10 @@ class SurveySelectionViewModelTest : TestsWithMocks() {
} returns flowOf(dateComponent)
mocker.every {
getProfileUseCase()
} returns flow { error("") }
} returns flow {
delay(50)
error("")
}

surveySelectionViewModel.fetch()

Expand All @@ -144,7 +151,10 @@ class SurveySelectionViewModelTest : TestsWithMocks() {
} returns flow { error("") }
mocker.every {
getProfileUseCase()
} returns flow { error("") }
} returns flow {
delay(50)
error("")
}

surveySelectionViewModel.fetch()

Expand Down

0 comments on commit 19bf25a

Please sign in to comment.