Skip to content

Commit

Permalink
fix: Fix issues with sign in page redirection and video view (#3404)
Browse files Browse the repository at this point in the history
  • Loading branch information
bistaastha authored Jan 7, 2025
1 parent 8c8b5f2 commit 7358230
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 18 deletions.
2 changes: 2 additions & 0 deletions src/app/auth/sign-in/sign-in.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
oncanplay="this.play()"
poster="../../../assets/images/video-default-background.png"
loop
playsinline
autoplay
>
<source src="/assets/videos/mobile-onboarding.mp4" type="video/mp4" />
</video>
Expand Down
11 changes: 4 additions & 7 deletions src/app/auth/sign-in/sign-in.page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,18 +228,15 @@ describe('SignInPage', () => {
spyOn(component, 'goBack');
component.ionViewWillEnter();
expect(component.hardwareBackButtonAction).toEqual(mockSubscription);
expect(platformHandlerService.registerBackButtonAction).toHaveBeenCalledOnceWith(
BackButtonActionPriority.MEDIUM,
component.goBack
);
expect(platformHandlerService.registerBackButtonAction).toHaveBeenCalledTimes(1);
});

describe('goBack(): ', () => {
it('should navigate to ENTER_EMAIL when current step is ENTER_PASSWORD', () => {
spyOn(component, 'changeState');

component.currentStep = SignInPageState.ENTER_PASSWORD;
component.goBack();
component.goBack(component.currentStep);

expect(component.changeState).toHaveBeenCalledWith(SignInPageState.ENTER_EMAIL);
expect(backButtonService.showAppCloseAlert).not.toHaveBeenCalled();
Expand All @@ -249,7 +246,7 @@ describe('SignInPage', () => {
spyOn(component, 'changeState');

component.currentStep = SignInPageState.SELECT_SIGN_IN_METHOD;
component.goBack();
component.goBack(component.currentStep);

expect(backButtonService.showAppCloseAlert).toHaveBeenCalledTimes(1);
expect(component.changeState).not.toHaveBeenCalled();
Expand All @@ -259,7 +256,7 @@ describe('SignInPage', () => {
spyOn(component, 'changeState');

component.currentStep = SignInPageState.ENTER_EMAIL;
component.goBack();
component.goBack(component.currentStep);

expect(component.changeState).toHaveBeenCalledWith(SignInPageState.SELECT_SIGN_IN_METHOD);
});
Expand Down
9 changes: 6 additions & 3 deletions src/app/auth/sign-in/sign-in.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ export class SignInPage implements OnInit {
await this.loginInfoService.addLoginInfo(deviceInfo.appVersion, new Date());
}

goBack(): void {
switch (this.currentStep) {
goBack(currentStep: SignInPageState): void {
switch (currentStep) {
case SignInPageState.ENTER_EMAIL:
this.changeState(SignInPageState.SELECT_SIGN_IN_METHOD);
break;
Expand All @@ -285,8 +285,11 @@ export class SignInPage implements OnInit {
} else {
this.currentStep = SignInPageState.SELECT_SIGN_IN_METHOD;
}
const fn = (): void => {
this.goBack(this.currentStep);
};
const priority = BackButtonActionPriority.MEDIUM;
this.hardwareBackButtonAction = this.platformHandlerService.registerBackButtonAction(priority, this.goBack);
this.hardwareBackButtonAction = this.platformHandlerService.registerBackButtonAction(priority, fn);
}

changeState(state: SignInPageState): void {
Expand Down
22 changes: 16 additions & 6 deletions src/app/auth/verify/verify.page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { of, throwError } from 'rxjs';
import { apiEouRes } from 'src/app/core/mock-data/extended-org-user.data';
import { getElementBySelector, getTextContent } from 'src/app/core/dom-helpers';
import { VerifyPageState } from './verify.enum';
import { UserEventService } from 'src/app/core/services/user-event.service';

describe('VerifyPage', () => {
let component: VerifyPage;
Expand All @@ -19,12 +20,14 @@ describe('VerifyPage', () => {
let routerAuthService: jasmine.SpyObj<RouterAuthService>;
let authService: jasmine.SpyObj<AuthService>;
let trackingService: jasmine.SpyObj<TrackingService>;
let userEventService: jasmine.SpyObj<UserEventService>;

beforeEach(waitForAsync(() => {
const routerSpy = jasmine.createSpyObj('Router', ['navigate']);
const routerAuthServiceSpy = jasmine.createSpyObj('RouterAuthService', ['emailVerify']);
const authServiceSpy = jasmine.createSpyObj('AuthService', ['newRefreshToken']);
const trackingServiceSpy = jasmine.createSpyObj('TrackingService', ['emailVerified', 'onSignin']);
const userEventServiceSpy = jasmine.createSpyObj('UserEventService', ['logout']);

TestBed.configureTestingModule({
declarations: [VerifyPage],
Expand Down Expand Up @@ -54,6 +57,10 @@ describe('VerifyPage', () => {
},
},
},
{
provide: UserEventService,
useValue: userEventServiceSpy,
},
],
}).compileComponents();

Expand All @@ -63,6 +70,7 @@ describe('VerifyPage', () => {
routerAuthService = TestBed.inject(RouterAuthService) as jasmine.SpyObj<RouterAuthService>;
authService = TestBed.inject(AuthService) as jasmine.SpyObj<AuthService>;
trackingService = TestBed.inject(TrackingService) as jasmine.SpyObj<TrackingService>;
userEventService = TestBed.inject(UserEventService) as jasmine.SpyObj<UserEventService>;
}));

it('should create', () => {
Expand Down Expand Up @@ -107,13 +115,15 @@ describe('VerifyPage', () => {
const error = {
status: 404,
};
const logoutSpy = spyOn(component, 'logout');
component.handleError(error);
expect(router.navigate).toHaveBeenCalledOnceWith([
'/',
'auth',
'pending_verification',
{ orgId: 'orNVthTo2Zyo' },
]);
expect(logoutSpy).toHaveBeenCalledTimes(1);
});
});

it('logout(): should log out the user', () => {
component.logout();
expect(userEventService.logout).toHaveBeenCalledTimes(1);
expect(router.navigate).toHaveBeenCalledOnceWith(['/', 'auth', 'sign_in']);
});
});
11 changes: 9 additions & 2 deletions src/app/auth/verify/verify.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { RouterAuthService } from 'src/app/core/services/router-auth.service';
import { switchMap, tap } from 'rxjs/operators';
import { AuthService } from 'src/app/core/services/auth.service';
import { TrackingService } from '../../core/services/tracking.service';
import { UserEventService } from 'src/app/core/services/user-event.service';

@Component({
selector: 'app-verify',
Expand All @@ -16,7 +17,8 @@ export class VerifyPage implements OnInit {
private routerAuthService: RouterAuthService,
private authService: AuthService,
private router: Router,
private trackingService: TrackingService
private trackingService: TrackingService,
private userEventService: UserEventService
) {}

ngOnInit(): void {
Expand All @@ -43,7 +45,12 @@ export class VerifyPage implements OnInit {
} else if (err.status === 440) {
this.router.navigate(['/', 'auth', 'pending_verification', { hasTokenExpired: true, orgId }]);
} else {
this.router.navigate(['/', 'auth', 'pending_verification', { orgId }]);
this.logout();
}
}

logout(): void {
this.userEventService.logout();
this.router.navigate(['/', 'auth', 'sign_in']);
}
}
1 change: 1 addition & 0 deletions src/app/fyle/dashboard/tasks/tasks-2.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ export function TestCases2(getTestBed) {
});

it('handleEnrollmentSuccess(): should handle enrollment success and trigger subsequent actions', fakeAsync(() => {
spyOn(component, 'doRefresh');
corporateCreditCardExpenseService.clearCache.and.returnValue(of(null));

const mockPopover = {
Expand Down
2 changes: 2 additions & 0 deletions src/app/fyle/dashboard/tasks/tasks.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,8 @@ export class TasksComponent implements OnInit {

await cardAddedModal.present();
await cardAddedModal.onDidDismiss();

this.doRefresh();
});
}

Expand Down

0 comments on commit 7358230

Please sign in to comment.