@@ -5,7 +5,8 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query"
55
66import { type ModelInfo , type ProviderSettings , openAiModelInfoSaneDefaults } from "@roo-code/types"
77
8- import { ExtensionStateContextProvider } from "@src/context/ExtensionStateContext"
8+ import * as ExtensionStateContext from "@src/context/ExtensionStateContext"
9+ const { ExtensionStateContextProvider } = ExtensionStateContext
910
1011import ApiOptions , { ApiOptionsProps } from "../ApiOptions"
1112
@@ -238,6 +239,18 @@ vi.mock("../providers/LiteLLM", () => ({
238239 ) ,
239240} ) )
240241
242+ // Mock Roo provider for tests
243+ vi . mock ( "../providers/Roo" , ( ) => ( {
244+ Roo : ( { cloudIsAuthenticated } : any ) => (
245+ < div data-testid = "roo-provider" > { cloudIsAuthenticated ? "Authenticated" : "Not Authenticated" } </ div >
246+ ) ,
247+ } ) )
248+
249+ // Mock RooBalanceDisplay for tests
250+ vi . mock ( "../providers/RooBalanceDisplay" , ( ) => ( {
251+ RooBalanceDisplay : ( ) => < div data-testid = "roo-balance-display" > Balance: $10.00</ div > ,
252+ } ) )
253+
241254vi . mock ( "@src/components/ui/hooks/useSelectedModel" , ( ) => ( {
242255 useSelectedModel : vi . fn ( ( apiConfiguration : ProviderSettings ) => {
243256 if ( apiConfiguration . apiModelId ?. includes ( "thinking" ) ) {
@@ -563,4 +576,40 @@ describe("ApiOptions", () => {
563576 expect ( screen . queryByTestId ( "litellm-provider" ) ) . not . toBeInTheDocument ( )
564577 } )
565578 } )
579+
580+ describe ( "Roo provider tests" , ( ) => {
581+ it ( "shows balance display when authenticated" , ( ) => {
582+ // Mock useExtensionState to return authenticated state
583+ const useExtensionStateMock = vi . spyOn ( ExtensionStateContext , "useExtensionState" )
584+ useExtensionStateMock . mockReturnValue ( {
585+ cloudIsAuthenticated : true ,
586+ organizationAllowList : { providers : { } } ,
587+ } as any )
588+
589+ renderApiOptions ( {
590+ apiConfiguration : {
591+ apiProvider : "roo" ,
592+ } ,
593+ } )
594+
595+ expect ( screen . getByTestId ( "roo-balance-display" ) ) . toBeInTheDocument ( )
596+ } )
597+
598+ it ( "does not show balance display when not authenticated" , ( ) => {
599+ // Mock useExtensionState to return unauthenticated state
600+ const useExtensionStateMock = vi . spyOn ( ExtensionStateContext , "useExtensionState" )
601+ useExtensionStateMock . mockReturnValue ( {
602+ cloudIsAuthenticated : false ,
603+ organizationAllowList : { providers : { } } ,
604+ } as any )
605+
606+ renderApiOptions ( {
607+ apiConfiguration : {
608+ apiProvider : "roo" ,
609+ } ,
610+ } )
611+
612+ expect ( screen . queryByTestId ( "roo-balance-display" ) ) . not . toBeInTheDocument ( )
613+ } )
614+ } )
566615} )
0 commit comments