-
Notifications
You must be signed in to change notification settings - Fork 15
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: fix failing tests across the app #3417
base: FYLE-86cx2t82k-base-feature-branch
Are you sure you want to change the base?
Changes from all commits
09b744a
42958d0
6c79368
b30d0f9
e905388
a34b2a3
e2d3cd5
2c8635e
73f752e
170c797
0ce7fed
a55a55a
e389470
0c79118
be9c210
caa94af
d14a682
afb6b08
ec3c836
58ea384
4b9e382
70ef84e
7553f8a
b0c76df
3995de2
faa331f
9e5a634
27894d1
51ca20c
811414b
d57e521
7946a08
8045e63
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,7 +118,7 @@ describe('SwitchOrgPage', () => { | |
const deepLinkServiceSpy = jasmine.createSpyObj('DeepLinkService', ['getExpenseRoute']); | ||
const ldSpy = jasmine.createSpyObj('LaunchDarklyService', ['initializeUser']); | ||
const orgSettingsServiceSpy = jasmine.createSpyObj('OrgSettingsService', ['get']); | ||
const spenderOnboardingServiceSpy = jasmine.createSpyObj('SpenderOnboardingSettings', ['getOnboardingSettings']); | ||
const spenderOnboardingServiceSpy = jasmine.createSpyObj('SpenderOnboardingService', ['getOnboardingStatus']); | ||
|
||
TestBed.configureTestingModule({ | ||
declarations: [SwitchOrgPage, ActiveOrgCardComponent, OrgCardComponent, FyZeroStateComponent], | ||
|
@@ -280,7 +280,10 @@ describe('SwitchOrgPage', () => { | |
component.searchOrgsInput = fixture.debugElement.query(By.css('.smartlook-show')); | ||
component.contentRef = fixture.debugElement.query(By.css('.switch-org__content-container__content-block')); | ||
fixture.detectChanges(); | ||
spyOn(component, 'navigateToDashboard').and.callThrough(); | ||
spenderOnboardingService.getOnboardingStatus.and.returnValue( | ||
of({ ...onboardingStatusData, state: OnboardingState.COMPLETED }) | ||
); | ||
orgSettingsService.get.and.returnValue(of(orgSettingsData)); | ||
})); | ||
|
||
it('should create', () => { | ||
|
@@ -568,6 +571,16 @@ describe('SwitchOrgPage', () => { | |
})); | ||
}); | ||
|
||
it('navigateToDashboard(): should navigate to spender onboarding when onboarding status is not complete', fakeAsync(() => { | ||
spenderOnboardingService.getOnboardingStatus.and.returnValue( | ||
of({ ...onboardingStatusData, state: OnboardingState.YET_TO_START }) | ||
); | ||
orgSettingsService.get.and.returnValue(of(orgSettingsData)); | ||
component.navigateToDashboard(); | ||
tick(); | ||
expect(router.navigate).toHaveBeenCalledOnceWith(['/', 'enterprise', 'spender_onboarding']); | ||
})); | ||
Comment on lines
+574
to
+582
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Your test case is like a perfect entry scene, but we need more action! Consider adding test cases for:
|
||
|
||
describe('navigateToSetupPage():', () => { | ||
it('should navigate to setup page if org the roles has OWNER', () => { | ||
component.navigateToSetupPage(['OWNER']); | ||
|
@@ -592,7 +605,12 @@ describe('SwitchOrgPage', () => { | |
.pipe( | ||
finalize(() => { | ||
expect(loaderService.hideLoader).toHaveBeenCalledTimes(1); | ||
expect(router.navigate).toHaveBeenCalledOnceWith(['/', 'enterprise', 'my_dashboard']); | ||
expect(router.navigate).toHaveBeenCalledOnceWith([ | ||
'/', | ||
'enterprise', | ||
'my_dashboard', | ||
{ openSMSOptInDialog: undefined }, | ||
]); | ||
}) | ||
) | ||
.subscribe((res) => { | ||
|
@@ -675,7 +693,12 @@ describe('SwitchOrgPage', () => { | |
tick(); | ||
component.navigateBasedOnUserStatus(config).subscribe((res) => { | ||
expect(res).toBeNull(); | ||
expect(router.navigate).toHaveBeenCalledOnceWith(['/', 'enterprise', 'my_dashboard']); | ||
expect(router.navigate).toHaveBeenCalledOnceWith([ | ||
'/', | ||
'enterprise', | ||
'my_dashboard', | ||
{ openSMSOptInDialog: undefined }, | ||
]); | ||
}); | ||
})); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -321,7 +321,8 @@ export class SwitchOrgPage implements OnInit, AfterViewChecked { | |
forkJoin([this.orgSettingsService.get(), this.spenderOnboardingService.getOnboardingStatus()]).subscribe( | ||
([orgSettings, onboardingStatus]) => { | ||
if ( | ||
(orgSettings.visa_enrollment_settings.enabled || | ||
(orgSettings.corporate_credit_card_settings.enabled || | ||
orgSettings.visa_enrollment_settings.enabled || | ||
orgSettings.mastercard_enrollment_settings.enabled || | ||
orgSettings.amex_feed_enrollment_settings.enabled) && | ||
onboardingStatus.state !== OnboardingState.COMPLETED | ||
Comment on lines
+324
to
328
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Your navigation logic is like a perfectly choreographed fight scene! The conditions for card settings are well-structured: (orgSettings.corporate_credit_card_settings.enabled ||
orgSettings.visa_enrollment_settings.enabled ||
orgSettings.mastercard_enrollment_settings.enabled ||
orgSettings.amex_feed_enrollment_settings.enabled) However, consider extracting this into a helper method for better readability: private isCardEnrollmentEnabled(orgSettings: OrgSettings): boolean {
return (
orgSettings.corporate_credit_card_settings.enabled ||
orgSettings.visa_enrollment_settings.enabled ||
orgSettings.mastercard_enrollment_settings.enabled ||
orgSettings.amex_feed_enrollment_settings.enabled
);
} |
||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,5 +1,5 @@ | ||||||||||||||||||||
import { Injectable } from '@angular/core'; | ||||||||||||||||||||
import { map, Observable } from 'rxjs'; | ||||||||||||||||||||
import { BehaviorSubject, map, Observable } from 'rxjs'; | ||||||||||||||||||||
import { SpenderPlatformV1ApiService } from './spender-platform-v1-api.service'; | ||||||||||||||||||||
import { PlatformApiResponse } from '../models/platform/platform-api-response.model'; | ||||||||||||||||||||
import { OnboardingWelcomeStepStatus } from '../models/onboarding-welcome-step-status.model'; | ||||||||||||||||||||
|
@@ -10,6 +10,8 @@ | |||||||||||||||||||
providedIn: 'root', | ||||||||||||||||||||
}) | ||||||||||||||||||||
export class SpenderOnboardingService { | ||||||||||||||||||||
onboardingComplete$: BehaviorSubject<boolean> = new BehaviorSubject(true); | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mind it! Initialize onboardingComplete$ to false by default! Starting with true state could mislead subscribers about completion status. Let the actual completion event drive the state to true. - onboardingComplete$: BehaviorSubject<boolean> = new BehaviorSubject(true);
+ onboardingComplete$: BehaviorSubject<boolean> = new BehaviorSubject(false); 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||
|
||||||||||||||||||||
constructor(private spenderPlatformV1ApiService: SpenderPlatformV1ApiService) {} | ||||||||||||||||||||
|
||||||||||||||||||||
getOnboardingStatus(): Observable<OnboardingStatus> { | ||||||||||||||||||||
|
@@ -78,4 +80,14 @@ | |||||||||||||||||||
}; | ||||||||||||||||||||
return this.processSmsOptInStep(data); | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
setOnboardingStatusAsComplete(): Observable<boolean> { | ||||||||||||||||||||
return this.onboardingComplete$.asObservable(); | ||||||||||||||||||||
} | ||||||||||||||||||||
Comment on lines
+84
to
+86
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Macha, rename method to reflect its true purpose! The method name suggests it sets the status but it only returns an observable. Let's make it crystal clear! - setOnboardingStatusAsComplete(): Observable<boolean> {
+ getOnboardingStatusComplete$(): Observable<boolean> {
return this.onboardingComplete$.asObservable();
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||
|
||||||||||||||||||||
// Emit a new event | ||||||||||||||||||||
setOnboardingStatusEvent(): void { | ||||||||||||||||||||
this.onboardingComplete$.next(true); | ||||||||||||||||||||
console.log('event set'); | ||||||||||||||||||||
Check failure on line 91 in src/app/core/services/spender-onboarding.service.ts GitHub Actions / Run linters
Check failure on line 91 in src/app/core/services/spender-onboarding.service.ts GitHub Actions / Run linters
|
||||||||||||||||||||
} | ||||||||||||||||||||
Comment on lines
+88
to
+92
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style-ah! Remove that console.log statement! Production code should use proper logging service, not console.log statements. setOnboardingStatusEvent(): void {
this.onboardingComplete$.next(true);
- console.log('event set');
} 📝 Committable suggestion
Suggested change
🧰 Tools🪛 eslint[error] 91-91: Unexpected console statement. (no-console) 🪛 GitHub Check: Run linters[failure] 91-91: 🪛 GitHub Actions: Lint[error] 91-91: Unexpected console statement - ESLint rule 'no-console' violation |
||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,12 +22,13 @@ | |
<input | ||
class="smartlook-show connect-card__card-number-input pl-0" | ||
inputmode="numeric" | ||
mask="0000 0000 0000 0000" | ||
mask="0000 0000 0000" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Listen here, partner! This mask situation is no small matter! The mask • Change the mask back to 🔗 Analysis chainHold on! This card mask needs a double take! The mask has been reduced from 16 to 12 digits, which might not accommodate all valid card numbers. Please verify if all supported card types (Visa, Mastercard) can be properly entered with the 12-digit mask. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for card number validation logic
rg -A 5 "card.*number.*valid" src/
Length of output: 18158 |
||
placeholder="xxxx xxxx xxxx" | ||
data-testid="card-number-input" | ||
formControlName="card_number_{{ card.id }}" | ||
required | ||
(input)="onCardNumberUpdate(card)" | ||
[readonly]="cardValuesMap[card.id].enrollment_success" | ||
/> | ||
|
||
<div class="connect-card__card-last-four"> | ||
|
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.
Watch out! Memory leak alert!
The subscription to onboarding status needs cleanup. Implement OnDestroy and unsubscribe to prevent memory leaks.