Skip to content
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 advanced settings save functionality #1026

Merged

Conversation

JustARatherRidiculouslyLongUsername
Copy link
Contributor

@JustARatherRidiculouslyLongUsername JustARatherRidiculouslyLongUsername commented Oct 15, 2024

Clickup

https://app.clickup.com/t/86cwh86cy

Summary by CodeRabbit

  • Tests
    • Enhanced test suite for the Intacct Advanced Settings component to improve coverage and robustness.
    • Added tests for component initialization, onboarding state handling, memo preview functionality, form field watchers, and save functionality across various scenarios.
  • Chores
    • Updated fixture file with new constants and expanded imports for improved configuration handling, including admin emails and advanced settings.

Copy link
Contributor

coderabbitai bot commented Oct 15, 2024

Walkthrough

The pull request enhances the test suite for the IntacctAdvancedSettingsComponent, improving coverage and robustness. Key updates include the addition of new dependencies, restructuring the test suite, and expanding tests for component initialization, onboarding state handling, memo preview functionality, form watchers, and save functionality. Additionally, the intacct.fixture.ts file has been updated with new constants and expanded imports to support the enhanced testing framework.

Changes

File Path Change Summary
src/app/integrations/intacct/intacct-advanced-settings/intacct-advanced-settings.component.spec.ts Enhanced test suite with new dependencies, restructured tests, and expanded coverage for component behavior, initialization, onboarding state, memo preview, form watchers, and save functionality.
src/app/integrations/intacct/intacct.fixture.ts Updated with new constants (adminEmails, advancedSettings, expenseFilter, groupedAttributes, configurationForAddvancedSettings) and expanded imports.

Possibly related PRs

Suggested labels

deploy

Suggested reviewers

  • DhaaraniCIT
  • ashwin1111

Poem

🐇 In the meadow where tests do play,
New constants bloom, bright as the day.
With every save and form that we tweak,
Robustness grows, our goals we seek!
Hops of joy for the code we write,
In Intacct's realm, everything feels right! 🌼


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between fbaadfe and a68d5d4.

