Skip to content

Commit

Permalink
feat: Remove unified card enrollment flow LD flag (#2473)
Browse files Browse the repository at this point in the history
  • Loading branch information
OmkarJ13 authored Oct 4, 2023
1 parent d50f3f7 commit 09e8d7c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 54 deletions.
17 changes: 4 additions & 13 deletions src/app/fyle/dashboard/card-stats/card-stats.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { By } from '@angular/platform-browser';
import { cardDetailsRes } from 'src/app/core/mock-data/platform-corporate-card-detail-data';
import { AddCorporateCardComponent } from '../../manage-corporate-cards/add-corporate-card/add-corporate-card.component';
import { CardAddedComponent } from '../../manage-corporate-cards/card-added/card-added.component';
import { LaunchDarklyService } from 'src/app/core/services/launch-darkly.service';

@Component({
selector: 'app-spent-cards',
Expand Down Expand Up @@ -62,7 +61,6 @@ describe('CardStatsComponent', () => {
let orgUserSettingsService: jasmine.SpyObj<OrgUserSettingsService>;
let corporateCreditCardExpenseService: jasmine.SpyObj<CorporateCreditCardExpenseService>;
let popoverController: jasmine.SpyObj<PopoverController>;
let launchDarklyService: jasmine.SpyObj<LaunchDarklyService>;

beforeEach(waitForAsync(() => {
const currencyServiceSpy = jasmine.createSpyObj('CurrencyService', ['getHomeCurrency']);
Expand All @@ -76,7 +74,6 @@ describe('CardStatsComponent', () => {
'clearCache',
]);
const popoverControllerSpy = jasmine.createSpyObj('PopoverController', ['create']);
const launchDarklyServiceSpy = jasmine.createSpyObj('LaunchDarklyService', ['getVariation']);

TestBed.configureTestingModule({
declarations: [CardStatsComponent, MockSpentCardsComponent, MockAddCardComponent],
Expand Down Expand Up @@ -110,10 +107,6 @@ describe('CardStatsComponent', () => {
provide: PopoverController,
useValue: popoverControllerSpy,
},
{
provide: LaunchDarklyService,
useValue: launchDarklyServiceSpy,
},
],
}).compileComponents();

Expand All @@ -126,10 +119,9 @@ describe('CardStatsComponent', () => {
networkService = TestBed.inject(NetworkService) as jasmine.SpyObj<NetworkService>;
orgUserSettingsService = TestBed.inject(OrgUserSettingsService) as jasmine.SpyObj<OrgUserSettingsService>;
corporateCreditCardExpenseService = TestBed.inject(
CorporateCreditCardExpenseService,
CorporateCreditCardExpenseService
) as jasmine.SpyObj<CorporateCreditCardExpenseService>;
popoverController = TestBed.inject(PopoverController) as jasmine.SpyObj<PopoverController>;
launchDarklyService = TestBed.inject(LaunchDarklyService) as jasmine.SpyObj<LaunchDarklyService>;

// Default return values
currencyService.getHomeCurrency.and.returnValue(of('USD'));
Expand All @@ -140,7 +132,6 @@ describe('CardStatsComponent', () => {
corporateCreditCardExpenseService.getPlatformCorporateCardDetails.and.returnValue(cardDetails);
networkService.isOnline.and.returnValue(of(true));
corporateCreditCardExpenseService.clearCache.and.returnValue(of(null));
launchDarklyService.getVariation.and.returnValue(of(true));

spyOn(component.loadCardDetails$, 'next').and.callThrough();

Expand Down Expand Up @@ -192,7 +183,7 @@ describe('CardStatsComponent', () => {
expect(corporateCreditCardExpenseService.getCorporateCards).toHaveBeenCalledTimes(1);
expect(corporateCreditCardExpenseService.getPlatformCorporateCardDetails).toHaveBeenCalledOnceWith(
cards,
cardStats.cardDetails,
cardStats.cardDetails
);
});

Expand Down Expand Up @@ -245,7 +236,7 @@ describe('CardStatsComponent', () => {

popoverController.create.and.returnValues(
Promise.resolve(addCardPopoverSpy),
Promise.resolve(cardAddedPopoverSpy),
Promise.resolve(cardAddedPopoverSpy)
);

corporateCreditCardExpenseService.getCorporateCards.and.returnValue(of([]));
Expand Down Expand Up @@ -310,7 +301,7 @@ describe('CardStatsComponent', () => {

popoverController.create.and.returnValues(
Promise.resolve(addCardPopoverSpy),
Promise.resolve(cardAddedPopoverSpy),
Promise.resolve(cardAddedPopoverSpy)
);

component.ngOnInit();
Expand Down
20 changes: 3 additions & 17 deletions src/app/fyle/dashboard/card-stats/card-stats.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { AddCorporateCardComponent } from '../../manage-corporate-cards/add-corp
import { OverlayResponse } from 'src/app/core/models/overlay-response.modal';
import { CardAddedComponent } from '../../manage-corporate-cards/card-added/card-added.component';
import { NetworkService } from 'src/app/core/services/network.service';
import { LaunchDarklyService } from 'src/app/core/services/launch-darkly.service';

@Component({
selector: 'app-card-stats',
Expand Down Expand Up @@ -47,8 +46,7 @@ export class CardStatsComponent implements OnInit {
private networkService: NetworkService,
private orgUserSettingsService: OrgUserSettingsService,
private corporateCreditCardExpenseService: CorporateCreditCardExpenseService,
private popoverController: PopoverController,
private launchDarklyService: LaunchDarklyService
private popoverController: PopoverController
) {}

ngOnInit(): void {
Expand Down Expand Up @@ -98,20 +96,8 @@ export class CardStatsComponent implements OnInit {
)
);

const isUnifiedCardEnrollmentFlowEnabled$ = this.launchDarklyService.getVariation(
'unified_card_enrollment_flow_enabled',
false
);

this.canAddCorporateCards$ = forkJoin([
isUnifiedCardEnrollmentFlowEnabled$,
this.isVisaRTFEnabled$,
this.isMastercardRTFEnabled$,
]).pipe(
map(
([isUnifiedCardEnrollmentFlowEnabled, isVisaRTFEnabled, isMastercardRTFEnabled]) =>
isUnifiedCardEnrollmentFlowEnabled && (isVisaRTFEnabled || isMastercardRTFEnabled)
)
this.canAddCorporateCards$ = forkJoin([this.isVisaRTFEnabled$, this.isMastercardRTFEnabled$]).pipe(
map(([isVisaRTFEnabled, isMastercardRTFEnabled]) => isVisaRTFEnabled || isMastercardRTFEnabled)
);

this.cardDetails$ = this.loadCardDetails$.pipe(
Expand Down
4 changes: 1 addition & 3 deletions src/app/fyle/my-profile/my-profile.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@
></ion-icon>
</div>

<ng-container
*ngIf="isCCCEnabled && isUnifiedCardEnrollmentFlowEnabled && (isVisaRTFEnabled || isMastercardRTFEnabled)"
>
<ng-container *ngIf="isCCCEnabled && (isVisaRTFEnabled || isMastercardRTFEnabled)">
<div class="my-profile__section-header">Corporate Cards</div>
<div class="my-profile__card" [routerLink]="[ '/', 'enterprise', 'manage_corporate_cards' ]" matRipple>
<div class="my-profile__card__title">Manage Corporate Cards</div>
Expand Down
9 changes: 0 additions & 9 deletions src/app/fyle/my-profile/my-profile.page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import { MyProfilePage } from './my-profile.page';
import { UpdateMobileNumberComponent } from './update-mobile-number/update-mobile-number.component';
import { VerifyNumberPopoverComponent } from './verify-number-popover/verify-number-popover.component';
import { orgData1 } from 'src/app/core/mock-data/org.data';
import { LaunchDarklyService } from 'src/app/core/services/launch-darkly.service';

describe('MyProfilePage', () => {
let component: MyProfilePage;
Expand All @@ -52,7 +51,6 @@ describe('MyProfilePage', () => {
let matSnackBar: jasmine.SpyObj<MatSnackBar>;
let snackbarProperties: jasmine.SpyObj<SnackbarPropertiesService>;
let activatedRoute: jasmine.SpyObj<ActivatedRoute>;
let launchDarklyService: jasmine.SpyObj<LaunchDarklyService>;

beforeEach(waitForAsync(() => {
const authServiceSpy = jasmine.createSpyObj('AuthService', ['getEou', 'logout', 'refreshEou']);
Expand All @@ -76,7 +74,6 @@ describe('MyProfilePage', () => {
const popoverControllerSpy = jasmine.createSpyObj('PopoverController', ['create']);
const matSnackBarSpy = jasmine.createSpyObj('MatSnackBar', ['openFromComponent']);
const snackbarPropertiesSpy = jasmine.createSpyObj('SnackbarPropertiesService', ['setSnackbarProperties']);
const launchDarklyServiceSpy = jasmine.createSpyObj('LaunchDarklyService', ['getVariation']);

TestBed.configureTestingModule({
declarations: [MyProfilePage],
Expand Down Expand Up @@ -156,10 +153,6 @@ describe('MyProfilePage', () => {
provide: SnackbarPropertiesService,
useValue: snackbarPropertiesSpy,
},
{
provide: LaunchDarklyService,
useValue: launchDarklyServiceSpy,
},
],
}).compileComponents();

Expand All @@ -183,9 +176,7 @@ describe('MyProfilePage', () => {
matSnackBar = TestBed.inject(MatSnackBar) as jasmine.SpyObj<MatSnackBar>;
snackbarProperties = TestBed.inject(SnackbarPropertiesService) as jasmine.SpyObj<SnackbarPropertiesService>;
activatedRoute = TestBed.inject(ActivatedRoute) as jasmine.SpyObj<ActivatedRoute>;
launchDarklyService = TestBed.inject(LaunchDarklyService) as jasmine.SpyObj<LaunchDarklyService>;

launchDarklyService.getVariation.and.returnValue(of(true));
component.loadEou$ = new BehaviorSubject(null);
component.eou$ = of(apiEouRes);

Expand Down
13 changes: 1 addition & 12 deletions src/app/fyle/my-profile/my-profile.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import { OverlayResponse } from 'src/app/core/models/overlay-response.modal';
import { EventData } from 'src/app/core/models/event-data.model';
import { PreferenceSetting } from 'src/app/core/models/preference-setting.model';
import { CopyCardDetails } from 'src/app/core/models/copy-card-details.model';
import { LaunchDarklyService } from 'src/app/core/services/launch-darkly.service';

@Component({
selector: 'app-my-profile',
Expand Down Expand Up @@ -74,10 +73,6 @@ export class MyProfilePage {

isMastercardRTFEnabled: boolean;

isYodleeEnabled: boolean;

isUnifiedCardEnrollmentFlowEnabled: boolean;

constructor(
private authService: AuthService,
private orgUserSettingsService: OrgUserSettingsService,
Expand All @@ -94,8 +89,7 @@ export class MyProfilePage {
private popoverController: PopoverController,
private matSnackBar: MatSnackBar,
private snackbarProperties: SnackbarPropertiesService,
private activatedRoute: ActivatedRoute,
private launchDarklyService: LaunchDarklyService
private activatedRoute: ActivatedRoute
) {}

setupNetworkWatcher(): void {
Expand Down Expand Up @@ -187,18 +181,13 @@ export class MyProfilePage {
forkJoin({
orgUserSettings: orgUserSettings$,
orgSettings: orgSettings$,
isUnifiedCardEnrollmentFlowEnabled: this.launchDarklyService.getVariation(
'unified_card_enrollment_flow_enabled',
false
),
})
),
finalize(() => from(this.loaderService.hideLoader()))
)
.subscribe(async (res) => {
this.orgUserSettings = res.orgUserSettings;
this.orgSettings = res.orgSettings;
this.isUnifiedCardEnrollmentFlowEnabled = res.isUnifiedCardEnrollmentFlowEnabled;

this.setCCCFlags();
this.setPreferenceSettings();
Expand Down

0 comments on commit 09e8d7c

Please sign in to comment.