| 619 | }; |
| 620 | |
| 621 | export const renderWithProviders = async ( |
| 622 | component: React.ReactElement, |
| 623 | { |
| 624 | shellFocus = true, |
| 625 | settings = mockSettings, |
| 626 | uiState: providedUiState, |
| 627 | quotaState: providedQuotaState, |
| 628 | inputState: providedInputState, |
| 629 | width, |
| 630 | mouseEventsEnabled = false, |
| 631 | config, |
| 632 | uiActions, |
| 633 | toolActions, |
| 634 | persistentState, |
| 635 | appState = mockAppState, |
| 636 | }: { |
| 637 | shellFocus?: boolean; |
| 638 | settings?: LoadedSettings; |
| 639 | uiState?: Partial<UIState>; |
| 640 | quotaState?: Partial<QuotaState>; |
| 641 | inputState?: Partial<InputState>; |
| 642 | width?: number; |
| 643 | mouseEventsEnabled?: boolean; |
| 644 | config?: Config; |
| 645 | uiActions?: Partial<UIActions>; |
| 646 | toolActions?: Partial<{ |
| 647 | isExpanded: (callId: string) => boolean; |
| 648 | toggleExpansion: (callId: string) => void; |
| 649 | toggleAllExpansion: (callIds: string[]) => void; |
| 650 | }>; |
| 651 | persistentState?: { |
| 652 | get?: typeof persistentStateMock.get; |
| 653 | set?: typeof persistentStateMock.set; |
| 654 | }; |
| 655 | appState?: AppState; |
| 656 | } = {}, |
| 657 | ): Promise<RenderWithProvidersInstance> => { |
| 658 | const baseState: UIState = new Proxy( |
| 659 | { ...baseMockUiState, ...providedUiState }, |
| 660 | { |
| 661 | get(target, prop) { |
| 662 | if (prop in target) { |
| 663 | return target[prop as keyof typeof target]; |
| 664 | } |
| 665 | // For properties not in the base mock or provided state, |
| 666 | // we'll check the original proxy to see if it's a defined but |
| 667 | // unprovided property, and if not, throw. |
| 668 | if (prop in baseMockUiState) { |
| 669 | return baseMockUiState[prop as keyof typeof baseMockUiState]; |
| 670 | } |
| 671 | throw new Error(`mockUiState does not have property ${String(prop)}`); |
| 672 | }, |
| 673 | }, |
| 674 | ) as UIState; |
| 675 | |
| 676 | const quotaState: QuotaState = { |
| 677 | userTier: undefined, |
| 678 | stats: undefined, |