@@ -11,6 +11,20 @@ vi.mock("@src/utils/vscode", () => ({
1111 } ,
1212} ) )
1313
14+ // Mock the ErrorBoundary component
15+ vi . mock ( "@src/components/ErrorBoundary" , ( ) => ( {
16+ __esModule : true ,
17+ default : ( { children } : { children : React . ReactNode } ) => < > { children } </ > ,
18+ } ) )
19+
20+ // Mock the telemetry client
21+ vi . mock ( "@src/utils/TelemetryClient" , ( ) => ( {
22+ telemetryClient : {
23+ capture : vi . fn ( ) ,
24+ updateTelemetryState : vi . fn ( ) ,
25+ } ,
26+ } ) )
27+
1428vi . mock ( "@src/components/chat/ChatView" , ( ) => ( {
1529 __esModule : true ,
1630 default : function ChatView ( { isHidden } : { isHidden : boolean } ) {
@@ -88,11 +102,81 @@ vi.mock("@src/components/account/AccountView", () => ({
88102
89103const mockUseExtensionState = vi . fn ( )
90104
105+ // Mock the HumanRelayDialog component
106+ vi . mock ( "@src/components/human-relay/HumanRelayDialog" , ( ) => ( {
107+ HumanRelayDialog : ( { _children, isOpen, onClose } : any ) => (
108+ < div data-testid = "human-relay-dialog" data-open = { isOpen } onClick = { onClose } >
109+ Human Relay Dialog
110+ </ div >
111+ ) ,
112+ } ) )
113+
114+ // Mock i18next and react-i18next
115+ vi . mock ( "i18next" , ( ) => {
116+ const tFunction = ( key : string ) => key
117+ const i18n = {
118+ t : tFunction ,
119+ use : ( ) => i18n ,
120+ init : ( ) => Promise . resolve ( tFunction ) ,
121+ changeLanguage : vi . fn ( ( ) => Promise . resolve ( ) ) ,
122+ }
123+ return { default : i18n }
124+ } )
125+
126+ vi . mock ( "react-i18next" , ( ) => {
127+ const tFunction = ( key : string ) => key
128+ return {
129+ withTranslation : ( ) => ( Component : any ) => {
130+ const MockedComponent = ( props : any ) => {
131+ return < Component t = { tFunction } i18n = { { t : tFunction } } tReady { ...props } />
132+ }
133+ MockedComponent . displayName = `withTranslation(${ Component . displayName || Component . name || "Component" } )`
134+ return MockedComponent
135+ } ,
136+ Trans : ( { children } : { children : React . ReactNode } ) => < > { children } </ > ,
137+ useTranslation : ( ) => {
138+ return {
139+ t : tFunction ,
140+ i18n : {
141+ t : tFunction ,
142+ changeLanguage : vi . fn ( ( ) => Promise . resolve ( ) ) ,
143+ } ,
144+ }
145+ } ,
146+ initReactI18next : {
147+ type : "3rdParty" ,
148+ init : vi . fn ( ) ,
149+ } ,
150+ }
151+ } )
152+
153+ // Mock TranslationProvider to pass through children
154+ vi . mock ( "@src/i18n/TranslationContext" , ( ) => {
155+ const tFunction = ( key : string ) => key
156+ return {
157+ __esModule : true ,
158+ default : ( { children } : { children : React . ReactNode } ) => < > { children } </ > ,
159+ useAppTranslation : ( ) => ( {
160+ t : tFunction ,
161+ i18n : {
162+ t : tFunction ,
163+ changeLanguage : vi . fn ( ( ) => Promise . resolve ( ) ) ,
164+ } ,
165+ } ) ,
166+ }
167+ } )
168+
91169vi . mock ( "@src/context/ExtensionStateContext" , ( ) => ( {
92170 useExtensionState : ( ) => mockUseExtensionState ( ) ,
93171 ExtensionStateContextProvider : ( { children } : { children : React . ReactNode } ) => < > { children } </ > ,
94172} ) )
95173
174+ // Mock environment variables
175+ vi . mock ( "process.env" , ( ) => ( {
176+ NODE_ENV : "test" ,
177+ PKG_VERSION : "1.0.0-test" ,
178+ } ) )
179+
96180describe ( "App" , ( ) => {
97181 beforeEach ( ( ) => {
98182 vi . clearAllMocks ( )
0 commit comments