-
Notifications
You must be signed in to change notification settings - Fork 0
[#600] 맥에서 소셜 로그인이 안되는 현상을 해결한다 #603
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e8bea23
chore: 배포를 편하게 하기 위한 1.2 으로 설정
opficdev 15235b7
fix: fcmToken이 없어도 로그인을 성공하도록 수정
opficdev 99da5e8
fix: AppDelegate에서 FCM 동기화 트리거를 분리하도록 수정
opficdev 892a13b
fix: FCMTokenSyncHandler에서 토큰 backfill 흐름을 처리하도록 수정
opficdev 99bbe58
chore: FCMTokenSyncHandler 동작 테스트를 추가
opficdev 2bdb8c5
refactor: 불필요 파라미터 제거
opficdev 1bfbee3
fix: MainActor 내에서 동작하도록 보장
opficdev f5c77a6
refactor: FCMTokenSyncHandler의 중첩 Task를 정리
opficdev 8e0f25d
refactor: 불필요 nil 반환 제거
opficdev 3707300
chore: 1.2.5 원복
opficdev 0e3a8a8
chore: 마이너 버전 + 1
opficdev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
176 changes: 176 additions & 0 deletions
176
Application/DevLogApp/Tests/PushNotification/FCMTokenSyncHandlerTests.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,176 @@ | ||
| // | ||
| // FCMTokenSyncHandlerTests.swift | ||
| // DevLogAppTests | ||
| // | ||
| // Created by opfic on 6/13/26. | ||
| // | ||
|
|
||
| import Foundation | ||
| import Testing | ||
| import DevLogData | ||
| @testable import DevLogApp | ||
|
|
||
| struct FCMTokenSyncHandlerTests { | ||
| @Test("현재 FCM token 동기화 요청 시 token이 있으면 저장한다") | ||
| func 현재_FCM_token_동기화_요청_시_token이_있으면_저장한다() async throws { | ||
| let notificationCenter = NotificationCenter() | ||
| let registrationObserver = NotificationObserver( | ||
| notificationCenter: notificationCenter, | ||
| name: .didRequestRemoteNotificationRegistration | ||
| ) | ||
| let messagingService = PushMessagingServiceSpy(currentFCMToken: "current-token") | ||
| let userService = UserServiceSpy() | ||
| let handler = FCMTokenSyncHandler( | ||
| messagingService: messagingService, | ||
| userService: userService, | ||
| notificationCenter: notificationCenter | ||
| ) | ||
|
|
||
| notificationCenter.post(name: .didRequestFCMTokenSync, object: nil) | ||
|
|
||
| try await waitUntil { | ||
| await userService.updatedFCMTokens == ["current-token"] | ||
| } | ||
| #expect(registrationObserver.didReceiveNotification) | ||
| _ = handler | ||
| } | ||
|
|
||
| @Test("현재 FCM token 동기화 요청 시 token이 없으면 저장하지 않는다") | ||
| func 현재_FCM_token_동기화_요청_시_token이_없으면_저장하지_않는다() async throws { | ||
| let notificationCenter = NotificationCenter() | ||
| let messagingService = PushMessagingServiceSpy(currentFCMToken: nil) | ||
| let userService = UserServiceSpy() | ||
| let handler = FCMTokenSyncHandler( | ||
| messagingService: messagingService, | ||
| userService: userService, | ||
| notificationCenter: notificationCenter | ||
| ) | ||
|
|
||
| notificationCenter.post(name: .didRequestFCMTokenSync, object: nil) | ||
|
|
||
| try await Task.sleep(for: .milliseconds(100)) | ||
| #expect(await userService.updatedFCMTokens.isEmpty) | ||
| _ = handler | ||
| } | ||
|
|
||
| @Test("갱신된 FCM token 이벤트 수신 시 저장한다") | ||
| func 갱신된_FCM_token_이벤트_수신_시_저장한다() async throws { | ||
| let notificationCenter = NotificationCenter() | ||
| let messagingService = PushMessagingServiceSpy(currentFCMToken: nil) | ||
| let userService = UserServiceSpy() | ||
| let handler = FCMTokenSyncHandler( | ||
| messagingService: messagingService, | ||
| userService: userService, | ||
| notificationCenter: notificationCenter | ||
| ) | ||
|
|
||
| notificationCenter.post( | ||
| name: .didRefreshFCMToken, | ||
| object: nil, | ||
| userInfo: ["fcmToken": "refreshed-token"] | ||
| ) | ||
|
|
||
| try await waitUntil { | ||
| await userService.updatedFCMTokens == ["refreshed-token"] | ||
| } | ||
| _ = handler | ||
| } | ||
|
|
||
| @Test("APNs token 이벤트 수신 시 APNs token을 적용하고 현재 FCM token을 저장한다") | ||
| func APNs_token_이벤트_수신_시_APNs_token을_적용하고_현재_FCM_token을_저장한다() async throws { | ||
| let notificationCenter = NotificationCenter() | ||
| let messagingService = PushMessagingServiceSpy(currentFCMToken: "current-token") | ||
| let userService = UserServiceSpy() | ||
| let handler = FCMTokenSyncHandler( | ||
| messagingService: messagingService, | ||
| userService: userService, | ||
| notificationCenter: notificationCenter | ||
| ) | ||
| let deviceToken = Data([0x01, 0x02, 0x03]) | ||
|
|
||
| notificationCenter.post( | ||
| name: .didReceiveAPNSToken, | ||
| object: nil, | ||
| userInfo: ["deviceToken": deviceToken] | ||
| ) | ||
|
|
||
| try await waitUntil { | ||
| await userService.updatedFCMTokens == ["current-token"] | ||
| } | ||
| #expect(messagingService.apnsTokens == [deviceToken]) | ||
| _ = handler | ||
| } | ||
| } | ||
|
|
||
| private actor UserServiceSpy: UserService { | ||
| private(set) var updatedFCMTokens = [String]() | ||
|
|
||
| func upsertUser(_ response: AuthDataResponse) async throws { } | ||
| func fetchUserProfile() async throws -> UserProfileResponse { fatalError() } | ||
| func upsertStatusMessage(_ message: String) async throws { } | ||
|
|
||
| func updateFCMToken(_ fcmToken: String) async throws { | ||
| updatedFCMTokens.append(fcmToken) | ||
| } | ||
|
|
||
| func updateUserTimeZone() async throws { } | ||
| } | ||
|
|
||
| private final class PushMessagingServiceSpy: PushMessagingService { | ||
| private let currentFCMToken: String? | ||
| private(set) var apnsTokens = [Data]() | ||
|
|
||
| init(currentFCMToken: String?) { | ||
| self.currentFCMToken = currentFCMToken | ||
| } | ||
|
|
||
| func setDelegate(_ delegate: PushMessagingServiceDelegate?) { } | ||
| func setAPNSToken(_ deviceToken: Data) { | ||
| apnsTokens.append(deviceToken) | ||
| } | ||
| func isNotificationAuthorized() async -> Bool { true } | ||
|
|
||
| func fetchFCMToken() async throws -> String? { | ||
| currentFCMToken | ||
| } | ||
| } | ||
|
|
||
| private final class NotificationObserver { | ||
| private(set) var didReceiveNotification = false | ||
| private var token: NSObjectProtocol? | ||
| private let notificationCenter: NotificationCenter | ||
|
|
||
| init(notificationCenter: NotificationCenter, name: Notification.Name) { | ||
| self.notificationCenter = notificationCenter | ||
| self.token = notificationCenter.addObserver( | ||
| forName: name, | ||
| object: nil, | ||
| queue: nil | ||
| ) { [weak self] _ in | ||
| self?.didReceiveNotification = true | ||
| } | ||
| } | ||
|
|
||
| deinit { | ||
| if let token { | ||
| notificationCenter.removeObserver(token) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private func waitUntil( | ||
| timeout: Duration = .seconds(1), | ||
| pollInterval: Duration = .milliseconds(10), | ||
| condition: @escaping @Sendable () async -> Bool | ||
| ) async throws { | ||
| let deadline = ContinuousClock.now + timeout | ||
|
|
||
| while ContinuousClock.now < deadline { | ||
| if await condition() { | ||
| return | ||
| } | ||
| try await Task.sleep(for: pollInterval) | ||
| } | ||
|
|
||
| Issue.record("조건을 만족하지 못함") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.