Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Issue #ED-76 fix:"Header fix on native login" #3181

Merged
merged 2 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions src/app/sign-in/sign-in.page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ describe('SignInPage', () => {
};
const mockAppHeaderService: Partial<AppHeaderService> = {
hideHeader: jest.fn(),
showStatusBar: jest.fn()
showStatusBar: jest.fn(),
hideStatusBar: jest.fn(),
showHeaderWithHomeButton: jest.fn()
};
const mockCommonUtilService: Partial<CommonUtilService> = {
getAppName: jest.fn(),
Expand Down Expand Up @@ -83,10 +85,6 @@ describe('SignInPage', () => {
const mockAppGlobalService: Partial<AppGlobalService> = {
resetSavedQuizContent: jest.fn()
}
const mockStatusBar: Partial<StatusBar> = {
styleDefault: jest.fn(),
backgroundColorByHexString: jest.fn()
};
const mockLoginHandlerService: Partial<LoginHandlerService> = {};
window.cordova.plugins = {
Keyboard: { hideKeyboardAccessoryBar: jest.fn() }
Expand All @@ -106,8 +104,7 @@ describe('SignInPage', () => {
mockLocation as Location,
mockSignInWithApple as SignInWithApple,
mockPlatform as Platform,
mockAppGlobalService as AppGlobalService,
mockStatusBar as StatusBar
mockAppGlobalService as AppGlobalService
);
});

Expand Down Expand Up @@ -136,23 +133,24 @@ describe('SignInPage', () => {
describe('ionViewWillEnter', () => {
it('should set status bar background white and default style', () => {
// arrange
mockStatusBar.backgroundColorByHexString = jest.fn()
mockAppHeaderService.hideStatusBar = jest.fn()
// act
signInPage.ionViewWillEnter();
// assert
expect(mockStatusBar.backgroundColorByHexString).toHaveBeenCalledWith('#FFFFFF');
expect(mockStatusBar.styleDefault).toHaveBeenCalled();
expect(mockAppHeaderService.hideStatusBar).toHaveBeenCalled();
})
});

describe('ionViewWillLeave', () => {
it('should show status bar before view will leave', () => {
// arrange
mockAppHeaderService.showStatusBar = jest.fn(() => Promise.resolve());
mockAppHeaderService.showHeaderWithHomeButton = jest.fn(() => Promise.resolve());
// act
signInPage.ionViewWillLeave();
// assert
expect(mockAppHeaderService.showStatusBar).toHaveBeenCalled();
expect(mockAppHeaderService.showHeaderWithHomeButton).toHaveBeenCalled();
})
});

Expand Down
7 changes: 2 additions & 5 deletions src/app/sign-in/sign-in.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
WebviewSessionProviderConfig,
WebviewLoginSessionProvider,
NativeGoogleSessionProvider,
AuthService,
SystemSettingsService,
SignInError,
SharedPreferences,
Expand All @@ -35,7 +34,6 @@ import {
} from '@ionic-native/sign-in-with-apple/ngx';
import { Platform } from '@ionic/angular';
import { FieldConfig } from 'common-form-elements';
import { StatusBar } from '@ionic-native/status-bar/ngx';

@Component({
selector: 'app-sign-in',
Expand Down Expand Up @@ -64,7 +62,6 @@ export class SignInPage implements OnInit {
private signInWithApple: SignInWithApple,
public platform: Platform,
private appGlobalService: AppGlobalService,
private statusBar: StatusBar,
) {
const extrasData = this.router.getCurrentNavigation().extras.state;
this.skipNavigation = extrasData;
Expand All @@ -76,12 +73,12 @@ export class SignInPage implements OnInit {
}

ionViewWillEnter() {
this.statusBar.backgroundColorByHexString('#FFFFFF');
this.statusBar.styleDefault();
this.appHeaderService.hideStatusBar();
}

ionViewWillLeave() {
this.appHeaderService.showStatusBar();
this.appHeaderService.showHeaderWithHomeButton(['download', 'notification'])
}

async ngOnInit() {
Expand Down