📒 Files selected for processing (1)
  • src/app/integrations/intacct/intacct-shared/intacct-advanced-settings/intacct-advanced-settings.component.spec.ts (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/app/integrations/intacct/intacct-shared/intacct-advanced-settings/intacct-advanced-settings.component.spec.ts

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Outside diff range and nitpick comments (4)
src/app/integrations/intacct/intacct-shared/intacct-advanced-settings/intacct-advanced-settings.component.spec.ts (4)

169-169: Avoid using as any; provide a proper type for skipExportChild

At line 169, skipExportChild is assigned an object cast as any. This bypasses TypeScript's type checking and can lead to unexpected errors. Define an appropriate type or use the actual component reference to maintain strong typing.

Apply this change to define a proper type:

- component.skipExportChild = { saveSkipExportFields: jasmine.createSpy('saveSkipExportFields') } as any;
+ component.skipExportChild = {
+   saveSkipExportFields: jasmine.createSpy('saveSkipExportFields')
+ } as jasmine.SpyObj<SkipExportComponent>;

Ensure that SkipExportComponent is imported and used correctly in the test setup.


196-199: Avoid hard-coded IDs in tests for better maintainability

In lines 197-199, the test uses hard-coded IDs (1 and 2) when verifying calls to deleteExpenseFilter. Relying on hard-coded values can make tests brittle and harder to maintain. Consider defining constants or obtaining these IDs dynamically to enhance readability and maintainability.

Apply this change:

- expect(advancedSettingsService.deleteExpenseFilter).toHaveBeenCalledWith(1);
- expect(advancedSettingsService.deleteExpenseFilter).toHaveBeenCalledWith(2);
+ const expenseFilterId1 = 1; // Replace with a meaningful constant or obtained ID
+ const expenseFilterId2 = 2; // Replace with a meaningful constant or obtained ID
+ expect(advancedSettingsService.deleteExpenseFilter).toHaveBeenCalledWith(expenseFilterId1);
+ expect(advancedSettingsService.deleteExpenseFilter).toHaveBeenCalledWith(expenseFilterId2);

218-220: Provide more informative error handling in tests

In the error handling test at lines 218-220, the error message is simply 'Error'. Providing a more descriptive error message or using an actual error object can improve test clarity and ensure that the component handles various error scenarios appropriately.

Consider updating the test as follows:

- const getError = () => new Error('Error');
+ const getError = () => new Error('Network error');

This makes the error scenario more specific and can help in verifying that the component displays appropriate messages to the user.


78-107: Add assertions to verify all critical form fields and component properties

In the initialization tests between lines 78-107, while several properties are being asserted, some component properties or form controls may not be verified. To ensure comprehensive test coverage, consider adding assertions for all critical properties and form controls.

Review and add assertions as needed:

expect(component.advancedSettingsForm.get('someOtherControl')?.value).toEqual(expectedValue);
expect(component.anotherComponentProperty).toBe(expectedState);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 5f99ab0 and fbaadfe.

📒 Files selected for processing (2)
  • src/app/integrations/intacct/intacct-shared/intacct-advanced-settings/intacct-advanced-settings.component.spec.ts (1 hunks)
  • src/app/integrations/intacct/intacct.fixture.ts (2 hunks)
🧰 Additional context used
🔇 Additional comments (3)
src/app/integrations/intacct/intacct.fixture.ts (3)

954-981: Advanced Settings Initialization Looks Good

The advancedSettings constant is correctly defined with a proper structure and appropriate values.


983-985: Expense Filter Initialization Looks Good

The expenseFilter constant is properly initialized with a count property set to 0.


987-994: Grouped Attributes Are Correctly Defined

The groupedAttributes constant is properly defined with the expected keys and corresponding IntacctDestinationAttribute arrays.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

🧹 Outside diff range and nitpick comments (2)
src/app/integrations/intacct/intacct-shared/intacct-advanced-settings/intacct-advanced-settings.component.spec.ts (2)

164-183: Missing Assertions on Service Calls

In the save functionality test during onboarding, there are multiple service calls, but not all are asserted. To ensure the test is robust, include assertions for all expected service interactions.

Consider adding assertions for the following service calls:

  • workspaceService.getIntacctOnboardingState
  • component.skipExportChild.saveSkipExportFields

Update the test to include these assertions.


40-40: Ensure All Spied Methods Are Used

In the spy object mappingServiceSpy, methods like refreshSageIntacctDimensions and refreshFyleDimensions are included but not used in the tests. Remove unused methods from the spy object to keep the test setup clean.

Apply this diff to remove unused methods:

- const mappingServiceSpy = jasmine.createSpyObj('SiMappingsService', ['getGroupedDestinationAttributes', 'getConfiguration', 'refreshSageIntacctDimensions', 'refreshFyleDimensions']);
+ const mappingServiceSpy = jasmine.createSpyObj('SiMappingsService', ['getGroupedDestinationAttributes', 'getConfiguration']);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 5f99ab0 and fbaadfe.

📒 Files selected for processing (2)
  • src/app/integrations/intacct/intacct-shared/intacct-advanced-settings/intacct-advanced-settings.component.spec.ts (1 hunks)
  • src/app/integrations/intacct/intacct.fixture.ts (2 hunks)
🧰 Additional context used
🔇 Additional comments (7)
src/app/integrations/intacct/intacct.fixture.ts (3)

14-14: LGTM: New imports are appropriate.

The added imports for GroupedDestinationAttribute, IntacctDestinationAttribute, QBDEmailOptions, and AdvancedSettingsGet are relevant to the new constants introduced in this file.

Also applies to: 16-17


949-985: LGTM: New constants are well-structured and appropriate for testing.

The newly added constants adminEmails, advancedSettings, and expenseFilter are well-structured and contain appropriate mock data for testing purposes. The use of type assertions ensures type safety when using these constants in tests.


987-1002: LGTM: New constants enhance test data coverage.

The newly added constants groupedAttributes and configurationForAddvancedSettings are well-structured and provide comprehensive mock data for testing various scenarios. The use of enums and type assertions ensures type safety.

Overall, the changes in this file significantly enhance the test data coverage for Intacct integration, particularly for advanced settings and grouped attributes. This will allow for more thorough and accurate testing of the related functionality.

src/app/integrations/intacct/intacct-shared/intacct-advanced-settings/intacct-advanced-settings.component.spec.ts (4)

198-199: Redundant Calls to deleteExpenseFilter

The test checks for two calls to advancedSettingsService.deleteExpenseFilter with IDs 1 and 2. Ensure that these IDs are correct and that both calls are necessary. If the IDs are dynamic or fetched from a list, consider using a loop or parameterized test.

Verify that IDs 1 and 2 correspond to existing filters.


175-175: Missing tick() After Async Operation

In the test, there is a call to component.save(); followed by tick();. Ensure that all asynchronous operations have corresponding tick() calls to simulate the passage of time correctly.


126-127: ⚠️ Potential issue

Potential Flaky Test Due to Dynamic Date

The test uses new Date(Date.now()).toLocaleDateString() to generate a date in memoPreviewText, which can lead to flaky tests if the date changes or in different time zones. It's better to use a fixed date to ensure consistent test results.

Apply this diff to use a fixed date in the test:

- expect(component.memoPreviewText).toBe('Client Meeting - Meals and Entertainment - ' + new Date(Date.now()).toLocaleDateString());
+ const fixedDate = '01/01/2021';
+ expect(component.memoPreviewText).toBe('Client Meeting - Meals and Entertainment - ' + fixedDate);

And update the component or mock the date accordingly.

Likely invalid or redundant comment.


83-83: Possible Issue with Email Concatenation Order

The concatenation of adminEmails and advancedSettings.workspace_schedules.additional_email_options may result in the emails being in an unintended order. Verify if this is the desired sequence.

Run the following script to check the order of concatenated emails:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/M Medium PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants