-
Notifications
You must be signed in to change notification settings - Fork 180
optimize editor config, improve logging, and add utility functions with tests #847
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
optimize editor config, improve logging, and add utility functions with tests #847
Conversation
WalkthroughThis update introduces new JSON utility and testing utilities, comprehensive unit tests for key providers, and improved error handling in the ErrorBoundary component. It removes numerous debug and informational console logs across the codebase, updates editor configuration for performance, and revises ignore files. Several error logs are upgraded to warnings or errors, and default feature flag exports are refactored. Changes
Sequence Diagram(s)sequenceDiagram
participant App
participant ErrorBoundary
participant Sentry
participant Analytics
App->>ErrorBoundary: Render child component
Note right of ErrorBoundary: Child throws error
ErrorBoundary->>Analytics: flush()
ErrorBoundary->>Sentry: captureException(error, {stack, errorBoundary: true})
ErrorBoundary->>App: Render fallback UI
sequenceDiagram
participant TestSuite
participant PassportProvider
participant Keychain
participant NativeModules
TestSuite->>PassportProvider: Render with children
PassportProvider->>NativeModules: initializeNativeModules()
alt NativeModules ready
PassportProvider->>Keychain: loadDocumentCatalog()
PassportProvider-->>TestSuite: Provide context
else Error or retry needed
PassportProvider->>NativeModules: Retry initialization
PassportProvider->>Keychain: migrateFromLegacyStorage()
PassportProvider->>Keychain: loadDocumentCatalog()
PassportProvider-->>TestSuite: Provide context
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
|
fyi @aaronmgdr creating my own version of an integration branch |
b2b0b8d to
d42943d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
.cursorignore(0 hunks).vscode/settings.json(2 hunks)app/src/providers/passportDataProvider.tsx(11 hunks)app/src/screens/dev/DevSettingsScreen.tsx(1 hunks)app/src/utils/jsonUtils.ts(1 hunks)app/src/utils/testingUtils.ts(1 hunks)app/tests/src/providers/passportDataProvider.test.tsx(1 hunks)app/tests/src/utils/jsonUtils.test.ts(1 hunks)
💤 Files with no reviewable changes (1)
- .cursorignore
✅ Files skipped from review due to trivial changes (1)
- app/src/screens/dev/DevSettingsScreen.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- .vscode/settings.json
🧰 Additional context used
📓 Path-based instructions (2)
app/src/**/*.{ts,tsx,js,jsx}
⚙️ CodeRabbit Configuration File
app/src/**/*.{ts,tsx,js,jsx}: Review React Native TypeScript code for:
- Component architecture and reusability
- State management patterns
- Performance optimizations
- TypeScript type safety
- React hooks usage and dependencies
- Navigation patterns
Files:
app/src/utils/testingUtils.tsapp/src/utils/jsonUtils.tsapp/src/providers/passportDataProvider.tsx
**/*.{test,spec}.{ts,js,tsx,jsx}
⚙️ CodeRabbit Configuration File
**/*.{test,spec}.{ts,js,tsx,jsx}: Review test files for:
- Test coverage completeness
- Test case quality and edge cases
- Mock usage appropriateness
- Test readability and maintainability
Files:
app/tests/src/utils/jsonUtils.test.tsapp/tests/src/providers/passportDataProvider.test.tsx
🧠 Learnings (1)
📚 Learning: the import path '@selfxyz/common/utils/scope' is valid when the common package has a "./utils/*" exp...
Learnt from: transphorm
PR: selfxyz/self#795
File: app/src/screens/prove/ProveScreen.tsx:5-5
Timestamp: 2025-07-28T19:18:48.270Z
Learning: The import path 'selfxyz/common/utils/scope' is valid when the common package has a "./utils/*" export mapping in package.json, even if ESLint shows resolution errors before the package is built. The package.json exports field properly maps "./utils/*" to the compiled files in dist/.
Applied to files:
app/tests/src/utils/jsonUtils.test.tsapp/src/providers/passportDataProvider.tsx
⏰ Context from checks skipped due to timeout of 300000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: analyze-android
- GitHub Check: analyze-ios
- GitHub Check: e2e-ios
- GitHub Check: build
🔇 Additional comments (3)
app/tests/src/providers/passportDataProvider.test.tsx (1)
46-47: Good practice: Mocking console methods in testsExcellent approach to mock console methods in tests. This ensures tests don't pollute the console output and allows verification of logging behavior.
app/src/providers/passportDataProvider.tsx (2)
59-69: Good implementation of conditional test utility importThe conditional import of testing utilities only in development mode is a good practice to prevent test code from being included in production builds.
145-147: Good implementation of initialization mutexThe mutex pattern using
initializationInProgressandinitializationPromiseeffectively prevents race conditions during concurrent initialization calls. This is a robust solution for handling async initialization.
* Remove noisy console logs * Restore web stub warnings * clean up linting issues * fix tests * add instantiation test
* Log React errors to Sentry * cr feedback and improve tests
app/src/RemoteConfig.shared.ts
Outdated
| export const LOCAL_OVERRIDES_KEY = 'feature_flag_overrides'; | ||
|
|
||
| // Default feature flags - this should be defined by the consuming application | ||
| const defaultFlags: Record<string, any> = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think flags can only be number string or boolean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
| // Import testing utilities conditionally | ||
| let clearDocumentCatalogForMigrationTestingFromUtils: | ||
| | (() => Promise<void>) | ||
| | undefined; | ||
| if (__DEV__) { | ||
| try { | ||
| const testingUtils = require('../utils/testingUtils'); | ||
| clearDocumentCatalogForMigrationTestingFromUtils = | ||
| testingUtils.clearDocumentCatalogForMigrationTesting; | ||
| } catch (error) { | ||
| console.warn('Testing utilities not available:', error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm why are we even conditionally importing testing utils in main files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverted all this logic and added tests for the current logic in dev.
going to test before merging
| export async function storePassportData(passportData: PassportData) { | ||
| await storeDocumentWithDeduplication(passportData); | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the changes in this pr seem to big for a pr labeled removed logs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah after reviewing i'm gonna revert this work and go with what is in dev
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverted. going to dismiss the review to merge and saving the types work for another pr
aaronmgdr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the passport data page is just so many changes i dont see why. and the pattern of having test code in main components seems fishy.
|
@coderabbitai summary |
✅ Actions performedSummary regeneration triggered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Nitpick comments (2)
app/tests/src/providers/passportDataProvider.test.tsx (2)
6-21: Clarify or relocate the "Import after mocking" commentThe comment on line 6 is misleading as the actual mocking occurs on lines 21 and 28-30, not before lines 7-10. While Jest hoists
jest.mock()calls, this comment placement could confuse future maintainers.Consider moving the comment or removing it entirely since Jest's hoisting behavior handles the execution order automatically:
-// Import after mocking import { PassportProvider, usePassport, } from '../../../src/providers/passportDataProvider'; import { render } from '@testing-library/react-native'; -// Mock react-native-keychain before importing the module +// Mock dependencies const mockKeychain = {
65-140: Well-structured initialization tests with comprehensive coverageExcellent test coverage for
initializeNativeModulesincluding edge cases, retry logic, and concurrent initialization scenarios. The use ofjest.resetModules()ensures proper test isolation.Consider making test descriptions more specific about the behavior:
- Line 78: "should return true immediately if native modules are already ready" → "should cache successful initialization and skip redundant checks"
- Line 115: "should return false after max retries if modules never become ready" → "should respect maxRetries parameter and fail gracefully"
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
app/src/RemoteConfig.shared.ts(3 hunks)app/src/screens/dev/MockDataScreen.tsx(0 hunks)app/tests/src/providers/passportDataProvider.test.tsx(1 hunks)
💤 Files with no reviewable changes (1)
- app/src/screens/dev/MockDataScreen.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- app/src/RemoteConfig.shared.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{test,spec}.{ts,js,tsx,jsx}
⚙️ CodeRabbit Configuration File
**/*.{test,spec}.{ts,js,tsx,jsx}: Review test files for:
- Test coverage completeness
- Test case quality and edge cases
- Mock usage appropriateness
- Test readability and maintainability
Files:
app/tests/src/providers/passportDataProvider.test.tsx
⏰ Context from checks skipped due to timeout of 300000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: e2e-ios
- GitHub Check: analyze-android
- GitHub Check: analyze-ios
- GitHub Check: build
🔇 Additional comments (1)
app/tests/src/providers/passportDataProvider.test.tsx (1)
227-229: Service name matches implementation — no change neededThe test’s hardcoded
'passportData:'aligns exactly with the implementation’slegacyServicesentry ('passportData') and the template literal`Could not migrate from service ${service}:`so the expected string is correct. No updates required.
|
@coderabbitai title |
|
Tip For best results, initiate chat on the files or code changes. @transphorm The current title "INT: vscode fixes; remove console.logs" is accurate but could better reflect the broader scope of improvements. Based on the changes, I'd suggest: "feat: enhance dev experience with editor optimizations, logging cleanup, and new utilities" Or alternatively: "dev: optimize editor config, improve logging, and add utility functions with tests" The current title undersells the scope - you've made substantial improvements including:
The changes represent a significant developer experience enhancement rather than just "fixes." |
|
@aaronmgdr thanks for approving. updated the passport provider tests based on coderabbit's feedback. tested the app locally and everything works. going to merge after the pipelines pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
app/src/providers/passportDataProvider.tsx(1 hunks)app/tests/src/providers/passportDataProvider.test.tsx(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{test,spec}.{ts,js,tsx,jsx}
⚙️ CodeRabbit Configuration File
**/*.{test,spec}.{ts,js,tsx,jsx}: Review test files for:
- Test coverage completeness
- Test case quality and edge cases
- Mock usage appropriateness
- Test readability and maintainability
Files:
app/tests/src/providers/passportDataProvider.test.tsx
app/src/**/*.{ts,tsx,js,jsx}
⚙️ CodeRabbit Configuration File
app/src/**/*.{ts,tsx,js,jsx}: Review React Native TypeScript code for:
- Component architecture and reusability
- State management patterns
- Performance optimizations
- TypeScript type safety
- React hooks usage and dependencies
- Navigation patterns
Files:
app/src/providers/passportDataProvider.tsx
🧠 Learnings (1)
📚 Learning: 2025-07-28T19:18:48.270Z
Learnt from: transphorm
PR: selfxyz/self#795
File: app/src/screens/prove/ProveScreen.tsx:5-5
Timestamp: 2025-07-28T19:18:48.270Z
Learning: The import path 'selfxyz/common/utils/scope' is valid when the common package has a "./utils/*" export mapping in package.json, even if ESLint shows resolution errors before the package is built. The package.json exports field properly maps "./utils/*" to the compiled files in dist/.
Applied to files:
app/src/providers/passportDataProvider.tsx
⏰ Context from checks skipped due to timeout of 300000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: analyze-ios
- GitHub Check: analyze-android
- GitHub Check: e2e-ios
- GitHub Check: build
🔇 Additional comments (5)
app/src/providers/passportDataProvider.tsx (1)
499-504: Good defensive check for null catalog valuesThe added null check after parsing prevents edge cases where
JSON.parse("null")would returnnullinstead of a valid catalog object. This defensive programming ensures type safety and prevents downstream issues.app/tests/src/providers/passportDataProvider.test.tsx (4)
33-60: Well-implemented test component that verifies actual context valuesThe TestComponent properly extracts and verifies the actual context functions rather than just rendering static text. This effectively addresses the previous review feedback and ensures the tests validate real context functionality.
128-256: Comprehensive PassportProvider test coverageExcellent test suite that covers all the scenarios suggested in the previous review:
- Multiple consumers accessing the same context
- Context updates triggering re-renders
- Error boundary handling
- Provider without children
- Context stability across re-renders
This thoroughly validates the provider's behavior.
257-332: Thorough testing of native module initializationThe test suite effectively covers all initialization scenarios including retry logic, error handling, and module caching. Good use of
jest.resetModules()to ensure test isolation.
565-598: Excellent test coverage for the null password edge caseThis test validates the defensive check added in
loadDocumentCatalogwhereJSON.parse(null)is handled properly. It confirms that a TypeError is thrown, caught, and the function safely returns an empty catalog.
| console.log('About to call loadDocumentCatalogLocal'); | ||
| const result = await loadDocumentCatalogLocal(); | ||
| console.log('Called loadDocumentCatalogLocal'); | ||
|
|
||
| console.log('Actual result:', result); | ||
| console.log('Result type:', typeof result); | ||
| console.log('Is null?', result === null); | ||
| console.log('Function name:', loadDocumentCatalogLocal.name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove debug console.log statements
These debug statements should be removed from the test code as they add noise to test output.
- console.log('About to call loadDocumentCatalogLocal');
const result = await loadDocumentCatalogLocal();
- console.log('Called loadDocumentCatalogLocal');
-
- console.log('Actual result:', result);
- console.log('Result type:', typeof result);
- console.log('Is null?', result === null);
- console.log('Function name:', loadDocumentCatalogLocal.name);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| console.log('About to call loadDocumentCatalogLocal'); | |
| const result = await loadDocumentCatalogLocal(); | |
| console.log('Called loadDocumentCatalogLocal'); | |
| console.log('Actual result:', result); | |
| console.log('Result type:', typeof result); | |
| console.log('Is null?', result === null); | |
| console.log('Function name:', loadDocumentCatalogLocal.name); | |
| const result = await loadDocumentCatalogLocal(); |
🤖 Prompt for AI Agents
In app/tests/src/providers/passportDataProvider.test.tsx around lines 580 to
587, remove all console.log debug statements as they clutter the test output and
are not needed for the final test code.
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Chores
Refactor