Skip to content

Commit

Permalink
[WEAV-117] Debug View 상세 구현, Transition 처리 보완 (#38)
Browse files Browse the repository at this point in the history
* [WEAV-117] Debug View 상세 구현, login 뷰 전환 처리 보완

* [WEAV-117] Tansition library 추가

* [WEAV-117] UnitTestFail 처리

* [WEAV-117] 리뷰 반영

* [WEAV-117] unittest action script edited

* [WEAV-117] Unit Test Edited

* [WEAV-117] 테스트 실패 대응
  • Loading branch information
jisu15-kim authored Nov 2, 2024
1 parent bd1422e commit 6a2651d
Show file tree
Hide file tree
Showing 13 changed files with 119 additions and 35 deletions.
18 changes: 16 additions & 2 deletions .github/workflows/unitTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,19 @@ jobs:

- name: Run unit tests
run: |
xcodebuild test -scheme three-days-UnitTest -destination 'platform=iOS Simulator,name=iPhone 15,OS=latest' | tee result.log
continue-on-error: true
set -o pipefail && xcodebuild test \
-scheme three-days-UnitTest \
-destination 'platform=iOS Simulator,name=iPhone 15,OS=latest' \
| tee result.log
if grep -q "** TEST FAILED **" result.log; then
exit 1
fi
continue-on-error: false

- name: Failure notification to Discord
if: failure()
run: |
curl -H "Content-Type: application/json" \
-X POST \
-d "{\"content\": null, \"embeds\": [{\"title\": \"iOS 유닛 테스트 실패..?\", \"description\": \"Actor: ${{ github.actor }}\nBranch: ${{ github.head_ref }}\nCommit: ${{ github.event.pull_request.head.sha }}\n\n💥 잉?!\", \"color\": 16711741}]}" \
${{ secrets.DISCORD_WEBHOOK_URL }}
3 changes: 2 additions & 1 deletion Projects/App/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ let infoPlist = InfoPlist.extendingDefault(
let appDependencies: [TargetDependency] = [
.project(target: .home),
.project(target: .signUp),
.project(target: .designPreview)
.project(target: .designPreview),
.external(.navigationTransitions)
]

let project: Project = .make(
Expand Down
46 changes: 33 additions & 13 deletions Projects/App/Sources/Debug/AuthInfoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import SwiftUI
import DesignCore
import CoreKit
import CommonKit

#if DEBUG || STAGING
struct TableInfoModel: Identifiable {
Expand All @@ -26,9 +27,9 @@ enum Sections: CaseIterable {
var sectionTitle: String {
switch self {
case .authInfo: "토큰 정보"
case .userInfo: "유저 정보(TEMP)"
case .userProfile: "프로필 정보(TEMP)"
case .dreamPartnerInfo: "이상형 정보(TEMP)"
case .userInfo: "유저 정보"
case .userProfile: "프로필 정보"
case .dreamPartnerInfo: "이상형 정보"
}
}

Expand Down Expand Up @@ -57,40 +58,59 @@ enum Sections: CaseIterable {
),
TableInfoModel(
title: "이름",
value: "홍길동"
value: AppCoordinator.shared.userInfo?.name ?? "null"
),
TableInfoModel(
title: "휴대폰 번호",
value: "010-1234-1234"
value: AppCoordinator.shared.userInfo?.phone ?? "null"
)
]
case .userProfile:
[
TableInfoModel(
title: "출생년도",
value: "1996"
value: AppCoordinator.shared.userInfo?.profile.birthYear == nil ? "null" : String((AppCoordinator.shared.userInfo?.profile.birthYear)!)
),
TableInfoModel(
title: "회사 ID",
value: UUID().uuidString
value: AppCoordinator.shared.userInfo?.profile.companyId ?? "null"
),
TableInfoModel(
title: "성별",
value: "MALE"
value: AppCoordinator.shared.userInfo?.profile.gender.rawValue ?? "null"
),
TableInfoModel(
title: "직군정보",
value: UUID().uuidString
value: AppCoordinator.shared.userInfo?.profile.jobOccupation ?? "null"
),
TableInfoModel(
title: "활동지역 ID",
value: [UUID(), UUID(), UUID()]
.map { $0.uuidString }
.joined(separator: "\n")
value: AppCoordinator.shared.userInfo?.profile.locations != nil ? AppCoordinator.shared.userInfo!.profile.locations
.compactMap { $0 }
.joined(separator: "\n") : "null"
)
]
case .dreamPartnerInfo:
[]
[
TableInfoModel(
title: "출생년도 범위",
value: "\(AppCoordinator.shared.userInfo?.dreamPartner.lowerBirthYear ?? 0) ~ \(AppCoordinator.shared.userInfo?.dreamPartner.upperBirthYear ?? 0)"
),
TableInfoModel(
title: "같은 회사 소개 여부",
value: AppCoordinator.shared.userInfo?.dreamPartner.allowSameCompany == nil ? "null" : String((AppCoordinator.shared.userInfo?.dreamPartner.allowSameCompany)!)
),
TableInfoModel(
title: "거리",
value: AppCoordinator.shared.userInfo?.dreamPartner.distanceType.description ?? "null"
),
TableInfoModel(
title: "직군정보",
value: AppCoordinator.shared.userInfo?.dreamPartner.jobOccupations != nil ? AppCoordinator.shared.userInfo!.dreamPartner.jobOccupations
.compactMap { $0 }
.joined(separator: "\n") : "null"
)
]
}
}
}
Expand Down
14 changes: 9 additions & 5 deletions Projects/App/Sources/Splash/SplashAnimatedView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ struct SplashAnimatedView: View {
@State private var cycleCompleted = false
@State private var otherViewOpacity: CGFloat = 0.0
@State private var showLetterAnimation = false
@State private var viewDisappeared: Bool = false
@State private var iconStates: [IconState] = [
IconState(
id: 0,
Expand Down Expand Up @@ -115,9 +116,7 @@ struct SplashAnimatedView: View {
isActive: true,
isShowLetter: $showLetterAnimation
) {
AppCoordinator.shared.navigationStack.append(
.signUp(.authPhoneInput)
)
AppCoordinator.shared.changeRootView(.signUp(.authPhoneInput))
}
.frame(height: 70)
.padding(.horizontal, 50)
Expand All @@ -130,10 +129,15 @@ struct SplashAnimatedView: View {
.task {
await runSingleCycle()
}
.onDisappear {
viewDisappeared = true
}
}

private func runSingleCycle() async {
guard !cycleCompleted else { return }
for step in SplashAnimationStep.allCases.dropFirst() {
if viewDisappeared { return }
guard !cycleCompleted else { break }
if step == .fifth {
// auth 상태 체크
Expand All @@ -142,7 +146,7 @@ struct SplashAnimatedView: View {
/// 로그아웃 -> 애니메이션 계속진행
if isAuthorized {
try? await Task.sleep(for: .seconds(1))
await pushToHomeView()
pushToHomeView()
break
}
}
Expand Down Expand Up @@ -173,7 +177,7 @@ struct SplashAnimatedView: View {

@MainActor
private func pushToHomeView() {
AppCoordinator.shared.push(.authDebug)
AppCoordinator.shared.changeRootView(.authDebug)
}

private func updateIconStates(for step: SplashAnimationStep) {
Expand Down
5 changes: 5 additions & 0 deletions Projects/App/Sources/ThreeDaysApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import DesignCore
import DesignPreview
import CommonKit
import Home
import NavigationTransitions

@main
struct ThreeDaysApp: App {
Expand Down Expand Up @@ -33,6 +34,10 @@ struct ThreeDaysApp: App {
feature.view
}
}
.navigationTransition(
AppCoordinator.shared.needFadeTransition ? .fade(.cross) : .slide,
interactivity: AppCoordinator.shared.isRootView ? .disabled : .pan
)
}

#if STAGING || DEBUG
Expand Down
19 changes: 16 additions & 3 deletions Projects/Core/CommonKit/Sources/AppCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,25 @@ public final class AppCoordinator: ObservableObject {
}

//MARK: - Properties
@Published public var authState: AuthState = .none
@Published public var userInfo: UserInfo?
public var authState: AuthState = .none
public var userInfo: UserInfo?
public var needFadeTransition: Bool = false
@Published public var navigationStack: [PathType] = [.intro]
let authService = AuthService.shared

public var isRootView: Bool {
navigationStack.count == 1
}

//MARK: - Methods
private func setup() {
AuthState.changeHandler = { [weak self] state in
DispatchQueue.main.async {
self?.authState = state
if state == .loggedOut {
self?.navigationStack = [.intro]
if self?.navigationStack != [.intro] {
self?.navigationStack = [.intro]
}
self?.userInfo = nil
}
}
Expand All @@ -40,11 +47,13 @@ public final class AppCoordinator: ObservableObject {

@MainActor
public func changeRootView(_ path: PathType) {
needFadeTransition = true
navigationStack = [path]
}

@MainActor
public func push(_ path: PathType) {
needFadeTransition = false
navigationStack.append(path)
}

Expand All @@ -69,6 +78,10 @@ public final class AppCoordinator: ObservableObject {
if refreshToken == nil {
refreshToken = TokenManager.refreshToken
}

print("👉 accessToken: \(TokenManager.accessToken ?? "null")")
print("👉 refreshToken: \(TokenManager.refreshToken ?? "null")")

guard accessToken != nil && accessToken != "" else {
await MainActor.run {
AuthState.change(.loggedOut)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Foundation
import HTTPTypes

actor LoggingMiddleware {
package init() {}
init() {}
}

extension LoggingMiddleware: ClientMiddleware {
Expand Down Expand Up @@ -45,12 +45,8 @@ extension LoggingMiddleware: ClientMiddleware {

private func copyBody(_ body: HTTPBody?) async throws -> (Data?, HTTPBody?) {
guard let body = body else { return (nil, nil) }

if case .known(let length) = body.length {
let data = try await Data(collecting: body, upTo: Int(length))
return (data, HTTPBody(data))
}
return (nil, body)
let data = try await Data(collecting: body, upTo: 10 * 1024 * 1024)
return (data, HTTPBody(data))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ extension AuthPhoneVerifyIntent: AuthPhoneVerifyIntent.Intentable {
input: payload
)
)
case .EXISTING: return .home
case .EXISTING: return .authDebug
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class AuthPhoneVerifyTest: XCTestCase {

func testVerificationResult() {
let homePath = intent.getNextPath(userType: .EXISTING)
XCTAssertEqual(homePath, PathType.home)
XCTAssertEqual(homePath, PathType.authDebug)

let signUpProcessPath = intent.getNextPath(userType: .NEW)
XCTAssertEqual(signUpProcessPath, PathType.signUp(.authAgreement(input: .mock)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public enum DreamPartnerDistanceType: CaseIterable {
}
}

public enum GenderType: CaseIterable {
public enum GenderType: String, CaseIterable {
case male
case female

Expand Down
18 changes: 18 additions & 0 deletions Tuist/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,24 @@
"revision" : "9bf4c712ad7989d6a91dbe68748b8829a50837e4",
"version" : "1.0.2"
}
},
{
"identity" : "swiftui-introspect",
"kind" : "remoteSourceControl",
"location" : "https://github.com/siteline/swiftui-introspect",
"state" : {
"revision" : "807f73ce09a9b9723f12385e592b4e0aaebd3336",
"version" : "1.3.0"
}
},
{
"identity" : "swiftui-navigation-transitions",
"kind" : "remoteSourceControl",
"location" : "https://github.com/davdroman/swiftui-navigation-transitions.git",
"state" : {
"revision" : "76ae9c621422a1f38c30a07c8b7636994b669484",
"version" : "0.14.0"
}
}
],
"version" : 2
Expand Down
14 changes: 13 additions & 1 deletion Tuist/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@ import PackageDescription
// Customize the product types for specific package product
// Default is .staticFramework
// productTypes: ["Alamofire": .framework,]
productTypes: [:],
productTypes: [
"Animation": .framework,
"Animator": .framework,
"AtomicTransition": .framework,
"NavigationTransition": .framework,
"NavigationTransitions": .framework,
"RuntimeAssociation": .framework,
"RuntimeSwizzling": .framework
],
baseSettings: .settings(
configurations: [
.debug(name: .debug),
Expand All @@ -27,5 +35,9 @@ let package = Package(
url: "https://github.com/kean/Nuke.git",
exact: "12.8.0"
),
.package(
url: "https://github.com/davdroman/swiftui-navigation-transitions.git",
exact: "0.14.0"
)
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import ProjectDescription
public enum ExternalDependency: String {
case nuke = "Nuke"
case openapiGenerated = "OpenapiGenerated"
case navigationTransitions = "NavigationTransitions"

var name: String {
return self.rawValue
Expand Down

0 comments on commit 6a2651d

Please sign in to comment.