Skip to content
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
73e8632
Issue #SB-16209 fix: Added fix for collection deeplink issue while sc…
swayangjit Dec 16, 2019
c890307
Issue #SB-16209 merge: Merge pull request #331 from swayangjit/releas…
AmiableAnil Dec 16, 2019
a4eaf9d
Issue #SB-16953 fix: Adding loader before Tnc
NavKumarV Jan 6, 2020
bce781d
Issue #SB-16953 fix: Adding loader before Tnc-2
NavKumarV Jan 6, 2020
258a9cc
Issue #SB-16953 fix: Adding loader before Tnc-3
NavKumarV Jan 7, 2020
a17896d
Issue #SB-16953 merge: Merge pull request #413 from NavKumarV/release…
AmiableAnil Jan 7, 2020
2b7ddb3
Issue #SB-16649 fix: webview update popup
balakrishna-m Jan 7, 2020
5025953
Issue #SB-16649 fix: webview update popup
balakrishna-m Jan 7, 2020
4673189
Issue #SB-16649 merge: Merge pull request #418 from balakrishna10/rel…
swayangjit Jan 7, 2020
586a2ad
Issue: #SB-16926 chore: to additionally send stateId, districtId, dec…
JSDevL Jan 8, 2020
8c53bfe
Issue #SB-16649 fix: Updated the method to fetch the current webview …
swayangjit Jan 8, 2020
398066a
Merge pull request #426 from swayangjit/release-2.5.3
swayangjit Jan 8, 2020
a9ba9ec
Issue: #SB-16926 fix: REVERTED: deviceConfig changes
JSDevL Jan 9, 2020
65ad8ac
Issue: #SB-16926 merge: Merge pull request #424 from arfath-gwl/relea…
swayangjit Jan 9, 2020
3272400
Issue #SB-16942: Updated sunbird-sdk version.
swayangjit Jan 9, 2020
fc6d08e
Issue #SB-16942 merge: Merge pull request #427 from swayangjit/releas…
AmiableAnil Jan 9, 2020
07c59a3
Issue #SB-000 test: Added testcases for popups.
swayangjit Jan 9, 2020
fc80f41
Issue #SB-16649 fix: android web view issue
balakrishna-m Jan 9, 2020
a8a850b
Issue #SB-17157 fix: Fixed location popup issue.
AmiableAnil Jan 9, 2020
fe9b6eb
Issue #SB-16649 fix: android web view issue
balakrishna-m Jan 9, 2020
8021d1b
Issue #SB-16649 merge: Merge pull request #430 from balakrishna10/rel…
swayangjit Jan 9, 2020
6218909
Issue #SB-16649 fix: Update buildconfig reader tagged version.
swayangjit Jan 9, 2020
c9ad1a5
Issue #SB-16649 fix: Updated file-support tagged version.
swayangjit Jan 9, 2020
71734a7
Issue #SB-16649 fix: Merge pull request #431 from swayangjit/release-…
swayangjit Jan 9, 2020
a538b6e
Issue #SB-17157 merge: Merge pull request #429 from AmiableAnil/relea…
swayangjit Jan 9, 2020
8858b39
Merge branch 'release-2.7.0' of https://github.com/Sunbird-Ed/Sunbird…
swayangjit Jan 9, 2020
b8c8cc0
Issue #SB-000 merge: Merge branch 'release-2.5.3' into release-2.6.5
swayangjit Jan 9, 2020
900b88d
Issue #SB-000 merge: Merge pull request #432 from swayangjit/release-…
swayangjit Jan 9, 2020
16d45b2
Issue #SB-17157 fix: removing of hide-header code in tnc page.
NavKumarV Jan 10, 2020
f2c5b38
Issue #SB-17157 merge: Merge pull request #433 from NavKumarV/release…
swayangjit Jan 10, 2020
e731279
Issue #SB-16649 fix: Updated webview version to 68.
swayangjit Jan 10, 2020
641c072
Merge pull request #437 from swayangjit/release-2.6.5
sharathkashyap Jan 10, 2020
0c4a388
Issue: #SB-16926 chore: sdk version bump
JSDevL Jan 10, 2020
545eac0
Issue: #SB-16926 merge: Merge pull request #438 from arfath-gwl/relea…
swayangjit Jan 10, 2020
97025ed
Issue #SB-000 merge: Merge branch 'release-2.6.5' into release-2.7.0
swayangjit Jan 10, 2020
5303184
Issue #SB-000 test: Updated testcases for district mapping.
swayangjit Jan 10, 2020
dbaefd4
Issue #SB-000 merge: Merge branch 'release-2.7.0' of https://github.c…
swayangjit Jan 10, 2020
21afafb
Issue #SB-000 test : Added test cases for popups.
swayangjit Jan 12, 2020
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
32 changes: 32 additions & 0 deletions buildConfig/data/staging/form/form-config_webview_version_get.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"id": "api.form.read",
"params": {
"resmsgid": "cc557f06-5fcf-4feb-919d-627944163857",
"msgid": "f0dcdf53-4949-431c-b804-2dbf21886153",
"status": "successful"
},
"responseCode": "OK",
"result": {
"form": {
"type": "config",
"subtype": "webview_version",
"action": "get",
"component": "*",
"framework": "*",
"data": {
"templateName": "webview_version",
"action": "get",
"fields": [
{
"version": "54"
}
]
},
"created_on": "2020-01-07T10:51:43.203Z",
"last_modified_on": null,
"rootOrgId": "*"
}
},
"ts": "2020-01-07T10:52:04.924Z",
"ver": "1.0"
}
5 changes: 3 additions & 2 deletions build_config
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,20 @@ cordova-plugin=cordova-plugin-file-transfer
cordova-plugin=cordova-plugin-inappbrowser
cordova-plugin=cordova-plugin-network-information
cordova-plugin=cordova-plugin-statusbar
cordova-plugin=cordova-plugin-webview-checker
cordova-plugin=https://github.com/adriano-di-giovanni/cordova-plugin-shared-preferences.git
cordova-plugin=https://github.com/katzer/cordova-plugin-local-notifications.git
cordova-plugin=https://github.com/swayangjit/cordova-plugin-fcm-with-dependecy-updated.git#release-2.6.0
cordova-plugin=cordova-plugin-advanced-http
cordova-plugin=cordova-plugin-android-permissions
cordova-plugin=cordova-plugin-media
cordova-plugin=cordova.plugins.diagnostic
cordova-plugin=https://github.com/swayangjit/cordova-plugin-buildconfig-reader.git
cordova-plugin=https://github.com/swayangjit/cordova-plugin-buildconfig-reader.git#release-2.6.5
cordova-plugin=https://github.com/swayangjit/cordova-plugin-android-downloadmanager.git
cordova-plugin=https://github.com/swayangjit/sb-cordova-plugin-db.git
cordova-plugin=cordova-android-support-gradle-release --variable ANDROID_SUPPORT_VERSION=28.0.0
cordova-plugin=https://github.com/Sunbird-Ed/sb-cordova-plugin-customtabs.git --variable URL_SCHEME=@string/custom_scheme_url --variable URL_HOST=mobile
sunbird-cordova-plugin=https://github.com/project-sunbird/cordova-plugin-openrap.git
sunbird-cordova-plugin=https://github.com/project-sunbird/cordova-plugin-qr-scanner.git
sunbird-cordova-plugin=https://github.com/project-sunbird/cordova-plugin-sunbirdsplash.git#release-2.6.5
sunbird-cordova-plugin=https://github.com/project-sunbird/cordova-plugin-file-support.git
sunbird-cordova-plugin=https://github.com/project-sunbird/cordova-plugin-file-support.git#release-2.6.5
1 change: 1 addition & 0 deletions config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,6 @@
<plugin name="cordova-plugin-qr-scanner" spec="https://github.com/project-sunbird/cordova-plugin-qr-scanner.git" />
<plugin name="cordova-plugin-sunbirdsplash" spec="https://github.com/project-sunbird/cordova-plugin-sunbirdsplash.git#release-2.3.0" />
<plugin name="cordova-plugin-file-support" spec="https://github.com/project-sunbird/cordova-plugin-file-support.git" />
<plugin name="cordova-plugin-webview-checker" spec="^1.0.1" />
<engine name="android" spec="^8.1.0" />
</widget>
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"rxjs": "^6.5.3",
"sb-cordova-plugin-customtabs": "git+https://github.com/Sunbird-Ed/sb-cordova-plugin-customtabs.git",
"sb-cordova-plugin-db": "git+https://github.com/swayangjit/sb-cordova-plugin-db.git",
"sunbird-sdk": "git+https://github.com/Sunbird-Ed/sunbird-mobile-sdk.git#v2.7.5",
"sunbird-sdk": "git+https://github.com/Sunbird-Ed/sunbird-mobile-sdk.git#v2.7.7",
"tslib": "^1.10.0",
"x2js": "^3.3.0",
"zone.js": "~0.8.29"
Expand Down Expand Up @@ -180,7 +180,8 @@
"cordova-android-support-gradle-release": {
"ANDROID_SUPPORT_VERSION": "28.0.0"
},
"cordova-plugin-openrap": {}
"cordova-plugin-openrap": {},
"cordova-plugin-webview-checker": {}
},
"platforms": [
"android"
Expand Down Expand Up @@ -231,4 +232,4 @@
},
"transformIgnorePatterns": []
}
}
}
22 changes: 22 additions & 0 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,26 @@
</ion-row>
</ion-grid>
</div>

