-
Notifications
You must be signed in to change notification settings - Fork 0
test: intacct c1 import settings initialization #1012
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 c1 import settings initialization #1012
Conversation
WalkthroughThe pull request includes significant modifications to the test suites for the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
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 (4)
src/app/integrations/intacct/intacct-shared/intacct-c1-import-settings/intacct-c1-import-settings.component.spec.ts (3)
44-62: Review Spied Methods in Service MocksSeveral methods are being spied on in the service mocks. Please ensure that all these methods are necessary for the tests. Removing unused spied methods can simplify the test setup and improve maintainability.
68-76: Clean Up Unused Providers in TestBed ConfigurationThe
providersarray in theTestBedconfiguration includes multiple services. Verify that all provided services are required for the tests. Removing unused providers can streamline the test configuration.
94-95: Assess the Need for Spying on Router PropertiesThe setup includes spying on
router.navigateand overridingrouter.url. If these are not utilized in the test cases, consider removing these spies to reduce unnecessary code.src/app/integrations/intacct/intacct.fixture.ts (1)
853-857: Ensure consistent property definitions across fieldsIn
sageIntacctFieldsSortedByPriorityForC1, thesource_placeholderandis_dependentproperties are only included in the'GENERAL_LEDGER_ACCOUNT'field. For consistency, consider adding these properties to all fields or omitting them if they are not necessary.If these properties are only relevant for
'GENERAL_LEDGER_ACCOUNT', documenting the reason can improve code readability.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
- src/app/integrations/intacct/intacct-shared/intacct-c1-import-settings/intacct-c1-import-settings.component.spec.ts (1 hunks)
- src/app/integrations/intacct/intacct-shared/intacct-import-settings/intacct-import-settings.component.spec.ts (2 hunks)
- src/app/integrations/intacct/intacct.fixture.ts (2 hunks)
🧰 Additional context used
🔇 Additional comments (1)
src/app/integrations/intacct/intacct-shared/intacct-import-settings/intacct-import-settings.component.spec.ts (1)
185-185: Improved variable naming enhances code clarity.The change from
importSettingsWithProjecttoimportSettingsWithProjectMappingis a positive improvement. This new name is more descriptive and accurately reflects the content of the variable, enhancing code readability and maintaining consistency with the updated fixture data.
| it('should generate the correct expense fields', () => { | ||
| importSettingService.getImportSettings.and.returnValue(of( | ||
| importSettingsWithProjectMapping as ImportSettingGet | ||
| )); | ||
| spyOn<any>(component, 'createFormGroup').and.callThrough(); |
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
Avoid Spying on Private Methods
In the test case 'should generate the correct expense fields', you're using spyOn<any>(component, 'createFormGroup').and.callThrough();. Spying on private methods can lead to brittle tests. It's better to test the public interface of the component without directly interacting with its internal implementation.
Apply this change to rely on the component's public methods:
-it('should generate the correct expense fields', () => {
- importSettingService.getImportSettings.and.returnValue(of(
- importSettingsWithProjectMapping as ImportSettingGet
- ));
- spyOn<any>(component, 'createFormGroup').and.callThrough();
- component.ngOnInit();
-
- expect(component.importSettingsForm.get('expenseFields')?.value).toEqual(expenseFieldsExpectedForC1);
-});
+it('should generate the correct expense fields', () => {
+ importSettingService.getImportSettings.and.returnValue(of(
+ importSettingsWithProjectMapping as ImportSettingGet
+ ));
+ component.ngOnInit();
+
+ expect(component.importSettingsForm.get('expenseFields')?.value).toEqual(expenseFieldsExpectedForC1);
+});📝 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.
| it('should generate the correct expense fields', () => { | |
| importSettingService.getImportSettings.and.returnValue(of( | |
| importSettingsWithProjectMapping as ImportSettingGet | |
| )); | |
| spyOn<any>(component, 'createFormGroup').and.callThrough(); | |
| it('should generate the correct expense fields', () => { | |
| importSettingService.getImportSettings.and.returnValue(of( | |
| importSettingsWithProjectMapping as ImportSettingGet | |
| )); | |
| component.ngOnInit(); | |
| expect(component.importSettingsForm.get('expenseFields')?.value).toEqual(expenseFieldsExpectedForC1); | |
| }); |
| source_field: "", | ||
| destination_field: "CUSTOMER", | ||
| import_to_fyle: false, | ||
| is_custom: false, | ||
| source_placeholder: null | ||
| }, |
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.
Handle source_field with null for unmapped destination fields
In expenseFieldsExpectedForC1, the source_field is set to an empty string for 'CUSTOMER' and 'ITEM'. If there is no corresponding source field, it's preferable to use null instead of an empty string to clearly indicate the absence of a source field.
Apply this diff:
{
- source_field: "",
+ source_field: null,
destination_field: "CUSTOMER",
import_to_fyle: false,
is_custom: false,
source_placeholder: null
},
{
- source_field: "",
+ source_field: null,
destination_field: "ITEM",
import_to_fyle: false,
is_custom: false,
source_placeholder: null
}Also applies to: 911-916
| attribute_type: 'GENERAL_LEDGER_ACCOUNT', | ||
| display_name: 'General Ledger Account', | ||
| source_placeholder: '', | ||
| is_dependent: false |
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
Use null instead of an empty string for source_placeholder
For clarity and consistency, consider using null instead of an empty string for source_placeholder when no placeholder is required.
Apply this diff:
source_placeholder: '',
+ source_placeholder: null,
is_dependent: false
}Committable suggestion was skipped due to low confidence.
Clickup
https://app.clickup.com/t/86cwqhb5w
Summary by CodeRabbit
Bug Fixes
IntacctC1ImportSettingsComponentandIntacctImportSettingsComponentto ensure proper initialization and form control validation.New Features
Documentation