@@ -54,30 +54,47 @@ struct KasetApp: App {
5454 let auth = AuthService ( )
5555 let webkit = WebKitManager . shared
5656 let player = PlayerService ( )
57- let client = YTMusicClient ( authService: auth, webKitManager: webkit)
57+
58+ // Use mock client in UI test mode, real client otherwise
59+ let realClient = YTMusicClient ( authService: auth, webKitManager: webkit)
60+ let client : YTMusicClientProtocol = if UITestConfig . isUITestMode {
61+ MockUITestYTMusicClient ( )
62+ } else {
63+ realClient
64+ }
5865
5966 // Wire up dependencies
6067 player. setYTMusicClient ( client)
6168
6269 _authService = State ( initialValue: auth)
6370 _webKitManager = State ( initialValue: webkit)
6471 _playerService = State ( initialValue: player)
65- _ytMusicClient = State ( initialValue: client )
72+ _ytMusicClient = State ( initialValue: UITestConfig . isUITestMode ? nil : realClient )
6673 _notificationService = State ( initialValue: NotificationService ( playerService: player) )
74+
75+ if UITestConfig . isUITestMode {
76+ DiagnosticsLogger . ui. info ( " App launched in UI Test mode " )
77+ }
6778 }
6879
6980 var body : some Scene {
7081 WindowGroup {
71- MainWindow ( navigationSelection: $navigationSelection)
72- . environment ( authService)
73- . environment ( webKitManager)
74- . environment ( playerService)
75- . environment ( \. searchFocusTrigger, $searchFocusTrigger)
76- . environment ( \. navigationSelection, $navigationSelection)
77- . task {
78- // Check if user is already logged in from previous session
79- await authService. checkLoginStatus ( )
80- }
82+ // Skip UI during unit tests to prevent window spam
83+ if UITestConfig . isRunningUnitTests && !UITestConfig. isUITestMode {
84+ Color . clear
85+ . frame ( width: 1 , height: 1 )
86+ } else {
87+ MainWindow ( navigationSelection: $navigationSelection)
88+ . environment ( authService)
89+ . environment ( webKitManager)
90+ . environment ( playerService)
91+ . environment ( \. searchFocusTrigger, $searchFocusTrigger)
92+ . environment ( \. navigationSelection, $navigationSelection)
93+ . task {
94+ // Check if user is already logged in from previous session
95+ await authService. checkLoginStatus ( )
96+ }
97+ }
8198 }
8299 . commands {
83100 // App commands
0 commit comments