<div id="update-webview-container"
style="position: fixed;top: 0;left: 0;right: 0;bottom: 0;z-index: 10;background-color: rgba(0, 0, 0, 0.59);opacity: 1;display: none;">
<div id="update-webview-content"
style="position: fixed;top: 0;left: 0;right: 0;bottom: 0;z-index: 11;width: 80%;height: 195px;background-color: #eee; margin: auto;">
<div style="height:195px;position: relative;">
<div>
<h3
style="text-align: center;background-color: #024f9d; color: #fff;margin: 0;padding: 8px; font-size: 18px;">
{{'UPDATE_REQUIRED' | translate}}
</h3>
</div>
<div style="padding: 15px 0; font-size: 16px; color: #333;width:80%;margin: auto;">
<p style="margin: 0;">{{'WEBVIEW_UPDATE_TEXT' | translate}}</p>
</div>
<div style="position: absolute; width: 100%; bottom: 15px;text-align: center;">
<button (click)="openPlaystore()" style="color: #fff;background: #024f9d;padding: 10px;width: 80%;margin: auto;">{{'DOWNLOAD_NOW' | translate}}</button>
</div>
</div>
</div>
</div>

</ion-app>
39 changes: 35 additions & 4 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,43 @@ export class AppComponent implements OnInit, AfterViewInit {
this.appRatingService.checkInitialDate();
this.getUtmParameter();
this.checkForCodeUpdates();
this.checkAndroidWebViewVersion();
});
}

checkAndroidWebViewVersion() {
var that = this;
plugins['webViewChecker'].getCurrentWebViewPackageInfo()
.then(function(packageInfo) {
that.formAndFrameworkUtilService.getWebviewConfig().then(function(webviewVersion) {
if (parseInt(packageInfo.versionName.split('.')[0], 10) <= webviewVersion) {
document.getElementById('update-webview-container').style.display = 'block';
this.telemetryGeneratorService.generateImpressionTelemetry(
ImpressionType.VIEW, '',
PageId.UPDATE_WEBVIEW_POPUP,
Environment.HOME);
}
}).catch(function(err) {
if (parseInt(packageInfo.versionName.split('.')[0], 10) <= 54) {
document.getElementById('update-webview-container').style.display = 'block';
}
});
})
.catch(function(error) { });
}

openPlaystore() {
plugins['webViewChecker'].openGooglePlayPage()
.then(function() { })
.catch(function(error) { });

this.telemetryGeneratorService.generateInteractTelemetry(
InteractType.TOUCH,
InteractSubtype.UPDATE_WEBVIEW_CLICKED,
Environment.HOME,
PageId.UPDATE_WEBVIEW_POPUP);
}

getSystemConfig() {
const getSystemSettingsRequest: GetSystemSettingsRequest = {
id: SystemSettingsIds.COURSE_FRAMEWORK_ID
Expand Down Expand Up @@ -739,10 +773,7 @@ export class AppComponent implements OnInit, AfterViewInit {
&& !(await this.commonUtilService.isIpLocationAvailable())) {
this.deviceRegisterService.getDeviceProfile().toPromise().then(async (response) => {
if (response.userDeclaredLocation) {
const locationMap = new Map();
locationMap['state'] = response.userDeclaredLocation.state;
locationMap['district'] = response.userDeclaredLocation.district;
await this.preferences.putString(PreferenceKey.DEVICE_LOCATION, JSON.stringify(locationMap)).toPromise();
await this.preferences.putString(PreferenceKey.DEVICE_LOCATION, JSON.stringify(response.userDeclaredLocation)).toPromise();
} else if (response.ipLocation) {
const ipLocationMap = new Map();
if (response.ipLocation.state) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
import { AccountRecoveryInfoComponent } from './account-recovery-id-popup.component';
import { CommonUtilService, TelemetryGeneratorService, AppGlobalService } from '../../../../services';
import { PopoverController, Platform, MenuController } from '@ionic/angular';
import { ImpressionType, Environment, PageId } from '@app/services/telemetry-constants';
import { of, throwError } from 'rxjs';
import { ProfileService } from 'sunbird-sdk';

describe('AccountRecoveryInfoComponent', () => {
let accountRecoveryInfoComponent: AccountRecoveryInfoComponent;

const serverProfileResponse = { response: 'SUCCESS' } as any;
const mockProfileService: Partial<ProfileService> = {
updateServerProfile: jest.fn(() => of(serverProfileResponse)),
};

const mockTelemetryGeneratorService: Partial<TelemetryGeneratorService> = {
generateImpressionTelemetry: jest.fn(),
generateInteractTelemetry: jest.fn()
};

const profile = { uid: '0123456789' } as any;
const mockAppGlobalService: Partial<AppGlobalService> = {
getCurrentUser: jest.fn(() => profile)
};

const mockPlatform: Partial<Platform> = {
};

const mockCommonUtilService: Partial<CommonUtilService> = {
showToast: jest.fn(() => { })
};
const dismissFn = jest.fn(() => Promise.resolve());
const presentFn = jest.fn(() => Promise.resolve());
mockCommonUtilService.getLoader = jest.fn(() => ({
present: presentFn,
dismiss: dismissFn,
}));

const mockPopoverCtrl: Partial<PopoverController> = {
dismiss: jest.fn()
};

const mockMenuController: Partial<MenuController> = {
enable: jest.fn()
};

beforeAll(() => {
accountRecoveryInfoComponent = new AccountRecoveryInfoComponent(
mockProfileService as ProfileService,
mockTelemetryGeneratorService as TelemetryGeneratorService,
mockAppGlobalService as AppGlobalService,
mockCommonUtilService as CommonUtilService,
mockPopoverCtrl as PopoverController,
mockPlatform as Platform,
mockMenuController as MenuController,
);
});

beforeEach(() => {
jest.clearAllMocks();
});

it('should be create a instance of EditContactDetailsPopupComponent', () => {
expect(accountRecoveryInfoComponent).toBeTruthy();
});

it('should generate IMPRESSION telemtry on ngOnInit', () => {
// arrange
accountRecoveryInfoComponent.recoveryPhone = 'phone';
// act
accountRecoveryInfoComponent.ngOnInit();
// assert
expect(accountRecoveryInfoComponent.profile).toEqual({ uid: '0123456789' });
expect(mockTelemetryGeneratorService.generateImpressionTelemetry).toHaveBeenCalledWith(
ImpressionType.VIEW, '',
PageId.RECOVERY_ACCOUNT_ID_POPUP,
Environment.USER
);
expect(mockMenuController.enable).toHaveBeenCalledWith(false);
});

it('should handle the back button in ionViewWillEnter ', () => {
// arrange
const subscribeWithPriorityData = jest.fn((_, fn) => fn());
mockPlatform.backButton = {
subscribeWithPriority: subscribeWithPriorityData,

} as any;

accountRecoveryInfoComponent.unregisterBackButton = {
unsubscribe: jest.fn(),
} as any;

// act
accountRecoveryInfoComponent.ionViewWillEnter();
// assert
expect(mockPopoverCtrl.dismiss).toHaveBeenCalled();
});

it('should enable MenuDrawer and unsubscribe back function', () => {
// arrange
accountRecoveryInfoComponent.unregisterBackButton = {
unsubscribe: jest.fn(),

} as any;
// act
accountRecoveryInfoComponent.ionViewWillLeave();
// assert
expect(mockMenuController.enable).toHaveBeenCalledWith(true);
expect(accountRecoveryInfoComponent.unregisterBackButton.unsubscribe).toHaveBeenCalled();
});

it('should update the server profile successfully', (done) => {
// arrange
accountRecoveryInfoComponent.recoveryPhone = '';
mockCommonUtilService.networkInfo = { isNetworkAvailable: true };
accountRecoveryInfoComponent.recoveryEmailForm = { value: { email: '[email protected]' } } as any;
// act
accountRecoveryInfoComponent.submitRecoveryId(accountRecoveryInfoComponent.RecoveryType.EMAIL);
// assert
setTimeout(() => {
expect(mockPopoverCtrl.dismiss).toHaveBeenCalledWith({ isEdited: true });
expect(mockTelemetryGeneratorService.generateInteractTelemetry).toHaveBeenCalled();
done();
}, 1);
});

it('should handle the error scenario incase of API failure while updating email', (done) => {
// arrange
accountRecoveryInfoComponent.recoveryPhone = '';
mockCommonUtilService.networkInfo = { isNetworkAvailable: true };
accountRecoveryInfoComponent.recoveryEmailForm = { value: { email: '[email protected]' } } as any;
mockProfileService.updateServerProfile = jest.fn(() => throwError(
{ response: { body: { params: { err: 'RECOVERY_PARAM_MATCH_EXCEPTION' } } } }));
// act
accountRecoveryInfoComponent.submitRecoveryId(accountRecoveryInfoComponent.RecoveryType.EMAIL);
// assert
setTimeout(() => {
expect(accountRecoveryInfoComponent.sameEmailErr).toBeTruthy();
done();
}, 1);
});


it('should handle the error scenario incase of API failure while updating phone', (done) => {
// arrange
accountRecoveryInfoComponent.recoveryPhone = 'phone';
mockCommonUtilService.networkInfo = { isNetworkAvailable: true };
accountRecoveryInfoComponent.recoveryEmailForm = { value: { phone: '0123456789' } } as any;
mockProfileService.updateServerProfile = jest.fn(() => throwError(
{ response: { body: { params: { err: 'RECOVERY_PARAM_MATCH_EXCEPTION' } } } }));
// act
accountRecoveryInfoComponent.submitRecoveryId(accountRecoveryInfoComponent.RecoveryType.PHONE);
// assert
setTimeout(() => {
expect(accountRecoveryInfoComponent.samePhoneErr).toBeTruthy();
done();
}, 1);
});

it('should show TOAST in case of unexpected error scenario incase of API failure while updating phone', (done) => {
// arrange
accountRecoveryInfoComponent.recoveryPhone = 'phone';
mockCommonUtilService.networkInfo = { isNetworkAvailable: true };
accountRecoveryInfoComponent.recoveryEmailForm = { value: { phone: '0123456789' } } as any;
mockProfileService.updateServerProfile = jest.fn(() => throwError(
{ response: { body: { params: { err: 'ANY_OTHER_ERROR' } } } }));
// act
accountRecoveryInfoComponent.submitRecoveryId(accountRecoveryInfoComponent.RecoveryType.PHONE);
// assert
setTimeout(() => {
expect(mockCommonUtilService.showToast).toHaveBeenCalledWith('SOMETHING_WENT_WRONG');
done();
}, 1);
});

it('should show NETWORK ERROR popup in case of no network connection', () => {
// arrange
mockCommonUtilService.networkInfo = { isNetworkAvailable: false };
// act
accountRecoveryInfoComponent.submitRecoveryId(accountRecoveryInfoComponent.RecoveryType.PHONE);
// assert
expect(mockCommonUtilService.showToast).toHaveBeenCalledWith('INTERNET_CONNECTIVITY_NEEDED');
});

it('should dismiss the popup when cancel is clicked', () => {
// arrange
// act
accountRecoveryInfoComponent.cancel();
// assert
expect(mockPopoverCtrl.dismiss).toHaveBeenCalledWith({ isEdited: false });
});

it('should reset the error properties', () => {
// arrange
accountRecoveryInfoComponent.sameEmailErr = true;
// act
accountRecoveryInfoComponent.removeSameRecoveryIdErr(accountRecoveryInfoComponent.RecoveryType.EMAIL);
// assert
expect(accountRecoveryInfoComponent.sameEmailErr).toBeFalsy();

// arrange
accountRecoveryInfoComponent.samePhoneErr = true;
// act
accountRecoveryInfoComponent.removeSameRecoveryIdErr(accountRecoveryInfoComponent.RecoveryType.PHONE);
// assert
expect(accountRecoveryInfoComponent.samePhoneErr).toBeFalsy();
});


});
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ export class AccountRecoveryInfoComponent implements OnInit {
this.telemetryGeneratorService.generateImpressionTelemetry(
ImpressionType.VIEW, '',
PageId.RECOVERY_ACCOUNT_ID_POPUP,
Environment.USER, '', '', '',
undefined,
undefined
Environment.USER
);
}

Expand Down
Loading