-
Notifications
You must be signed in to change notification settings - Fork 0
test: intacct import settings save functionality #1009
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
test: intacct import settings save functionality #1009
Conversation
WalkthroughThe pull request introduces extensive modifications to the test suite for the Changes
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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: 3
🧹 Outside diff range and nitpick comments (5)
src/app/integrations/intacct/intacct-shared/intacct-import-settings/intacct-import-settings.component.spec.ts (3)
100-104: Enhance error handling tests in component initializationIn the 'Component Initialization' block, consider adding tests to simulate service call failures. This will ensure that the component gracefully handles errors from services like
siImportSettingService,siMappingsService, and others during initialization.
68-89: Implement cleanup withafterEachTo maintain test isolation, consider adding an
afterEachblock to reset or restore spy objects and any modified states. This prevents unintended interactions between tests due to shared state.
206-290: Expand edge case coverage in save functionality testsThe current tests handle successful saves and generic errors. Consider adding tests for scenarios like network timeouts, unauthorized access, or validation failures during the save operation to ensure comprehensive coverage.
src/app/integrations/intacct/intacct.fixture.ts (2)
854-858: Inconsistent property name incostCodeFieldValueThe property
source_placeholderincostCodeFieldValuemay be inconsistent with similar objects that useplaceholder. For consistency and clarity, consider usingplaceholder.Consider updating the property name:
- source_placeholder: 'Enter Cost Code', + placeholder: 'Enter Cost Code',
860-864: Inconsistent property name incostTypeFieldValueSimilarly, the
costTypeFieldValueobject usessource_placeholder. Aligning the property name with others enhances consistency.Consider the following change:
- source_placeholder: 'Enter Cost Type', + placeholder: 'Enter Cost Type',
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- src/app/integrations/intacct/intacct-shared/intacct-import-settings/intacct-import-settings.component.spec.ts (1 hunks)
- src/app/integrations/intacct/intacct.fixture.ts (2 hunks)
🧰 Additional context used
🔇 Additional comments (12)
src/app/integrations/intacct/intacct-shared/intacct-import-settings/intacct-import-settings.component.spec.ts (1)
1-290: Overall, excellent enhancement of the test suiteThe updated tests significantly improve coverage and robustness for the
IntacctImportSettingsComponent. Great work on thoroughly validating component functionality across different scenarios.src/app/integrations/intacct/intacct.fixture.ts (11)
11-15: LGTM: New imports are correctly addedThe newly added imports for
ExpenseField,DependentFieldSetting,ImportSettingGet,LocationEntityMapping,GroupedDestinationAttribute, andIntacctConfigurationare appropriate and will support the new constants defined below.
744-749: LGTM: Definition ofintacctImportCodeConfigThe
intacctImportCodeConfigobject is properly defined with the expected boolean properties forPROJECT,DEPARTMENT,ACCOUNT, andEXPENSE_TYPE.
751-763: LGTM: Definition offyleFieldsThe
fyleFieldsarray is correctly defined withExpenseFieldobjects representingCost CenterandProject. The properties are appropriate and consistent.
764-778: LGTM: Definition ofsageIntacctFieldsThe
sageIntacctFieldsarray is correctly defined withExpenseFieldobjects forcustomer,item, andProject. The structure is consistent with the expected format.
779-795: LGTM: Definition ofimportSettingsThe
importSettingsobject is properly defined with configurations and general mappings. The assignment ofdependent_field_settingsasnullwith type assertion aligns with the interface requirements.
797-801: LGTM: Definition ofconfigurationThe
configurationobject is correctly defined with the specified properties, and the values are appropriate for the application's needs.
803-811: LGTM: Definition oflocationEntityMappingThe
locationEntityMappingobject is properly structured and initialized, providing necessary mapping details.
813-822: LGTM: Definition ofgroupedDestinationAttributesThe
groupedDestinationAttributesobject is correctly initialized with empty arrays for each attribute type. This setup is suitable for grouping destination attributes.
824-837: LGTM: Definition ofsageIntacctFieldsSortedByPriorityThe
sageIntacctFieldsSortedByPriorityarray is well-defined, listing fields sorted by priority as intended.
839-843: LGTM: Definition ofimportSettingsWithProjectThe
importSettingsWithProjectobject appropriately extendsimportSettingsby adding a project mapping tomapping_settings. The structure aligns with theImportSettingGetinterface.
845-852: LGTM: Definition ofsettingsWithDependentFieldsThe
settingsWithDependentFieldsobject correctly extendsimportSettingswithdependent_field_settings. The properties are properly assigned, and the object is cast toImportSettingGetas required.
| describe('Form Group Initialization', () => { | ||
| it('should initialize the form with correct controls', () => { | ||
| expect(component.importSettingsForm.get('importVendorAsMerchant')).toBeTruthy(); | ||
| expect(component.importSettingsForm.get('importCategories')).toBeTruthy(); | ||
| expect(component.importSettingsForm.get('importTaxCodes')).toBeTruthy(); | ||
| expect(component.importSettingsForm.get('costCodes')).toBeTruthy(); | ||
| expect(component.importSettingsForm.get('dependentFieldImportToggle')).toBeTruthy(); | ||
| expect(component.importSettingsForm.get('workspaceId')).toBeTruthy(); | ||
| expect(component.importSettingsForm.get('costTypes')).toBeTruthy(); | ||
| expect(component.importSettingsForm.get('isDependentImportEnabled')).toBeTruthy(); | ||
| expect(component.importSettingsForm.get('sageIntacctTaxCodes')).toBeTruthy(); | ||
| expect(component.importSettingsForm.get('expenseFields')).toBeTruthy(); | ||
| expect(component.importSettingsForm.get('searchOption')).toBeTruthy(); | ||
| expect(component.importSettingsForm.get('importCodeField')).toBeTruthy(); | ||
| expect(component.importSettingsForm.get('importCodeFields')).toBeTruthy(); | ||
| }); |
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.
🛠️ Refactor suggestion
Add form validation tests
While the form controls are initialized correctly, consider adding tests to verify form validation logic. Testing how the form behaves with invalid inputs will ensure robustness in user input handling.
| siImportSettingService.getImportSettings.and.returnValue(of(importSettingsWithProject)); | ||
|
|
||
| fixture.detectChanges(); | ||
| tick(); | ||
|
|
||
| expect(component.costCodeFieldOption.length).toBe(1); | ||
| expect(component.costTypeFieldOption.length).toBe(1); | ||
| })); | ||
|
|
||
| it('should handle dependent field settings', () => { | ||
| siImportSettingService.getImportSettings.and.returnValue(of(settingsWithDependentFields)); | ||
|
|
||
| component.ngOnInit(); | ||
| fixture.detectChanges(); | ||
|
|
||
| expect(component.importSettingsForm.get('isDependentImportEnabled')?.value).toBeTrue(); | ||
| expect(component.importSettingsForm.get('costCodes')?.value).toEqual(costCodeFieldValue); | ||
| expect(component.importSettingsForm.get('costTypes')?.value).toEqual(costTypeFieldValue); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
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.
🛠️ Refactor suggestion
Refactor duplicated code in dependent fields tests
The tests for dependent fields setup have duplicated stubbing of getImportSettings. Refactoring this into shared beforeEach blocks or helper functions can reduce code duplication and enhance maintainability.
| } | ||
| }, | ||
| mapping_settings: [], | ||
| dependent_field_settings: null as unknown as DependentFieldSetting, |
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.
Unnecessary type assertion when assigning null
Assigning null as unknown as DependentFieldSetting may be unnecessary. If dependent_field_settings is optional or accepts null, you can directly assign null without type assertion.
Consider simplifying the assignment:
-dependent_field_settings: null as unknown as DependentFieldSetting,
+dependent_field_settings: null,📝 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.
| dependent_field_settings: null as unknown as DependentFieldSetting, | |
| dependent_field_settings: null, |
Clickup
https://app.clickup.com/t/86cwh86d5
Summary by CodeRabbit
New Features
Bug Fixes
IntacctImportSettingsComponent, ensuring accurate initialization and save functionality.Tests