@@ -4,15 +4,15 @@ import { vi, Mock, beforeEach, afterEach, describe, it, expect } from "vitest"
44import crypto from "crypto"
55import * as vscode from "vscode"
66
7- import { AuthService } from "../AuthService "
8- import { RefreshTimer } from "../RefreshTimer"
9- import * as Config from "../Config"
10- import * as utils from "../utils"
7+ import { WebAuthService } from "../../auth/WebAuthService "
8+ import { RefreshTimer } from "../../ RefreshTimer"
9+ import * as Config from "../../ Config"
10+ import * as utils from "../../ utils"
1111
1212// Mock external dependencies
13- vi . mock ( "../RefreshTimer" )
14- vi . mock ( "../Config" )
15- vi . mock ( "../utils" )
13+ vi . mock ( "../../ RefreshTimer" )
14+ vi . mock ( "../../ Config" )
15+ vi . mock ( "../../ utils" )
1616vi . mock ( "crypto" )
1717
1818// Mock fetch globally
@@ -34,8 +34,8 @@ vi.mock("vscode", () => ({
3434 } ,
3535} ) )
3636
37- describe ( "AuthService " , ( ) => {
38- let authService : AuthService
37+ describe ( "WebAuthService " , ( ) => {
38+ let authService : WebAuthService
3939 let mockTimer : {
4040 start : Mock
4141 stop : Mock
@@ -97,7 +97,8 @@ describe("AuthService", () => {
9797 stop : vi . fn ( ) ,
9898 reset : vi . fn ( ) ,
9999 }
100- vi . mocked ( RefreshTimer ) . mockImplementation ( ( ) => mockTimer as unknown as RefreshTimer )
100+ const MockedRefreshTimer = vi . mocked ( RefreshTimer )
101+ MockedRefreshTimer . mockImplementation ( ( ) => mockTimer as unknown as RefreshTimer )
101102
102103 // Setup config mocks - use production URL by default to maintain existing test behavior
103104 vi . mocked ( Config . getClerkBaseUrl ) . mockReturnValue ( "https://clerk.roocode.com" )
@@ -112,7 +113,7 @@ describe("AuthService", () => {
112113 // Setup log mock
113114 mockLog = vi . fn ( )
114115
115- authService = new AuthService ( mockContext as unknown as vscode . ExtensionContext , mockLog )
116+ authService = new WebAuthService ( mockContext as unknown as vscode . ExtensionContext , mockLog )
116117 } )
117118
118119 afterEach ( ( ) => {
@@ -138,9 +139,9 @@ describe("AuthService", () => {
138139 } )
139140
140141 it ( "should use console.log as default logger" , ( ) => {
141- const serviceWithoutLog = new AuthService ( mockContext as unknown as vscode . ExtensionContext )
142+ const serviceWithoutLog = new WebAuthService ( mockContext as unknown as vscode . ExtensionContext )
142143 // Can't directly test console.log usage, but constructor should not throw
143- expect ( serviceWithoutLog ) . toBeInstanceOf ( AuthService )
144+ expect ( serviceWithoutLog ) . toBeInstanceOf ( WebAuthService )
144145 } )
145146 } )
146147
@@ -434,7 +435,7 @@ describe("AuthService", () => {
434435 const credentials = { clientToken : "test-token" , sessionId : "test-session" }
435436 mockContext . secrets . get . mockResolvedValue ( JSON . stringify ( credentials ) )
436437
437- const authenticatedService = new AuthService ( mockContext as unknown as vscode . ExtensionContext , mockLog )
438+ const authenticatedService = new WebAuthService ( mockContext as unknown as vscode . ExtensionContext , mockLog )
438439 await authenticatedService . initialize ( )
439440
440441 expect ( authenticatedService . isAuthenticated ( ) ) . toBe ( true )
@@ -460,7 +461,7 @@ describe("AuthService", () => {
460461 const credentials = { clientToken : "test-token" , sessionId : "test-session" }
461462 mockContext . secrets . get . mockResolvedValue ( JSON . stringify ( credentials ) )
462463
463- const attemptingService = new AuthService ( mockContext as unknown as vscode . ExtensionContext , mockLog )
464+ const attemptingService = new WebAuthService ( mockContext as unknown as vscode . ExtensionContext , mockLog )
464465 await attemptingService . initialize ( )
465466
466467 expect ( attemptingService . hasOrIsAcquiringActiveSession ( ) ) . toBe ( true )
@@ -960,7 +961,7 @@ describe("AuthService", () => {
960961 // Mock getClerkBaseUrl to return production URL
961962 vi . mocked ( Config . getClerkBaseUrl ) . mockReturnValue ( "https://clerk.roocode.com" )
962963
963- const service = new AuthService ( mockContext as unknown as vscode . ExtensionContext , mockLog )
964+ const service = new WebAuthService ( mockContext as unknown as vscode . ExtensionContext , mockLog )
964965 const credentials = { clientToken : "test-token" , sessionId : "test-session" }
965966
966967 await service . initialize ( )
@@ -977,7 +978,7 @@ describe("AuthService", () => {
977978 // Mock getClerkBaseUrl to return custom URL
978979 vi . mocked ( Config . getClerkBaseUrl ) . mockReturnValue ( customUrl )
979980
980- const service = new AuthService ( mockContext as unknown as vscode . ExtensionContext , mockLog )
981+ const service = new WebAuthService ( mockContext as unknown as vscode . ExtensionContext , mockLog )
981982 const credentials = { clientToken : "test-token" , sessionId : "test-session" }
982983
983984 await service . initialize ( )
@@ -993,7 +994,7 @@ describe("AuthService", () => {
993994 const customUrl = "https://custom.clerk.com"
994995 vi . mocked ( Config . getClerkBaseUrl ) . mockReturnValue ( customUrl )
995996
996- const service = new AuthService ( mockContext as unknown as vscode . ExtensionContext , mockLog )
997+ const service = new WebAuthService ( mockContext as unknown as vscode . ExtensionContext , mockLog )
997998 const credentials = { clientToken : "test-token" , sessionId : "test-session" }
998999 mockContext . secrets . get . mockResolvedValue ( JSON . stringify ( credentials ) )
9991000
@@ -1008,7 +1009,7 @@ describe("AuthService", () => {
10081009 const customUrl = "https://custom.clerk.com"
10091010 vi . mocked ( Config . getClerkBaseUrl ) . mockReturnValue ( customUrl )
10101011
1011- const service = new AuthService ( mockContext as unknown as vscode . ExtensionContext , mockLog )
1012+ const service = new WebAuthService ( mockContext as unknown as vscode . ExtensionContext , mockLog )
10121013
10131014 await service . initialize ( )
10141015 await service [ "clearCredentials" ] ( )
@@ -1027,7 +1028,7 @@ describe("AuthService", () => {
10271028 return { dispose : vi . fn ( ) }
10281029 } )
10291030
1030- const service = new AuthService ( mockContext as unknown as vscode . ExtensionContext , mockLog )
1031+ const service = new WebAuthService ( mockContext as unknown as vscode . ExtensionContext , mockLog )
10311032 await service . initialize ( )
10321033
10331034 // Simulate credentials change event with scoped key
@@ -1054,7 +1055,7 @@ describe("AuthService", () => {
10541055 return { dispose : vi . fn ( ) }
10551056 } )
10561057
1057- const service = new AuthService ( mockContext as unknown as vscode . ExtensionContext , mockLog )
1058+ const service = new WebAuthService ( mockContext as unknown as vscode . ExtensionContext , mockLog )
10581059 await service . initialize ( )
10591060
10601061 const inactiveSessionSpy = vi . fn ( )
@@ -1078,7 +1079,7 @@ describe("AuthService", () => {
10781079 return { dispose : vi . fn ( ) }
10791080 } )
10801081
1081- const service = new AuthService ( mockContext as unknown as vscode . ExtensionContext , mockLog )
1082+ const service = new WebAuthService ( mockContext as unknown as vscode . ExtensionContext , mockLog )
10821083 await service . initialize ( )
10831084
10841085 const inactiveSessionSpy = vi . fn ( )
0 commit comments