Skip to content

Commit bbf9c13

Browse files
committed
test: Update RooHandler tests to reflect non-throwing constructor
The RooHandler constructor no longer throws exceptions when authentication is unavailable. Updated tests to expect the constructor to succeed gracefully in all cases, delegating authentication error handling to the server level.
1 parent 14c94fe commit bbf9c13

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

src/api/providers/__tests__/roo.spec.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,21 +131,25 @@ describe("RooHandler", () => {
131131
expect(handler.getModel().id).toBe(mockOptions.apiModelId)
132132
})
133133

134-
it("should throw error if CloudService is not available", () => {
134+
it("should not throw error if CloudService is not available", () => {
135135
mockHasInstanceFn.mockReturnValue(false)
136136
expect(() => {
137137
new RooHandler(mockOptions)
138-
}).toThrow("Authentication required for Roo Code Cloud")
139-
expect(t).toHaveBeenCalledWith("common:errors.roo.authenticationRequired")
138+
}).not.toThrow()
139+
// Constructor should succeed even without CloudService
140+
const handler = new RooHandler(mockOptions)
141+
expect(handler).toBeInstanceOf(RooHandler)
140142
})
141143

142-
it("should throw error if session token is not available", () => {
144+
it("should not throw error if session token is not available", () => {
143145
mockHasInstanceFn.mockReturnValue(true)
144146
mockGetSessionTokenFn.mockReturnValue(null)
145147
expect(() => {
146148
new RooHandler(mockOptions)
147-
}).toThrow("Authentication required for Roo Code Cloud")
148-
expect(t).toHaveBeenCalledWith("common:errors.roo.authenticationRequired")
149+
}).not.toThrow()
150+
// Constructor should succeed even without session token
151+
const handler = new RooHandler(mockOptions)
152+
expect(handler).toBeInstanceOf(RooHandler)
149153
})
150154

151155
it("should initialize with default model if no model specified", () => {
@@ -400,7 +404,7 @@ describe("RooHandler", () => {
400404
expect(mockGetSessionTokenFn).toHaveBeenCalled()
401405
})
402406

403-
it("should handle undefined auth service", () => {
407+
it("should handle undefined auth service gracefully", () => {
404408
mockHasInstanceFn.mockReturnValue(true)
405409
// Mock CloudService with undefined authService
406410
const originalGetter = Object.getOwnPropertyDescriptor(CloudService, "instance")?.get
@@ -413,7 +417,10 @@ describe("RooHandler", () => {
413417

414418
expect(() => {
415419
new RooHandler(mockOptions)
416-
}).toThrow("Authentication required for Roo Code Cloud")
420+
}).not.toThrow()
421+
// Constructor should succeed even with undefined auth service
422+
const handler = new RooHandler(mockOptions)
423+
expect(handler).toBeInstanceOf(RooHandler)
417424
} finally {
418425
// Always restore original getter, even if test fails
419426
if (originalGetter) {
@@ -425,12 +432,15 @@ describe("RooHandler", () => {
425432
}
426433
})
427434

428-
it("should handle empty session token", () => {
435+
it("should handle empty session token gracefully", () => {
429436
mockGetSessionTokenFn.mockReturnValue("")
430437

431438
expect(() => {
432439
new RooHandler(mockOptions)
433-
}).toThrow("Authentication required for Roo Code Cloud")
440+
}).not.toThrow()
441+
// Constructor should succeed even with empty session token
442+
const handler = new RooHandler(mockOptions)
443+
expect(handler).toBeInstanceOf(RooHandler)
434444
})
435445
})
436446
})

0 commit comments

Comments
 (0)