-
Notifications
You must be signed in to change notification settings - Fork 0
test: intacct advanced settings initialization #1024
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
Merged
JustARatherRidiculouslyLongUsername
merged 3 commits into
master
from
ut-intacct-advanced-settings
Oct 18, 2024
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
1a7a5fc
test: intacct advanced settings initialization
JustARatherRidiculouslyLongUsername ab0bfde
Merge branch 'master' into ut-intacct-advanced-settings
JustARatherRidiculouslyLongUsername 9d4aaf0
Merge branch 'master' into ut-intacct-advanced-settings
JustARatherRidiculouslyLongUsername File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
112 changes: 104 additions & 8 deletions
112
...acct/intacct-shared/intacct-advanced-settings/intacct-advanced-settings.component.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,119 @@ | ||
| import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
|
||
| import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; | ||
| import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms'; | ||
| import { provideRouter, Router } from '@angular/router'; | ||
| import { of } from 'rxjs'; | ||
| import { IntacctAdvancedSettingsComponent } from './intacct-advanced-settings.component'; | ||
| import { SiAdvancedSettingService } from 'src/app/core/services/si/si-configuration/si-advanced-setting.service'; | ||
| import { IntegrationsToastService } from 'src/app/core/services/common/integrations-toast.service'; | ||
| import { TrackingService } from 'src/app/core/services/integration/tracking.service'; | ||
| import { SiWorkspaceService } from 'src/app/core/services/si/si-core/si-workspace.service'; | ||
| import { SiMappingsService } from 'src/app/core/services/si/si-core/si-mappings.service'; | ||
| import { SkipExportComponent } from 'src/app/shared/components/si/helper/skip-export/skip-export.component'; | ||
| import { adminEmails, advancedSettings, configurationForAddvancedSettings, expenseFilter, groupedAttributes } from '../../intacct.fixture'; | ||
| import { ExpenseFilterResponse } from 'src/app/core/models/intacct/intacct-configuration/advanced-settings.model'; | ||
| import { SharedModule } from 'src/app/shared/shared.module'; | ||
|
|
||
| xdescribe('IntacctAdvancedSettingsComponent', () => { | ||
| describe('IntacctAdvancedSettingsComponent', () => { | ||
| let component: IntacctAdvancedSettingsComponent; | ||
| let fixture: ComponentFixture<IntacctAdvancedSettingsComponent>; | ||
| let advancedSettingsService: jasmine.SpyObj<SiAdvancedSettingService>; | ||
| let router: Router; | ||
| let toastService: jasmine.SpyObj<IntegrationsToastService>; | ||
| let trackingService: jasmine.SpyObj<TrackingService>; | ||
| let workspaceService: jasmine.SpyObj<SiWorkspaceService>; | ||
| let mappingService: jasmine.SpyObj<SiMappingsService>; | ||
|
|
||
|
|
||
| beforeEach(async () => { | ||
| const advancedSettingsServiceSpy = jasmine.createSpyObj('SiAdvancedSettingService', ['getAdvancedSettings', 'getExpenseFilter', 'getAdditionalEmails']); | ||
| const toastServiceSpy = jasmine.createSpyObj('IntegrationsToastService', ['displayToastMessage']); | ||
| const trackingServiceSpy = jasmine.createSpyObj('TrackingService', ['trackTimeSpent', 'integrationsOnboardingCompletion', 'intacctUpdateEvent']); | ||
| const workspaceServiceSpy = jasmine.createSpyObj('SiWorkspaceService', ['getIntacctOnboardingState', 'setIntacctOnboardingState']); | ||
| const mappingServiceSpy = jasmine.createSpyObj('SiMappingsService', ['getGroupedDestinationAttributes', 'getConfiguration', 'refreshSageIntacctDimensions', 'refreshFyleDimensions']); | ||
| await TestBed.configureTestingModule({ | ||
| declarations: [ IntacctAdvancedSettingsComponent ] | ||
| }) | ||
| .compileComponents(); | ||
| declarations: [ IntacctAdvancedSettingsComponent, SkipExportComponent ], | ||
| imports: [ SharedModule, ReactiveFormsModule ], | ||
| providers: [ | ||
| FormBuilder, | ||
| { provide: SiAdvancedSettingService, useValue: advancedSettingsServiceSpy }, | ||
| { provide: IntegrationsToastService, useValue: toastServiceSpy }, | ||
| { provide: TrackingService, useValue: trackingServiceSpy }, | ||
| { provide: SiWorkspaceService, useValue: workspaceServiceSpy }, | ||
| { provide: SiMappingsService, useValue: mappingServiceSpy }, | ||
| provideRouter([]) | ||
| ] | ||
| }).compileComponents(); | ||
|
|
||
| advancedSettingsService = TestBed.inject(SiAdvancedSettingService) as jasmine.SpyObj<SiAdvancedSettingService>; | ||
| toastService = TestBed.inject(IntegrationsToastService) as jasmine.SpyObj<IntegrationsToastService>; | ||
| trackingService = TestBed.inject(TrackingService) as jasmine.SpyObj<TrackingService>; | ||
| workspaceService = TestBed.inject(SiWorkspaceService) as jasmine.SpyObj<SiWorkspaceService>; | ||
| mappingService = TestBed.inject(SiMappingsService) as jasmine.SpyObj<SiMappingsService>; | ||
| router = TestBed.inject(Router); | ||
|
|
||
| advancedSettingsService.getAdditionalEmails.and.returnValue(of(adminEmails)); | ||
| advancedSettingsService.getAdvancedSettings.and.returnValue(of(advancedSettings)); | ||
| advancedSettingsService.getExpenseFilter.and.returnValue(of(expenseFilter as ExpenseFilterResponse)); | ||
| mappingService.getGroupedDestinationAttributes.and.returnValue(of(groupedAttributes)); | ||
| mappingService.getConfiguration.and.returnValue(of(configurationForAddvancedSettings)); | ||
|
|
||
| fixture = TestBed.createComponent(IntacctAdvancedSettingsComponent); | ||
| component = fixture.componentInstance; | ||
| fixture.detectChanges(); | ||
| }); | ||
|
|
||
| it('should create', () => { | ||
| expect(component).toBeTruthy(); | ||
| }); | ||
| }); | ||
|
|
||
| it('should initialize with correct data', fakeAsync(() => { | ||
| fixture.detectChanges(); | ||
| tick(); | ||
|
|
||
| expect(component.isLoading).toBeFalse(); | ||
| expect(component.adminEmails).toEqual(adminEmails.concat(advancedSettings.workspace_schedules.additional_email_options)); | ||
| expect(component.advancedSettings).toEqual(advancedSettings); | ||
| expect(component.sageIntacctLocations).toEqual(groupedAttributes.LOCATION); | ||
| expect(component.sageIntacctDefaultItem).toEqual(groupedAttributes.ITEM); | ||
| expect(component.sageIntacctDepartments).toEqual(groupedAttributes.DEPARTMENT); | ||
| expect(component.sageIntacctProjects).toEqual(groupedAttributes.PROJECT); | ||
| expect(component.sageIntacctClasses).toEqual(groupedAttributes.CLASS); | ||
| expect(component.sageIntacctPaymentAccount).toEqual(groupedAttributes.PAYMENT_ACCOUNT); | ||
| expect(component.reimbursableExpense).toEqual(configurationForAddvancedSettings.reimbursable_expenses_object); | ||
| expect(component.corporateCreditCardExpense).toEqual(configurationForAddvancedSettings.corporate_credit_card_expenses_object); | ||
| expect(component.importVendorsAsMerchants).toEqual(configurationForAddvancedSettings.import_vendors_as_merchants); | ||
| expect(component.useMerchantInJournalLine).toEqual(configurationForAddvancedSettings.use_merchant_in_journal_line); | ||
| expect(component.employeeFieldMapping).toEqual(configurationForAddvancedSettings.employee_field_mapping); | ||
| })); | ||
|
|
||
| it('should initialize forms correctly', () => { | ||
| fixture.detectChanges(); | ||
|
|
||
| expect(component.advancedSettingsForm).toBeDefined(); | ||
| expect(component.skipExportForm).toBeDefined(); | ||
|
|
||
| expect(component.advancedSettingsForm.get('exportSchedule')?.value).toBeTrue(); | ||
| expect(component.advancedSettingsForm.get('exportScheduleFrequency')?.value).toBe(12); | ||
| expect(component.advancedSettingsForm.get('setDescriptionField')?.value).toEqual(['employee_email', 'merchant', 'purpose']); | ||
| }); | ||
|
|
||
| it('should handle onboarding state correctly', () => { | ||
| spyOnProperty(router, 'url').and.returnValue('/integrations/intacct/onboarding/advanced_settings'); | ||
| fixture.detectChanges(); | ||
|
|
||
| expect(component.isOnboarding).toBeTrue(); | ||
| }); | ||
JustARatherRidiculouslyLongUsername marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| it('should handle non-onboarding state correctly', () => { | ||
| spyOnProperty(router, 'url').and.returnValue('/integrations/intacct/advanced_settings'); | ||
| fixture.detectChanges(); | ||
|
|
||
| expect(component.isOnboarding).toBeFalse(); | ||
| }); | ||
|
|
||
| it('should create memo preview correctly', () => { | ||
| fixture.detectChanges(); | ||
|
|
||
| const expectedPreview = '[email protected] - Pizza Hut - Client Meeting'; | ||
| expect(component.memoPreviewText).toBe(expectedPreview); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,8 +11,10 @@ import { SkipExportLogResponse } from "src/app/core/models/intacct/db/expense-gr | |
| import { ExpenseField } from 'src/app/core/models/intacct/db/expense-field.model'; | ||
| import { DependentFieldSetting, ImportSettingGet, MappingSetting } from 'src/app/core/models/intacct/intacct-configuration/import-settings.model'; | ||
| import { LocationEntityMapping } from 'src/app/core/models/intacct/db/location-entity-mapping.model'; | ||
| import { GroupedDestinationAttribute } from "src/app/core/models/intacct/db/destination-attribute.model"; | ||
| import { GroupedDestinationAttribute, IntacctDestinationAttribute } from "src/app/core/models/intacct/db/destination-attribute.model"; | ||
| import { IntacctConfiguration } from "src/app/core/models/db/configuration.model"; | ||
| import { QBDEmailOptions } from "src/app/core/models/qbd/qbd-configuration/qbd-advanced-setting.model"; | ||
| import { AdvancedSettingsGet } from "src/app/core/models/intacct/intacct-configuration/advanced-settings.model"; | ||
|
|
||
| export const workspaceResponse: IntacctWorkspace[] = [{ | ||
| "id": 1, | ||
|
|
@@ -942,4 +944,59 @@ export const blankMapping: MappingSetting = { | |
| export const customFieldFormValue = { | ||
| attribute_type: 'TEST', | ||
| source_placeholder: 'TEST_PLACEHOLDER' | ||
| }; | ||
| }; | ||
|
|
||
| export const adminEmails = [ | ||
| { name: 'John Doe', email: '[email protected]' }, | ||
| { name: 'Jane Smith', email: '[email protected]' } | ||
| ] as QBDEmailOptions[]; | ||
JustARatherRidiculouslyLongUsername marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| export const advancedSettings = { | ||
| workspace_schedules: { | ||
| enabled: true, | ||
| interval_hours: 12, | ||
| emails_selected: ['[email protected]'], | ||
| additional_email_options: [ | ||
| { name: 'Additional User', email: '[email protected]' } | ||
| ] | ||
| }, | ||
| configurations: { | ||
| sync_fyle_to_sage_intacct_payments: true, | ||
| sync_sage_intacct_to_fyle_payments: false, | ||
| auto_create_destination_entity: true, | ||
| change_accounting_period: true, | ||
| memo_structure: ['employee_email', 'merchant', 'purpose'], | ||
| auto_create_merchants_as_vendors: false | ||
| }, | ||
| general_mappings: { | ||
| default_location: { id: 'LOC1' }, | ||
| default_department: { id: 'DEP1' }, | ||
| default_project: { id: 'PRJ1' }, | ||
| default_class: { id: 'CLS1' }, | ||
| default_item: { id: 'ITEM1' }, | ||
| payment_account: { id: 'ACC1' }, | ||
| use_intacct_employee_locations: true, | ||
| use_intacct_employee_departments: true | ||
| } | ||
| } as unknown as AdvancedSettingsGet; | ||
|
|
||
| export const expenseFilter = { | ||
| count: 0 | ||
| }; | ||
|
|
||
| export const groupedAttributes = { | ||
| LOCATION: [{ destination_id: 'LOC1', value: 'Location 1' }] as IntacctDestinationAttribute[], | ||
| DEPARTMENT: [{ destination_id: 'DEP1', value: 'Department 1' }] as IntacctDestinationAttribute[], | ||
| PROJECT: [{ destination_id: 'PRJ1', value: 'Project 1' }] as IntacctDestinationAttribute[], | ||
| CLASS: [{ destination_id: 'CLS1', value: 'Class 1' }] as IntacctDestinationAttribute[], | ||
| ITEM: [{ destination_id: 'ITEM1', value: 'Item 1' }] as IntacctDestinationAttribute[], | ||
| PAYMENT_ACCOUNT: [{ destination_id: 'ACC1', value: 'Account 1' }] as IntacctDestinationAttribute[] | ||
| } as GroupedDestinationAttribute; | ||
|
|
||
| export const configurationForAddvancedSettings = { | ||
| reimbursable_expenses_object: IntacctReimbursableExpensesObject.EXPENSE_REPORT, | ||
| corporate_credit_card_expenses_object: IntacctCorporateCreditCardExpensesObject.CHARGE_CARD_TRANSACTION, | ||
| import_vendors_as_merchants: false, | ||
| use_merchant_in_journal_line: true, | ||
| employee_field_mapping: FyleField.EMPLOYEE | ||
| } as IntacctConfiguration; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.