-
Notifications
You must be signed in to change notification settings - Fork 4
RU-T46 Fixing issue with call creation map, perf fix for action. Live… #198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| // Mock for @livekit/react-native-webrtc | ||
| export const RTCAudioSession = { | ||
| configure: jest.fn().mockResolvedValue(undefined), | ||
| setCategory: jest.fn().mockResolvedValue(undefined), | ||
| setMode: jest.fn().mockResolvedValue(undefined), | ||
| getActiveAudioSession: jest.fn().mockReturnValue(null), | ||
| setActive: jest.fn().mockResolvedValue(undefined), | ||
| }; | ||
|
|
||
| export default { | ||
| RTCAudioSession, | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| /// <reference types="expo/types" /> | ||
|
|
||
| // NOTE: This file should not be edited and should be in your git ignore | ||
| // NOTE: This file should not be edited and should be in your git ignore |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,14 +37,29 @@ const defaultMockFiles = [ | |
| }, | ||
| ]; | ||
|
|
||
| let mockStoreState: any = { | ||
| callFiles: defaultMockFiles, | ||
| // Create a single object that will be mutated - never reassign! | ||
| const mockStoreState = { | ||
| callFiles: defaultMockFiles as any, | ||
| isLoadingFiles: false, | ||
| errorFiles: null, | ||
| errorFiles: null as string | null, | ||
| fetchCallFiles: mockFetchCallFiles, | ||
| clearFiles: mockClearFiles, | ||
| }; | ||
|
|
||
| // Helper function to update mock state without replacing the object | ||
| const setMockStoreState = (updates: Partial<typeof mockStoreState>) => { | ||
| Object.assign(mockStoreState, updates); | ||
| }; | ||
|
|
||
| // Reset mock state to defaults | ||
| const resetMockStoreState = () => { | ||
| mockStoreState.callFiles = defaultMockFiles; | ||
| mockStoreState.isLoadingFiles = false; | ||
| mockStoreState.errorFiles = null; | ||
| mockStoreState.fetchCallFiles = mockFetchCallFiles; | ||
| mockStoreState.clearFiles = mockClearFiles; | ||
| }; | ||
|
|
||
|
Comment on lines
+40
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, let's check if the file exists and read the relevant lines
head -80 src/components/calls/__tests__/call-files-modal.test.tsx | tail -50Repository: Resgrid/Unit Length of output: 1409 🏁 Script executed: # Search for existing CallFile or related types in non-test files
rg -n "type CallFile|interface CallFile|type.*CallFile|export.*CallFile" -g '!**/__tests__/**'Repository: Resgrid/Unit Length of output: 1866 🏁 Script executed: # Also check for any models or types related to call files
rg -n "class CallFile|type Call.*File|interface Call.*File" --type ts --type tsx -g '!**/__tests__/**' | head -20Repository: Resgrid/Unit Length of output: 83 🏁 Script executed: # Let's check the CallFileResultData structure to confirm it matches the mock
head -50 src/models/v4/callFiles/callFileResultData.tsRepository: Resgrid/Unit Length of output: 407 🏁 Script executed: # Check if callFiles array is mutated anywhere in the component
rg -A 5 -B 5 "callFiles\." src/components/calls/call-files-modal.tsx | head -40Repository: Resgrid/Unit Length of output: 1031 Replace Line 42 uses Cloning 🔧 Suggested fixconst mockStoreState = {
- callFiles: defaultMockFiles as any,
+ callFiles: defaultMockFiles as CallFileResultData[],
isLoadingFiles: false,
errorFiles: null as string | null,
fetchCallFiles: mockFetchCallFiles,
clearFiles: mockClearFiles,
};🤖 Prompt for AI Agents |
||
| jest.mock('@/stores/calls/detail-store', () => ({ | ||
| useCallDetailStore: () => mockStoreState, | ||
| })); | ||
|
|
@@ -301,13 +316,7 @@ describe('CallFilesModal', () => { | |
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| // Reset to default state | ||
| mockStoreState = { | ||
| callFiles: defaultMockFiles, | ||
| isLoadingFiles: false, | ||
| errorFiles: null, | ||
| fetchCallFiles: mockFetchCallFiles, | ||
| clearFiles: mockClearFiles, | ||
| }; | ||
| resetMockStoreState(); | ||
| }); | ||
|
|
||
| it('renders correctly when closed', () => { | ||
|
|
@@ -421,13 +430,11 @@ describe('CallFilesModal', () => { | |
| describe('Loading States', () => { | ||
| beforeEach(() => { | ||
| // Mock loading state | ||
| mockStoreState = { | ||
| setMockStoreState({ | ||
| callFiles: null, | ||
| isLoadingFiles: true, | ||
| errorFiles: null, | ||
| fetchCallFiles: mockFetchCallFiles, | ||
| clearFiles: mockClearFiles, | ||
| }; | ||
| }); | ||
| }); | ||
|
|
||
| it('displays loading spinner when fetching files', () => { | ||
|
|
@@ -443,13 +450,11 @@ describe('CallFilesModal', () => { | |
| describe('Error States', () => { | ||
| beforeEach(() => { | ||
| // Mock error state | ||
| mockStoreState = { | ||
| setMockStoreState({ | ||
| callFiles: [], | ||
| isLoadingFiles: false, | ||
| errorFiles: 'Network error occurred', | ||
| fetchCallFiles: mockFetchCallFiles, | ||
| clearFiles: mockClearFiles, | ||
| }; | ||
| }); | ||
| }); | ||
|
|
||
| it('displays error message when file fetch fails', () => { | ||
|
|
@@ -476,13 +481,11 @@ describe('CallFilesModal', () => { | |
| describe('Empty States', () => { | ||
| beforeEach(() => { | ||
| // Mock empty state | ||
| mockStoreState = { | ||
| setMockStoreState({ | ||
| callFiles: [], | ||
| isLoadingFiles: false, | ||
| errorFiles: null, | ||
| fetchCallFiles: mockFetchCallFiles, | ||
| clearFiles: mockClearFiles, | ||
| }; | ||
| }); | ||
| }); | ||
|
|
||
| it('displays empty state when no files available', () => { | ||
|
|
@@ -503,12 +506,11 @@ describe('CallFilesModal', () => { | |
|
|
||
| beforeEach(() => { | ||
| // Reset to default state with files | ||
| mockStoreState = { | ||
| setMockStoreState({ | ||
| callFiles: defaultMockFiles, | ||
| isLoadingFiles: false, | ||
| errorFiles: null, | ||
| fetchCallFiles: mockFetchCallFiles, | ||
| }; | ||
| }); | ||
| }); | ||
|
|
||
| it('downloads and shares file when clicked', async () => { | ||
|
|
@@ -591,13 +593,7 @@ describe('CallFilesModal', () => { | |
| describe('File Format Utilities', () => { | ||
| beforeEach(() => { | ||
| // Reset to default state | ||
| mockStoreState = { | ||
| callFiles: defaultMockFiles, | ||
| isLoadingFiles: false, | ||
| errorFiles: null, | ||
| fetchCallFiles: mockFetchCallFiles, | ||
| clearFiles: mockClearFiles, | ||
| }; | ||
| resetMockStoreState(); | ||
| }); | ||
|
|
||
| it('formats file sizes correctly', () => { | ||
|
|
@@ -625,13 +621,7 @@ describe('CallFilesModal', () => { | |
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| // Reset to default state | ||
| mockStoreState = { | ||
| callFiles: defaultMockFiles, | ||
| isLoadingFiles: false, | ||
| errorFiles: null, | ||
| fetchCallFiles: mockFetchCallFiles, | ||
| clearFiles: mockClearFiles, | ||
| }; | ||
| resetMockStoreState(); | ||
| }); | ||
|
|
||
| it('should track analytics event when modal is opened', () => { | ||
|
|
@@ -653,10 +643,9 @@ describe('CallFilesModal', () => { | |
| }); | ||
|
|
||
| it('should track analytics event with loading state', () => { | ||
| mockStoreState = { | ||
| ...mockStoreState, | ||
| setMockStoreState({ | ||
| isLoadingFiles: true, | ||
| }; | ||
| }); | ||
|
|
||
| render(<CallFilesModal {...defaultProps} isOpen={true} callId="test-call-456" />); | ||
|
|
||
|
|
@@ -670,10 +659,9 @@ describe('CallFilesModal', () => { | |
| }); | ||
|
|
||
| it('should track analytics event with error state', () => { | ||
| mockStoreState = { | ||
| ...mockStoreState, | ||
| setMockStoreState({ | ||
| errorFiles: 'Failed to load files', | ||
| }; | ||
| }); | ||
|
|
||
| render(<CallFilesModal {...defaultProps} isOpen={true} callId="test-call-error" />); | ||
|
|
||
|
|
@@ -687,10 +675,9 @@ describe('CallFilesModal', () => { | |
| }); | ||
|
|
||
| it('should track analytics event with no files', () => { | ||
| mockStoreState = { | ||
| ...mockStoreState, | ||
| setMockStoreState({ | ||
| callFiles: [], | ||
| }; | ||
| }); | ||
|
|
||
| render(<CallFilesModal {...defaultProps} isOpen={true} callId="test-call-no-files" />); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.