Skip to content
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
2 changes: 1 addition & 1 deletion build_config
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ cordova-plugin=cordova-plugin-document-viewer
cordova-plugin=com-sarriaroman-photoviewer
cordova-plugin=https://github.com/shikshalokam/cordova-plugin-filepath.git
cordova-plugin=https://github.com/greybax/cordova-plugin-proguard.git
cordova-plugin=https://github.com/Sunbird-Ed/sb-cordova-plugin-utility.git#release-4.1.0
cordova-plugin=https://github.com/Sunbird-Ed/sb-cordova-plugin-utility/tree/release-6.0.0
cordova-plugin=https://github.com/Sunbird-Ed/sb-cordova-plugin-downloadmanager.git
cordova-plugin=https://github.com/Sunbird-Ed/sb-cordova-plugin-db.git#release-4.6.0
cordova-plugin=https://github.com/Sunbird-Ed/sb-cordova-plugin-customtabs#release-5.0.2 --variable URL_SCHEME=@string/custom_scheme_url --variable URL_HOST=mobile
Expand Down
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
</plugin>
<plugin name="com.telerik.plugins.nativepagetransitions" spec="^0.6.5" />
<plugin name="cordova-plugin-proguard" spec="https://github.com/greybax/cordova-plugin-proguard.git" />
<plugin name="sb-cordova-plugin-utility" spec="https://github.com/Sunbird-Ed/sb-cordova-plugin-utility.git#release-3.1.0" />
<plugin name="sb-cordova-plugin-utility" spec="https://github.com/Sunbird-Ed/sb-cordova-plugin-utility.git#release-6.0.0" />
<plugin name="cordova-plugin-android-downloadmanager" spec="https://github.com/Sunbird-Ed/sb-cordova-plugin-downloadmanager.git" />
<plugin name="sb-cordova-plugin-db" spec="https://github.com/Sunbird-Ed/sb-cordova-plugin-db.git#release-3.1.0" />
<plugin name="sb-cordova-plugin-customtabs" spec="https://github.com/Sunbird-Ed/sb-cordova-plugin-customtabs.git">
Expand Down
650 changes: 393 additions & 257 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"@project-sunbird/sunbird-epub-player-v9": "5.2.1",
"@project-sunbird/sunbird-pdf-player-v9": "5.1.1",
"@project-sunbird/sunbird-quml-player-web-component": "3.0.3",
"@project-sunbird/sunbird-sdk": "7.0.18",
"@project-sunbird/sunbird-sdk": "7.0.19",
"@project-sunbird/sunbird-video-player-web-component": "^1.0.1",
"chart.js": "^2.9.4",
"chartjs-plugin-datalabels": "^0.7.0",
Expand All @@ -87,7 +87,6 @@
"com.jjdltc.cordova.plugin.zip": "git+https://github.com/Sunbird-Ed/jjdltc-cordova-plugin-zip.git",
"cordova-plugin-badge": "^0.8.8",
"core-js": "^3.23.3",
"crypto-browserify": "^3.12.0",
"datatables.net-dt": "^1.13.4",
"datatables.net-fixedcolumns": "^3.3.3",
"dayjs": "1.9.8",
Expand Down Expand Up @@ -116,10 +115,8 @@
"pouchdb-find": "^7.2.2",
"rxjs": "^6.6.3",
"sb-tag-manager": "^3.9.19",
"stream-browserify": "^3.0.0",
"ts-jest": "^28.0.8",
"tslib": "^2.0.0",
"util": "^0.12.5",
"uuid": "^3.4.0",
"video.js": "7.18.1",
"videojs-contrib-quality-levels": "2.1.0",
Expand Down Expand Up @@ -219,7 +216,7 @@
"sb-cordova-plugin-customtabs": "git+https://github.com/Sunbird-Ed/sb-cordova-plugin-customtabs.git#release-5.0.2",
"sb-cordova-plugin-db": "git+https://github.com/Sunbird-Ed/sb-cordova-plugin-db.git#release-4.6.0",
"sb-cordova-plugin-sync": "git+https://github.com/project-sunbird/sb-cordova-plugin-sync.git",
"sb-cordova-plugin-utility": "git+https://github.com/Sunbird-Ed/sb-cordova-plugin-utility.git#release-4.1.0",
"sb-cordova-plugin-utility": "git+https://github.com/Sunbird-Ed/sb-cordova-plugin-utility.git#release-6.0.0",
"sonarqube-scanner": "^2.5.0",
"tiny-glob": "^0.2.9",
"ts-node": "^10.9.1",
Expand Down
25 changes: 18 additions & 7 deletions src/app/collection-detail-etb/collection-detail-etb-page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
DownloadService,
EventsBusService,
ProfileService,
ProfileSource,
ProfileType,
StorageService,
TelemetryErrorCode,
TelemetryObject
Expand Down Expand Up @@ -47,7 +49,9 @@ import { SegmentationTagService } from '../../services/segmentation-tag/segmenta

describe('collectionDetailEtbPage', () => {
let collectionDetailEtbPage: CollectionDetailEtbPage;
const mockContentService: Partial<ContentService> = {};
const mockContentService: Partial<ContentService> = {
getChildContents: jest.fn(() => of())
};
const mockEventBusService: Partial<EventsBusService> = {};
const mockDownloadService: Partial<DownloadService> = {};
const mockProfileService: Partial<ProfileService> = {
Expand All @@ -68,7 +72,8 @@ describe('collectionDetailEtbPage', () => {

const mockappGlobalService: Partial<AppGlobalService> = {
isUserLoggedIn: jest.fn(() => true),
getCurrentUser: jest.fn()
getCurrentUser: jest.fn(() => ({uid: 'sample-uid', handle: '', profileType: ProfileType.NONE, source: ProfileSource.LOCAL})),
getCachedFrameworkCategory: jest.fn(() => ({value: [{index: 2}, {index: 1}]}))
};
const mockCommonUtilService: Partial<CommonUtilService> = {
networkInfo: {} as any,
Expand Down Expand Up @@ -235,6 +240,7 @@ describe('collectionDetailEtbPage', () => {
mockIonContent.ionScroll.subscribe = jest.fn((fn) => {
fn({});
});
mockappGlobalService.getCurrentUser = jest.fn(() => ({uid: 'sample_id'})) as any
mockHeaderService.showStatusBar = jest.fn();
jest.spyOn(mockHeaderService, 'getDefaultPageConfig').mockReturnValue({
showHeader: false,
Expand Down Expand Up @@ -277,15 +283,16 @@ describe('collectionDetailEtbPage', () => {
// arrange
mockappGlobalService.getCurrentUser = jest.fn(() => ({
uid: 'sample-uid'
}));
}))as any;
collectionDetailEtbPage.profile = {uid: 'sample-uid'} as any
mockProfileService.addContentAccess = jest.fn(() => of(true));
mockevents.publish = jest.fn();
mockContentService.setContentMarker = jest.fn(() => of(true));
// act
collectionDetailEtbPage.markContent();
// assert
setTimeout(() => {
expect(mockappGlobalService.getCurrentUser).toHaveBeenCalled();
// expect(mockappGlobalService.getCurrentUser).toHaveBeenCalled();
expect(mockProfileService.addContentAccess).toHaveBeenCalledWith({
contentId: 'do_212911645382959104165',
contentType: 'Course',
Expand All @@ -310,14 +317,15 @@ describe('collectionDetailEtbPage', () => {
// arrange
mockappGlobalService.getCurrentUser = jest.fn(() => ({
uid: 'sample-uid'
}));
})) as any;
collectionDetailEtbPage.profile = {uid: 'sample-uid'} as any
mockProfileService.addContentAccess = jest.fn(() => of(false));
mockContentService.setContentMarker = jest.fn(() => of(true));
// act
collectionDetailEtbPage.markContent();
// assert
setTimeout(() => {
expect(mockappGlobalService.getCurrentUser).toHaveBeenCalled();
// expect(mockappGlobalService.getCurrentUser).toHaveBeenCalled();
expect(mockProfileService.addContentAccess).toHaveBeenCalledWith({
contentId: 'do_212911645382959104165',
contentType: 'Course',
Expand All @@ -344,6 +352,7 @@ describe('collectionDetailEtbPage', () => {
// arrange
jest.spyOn(collectionDetailEtbPage, 'registerDeviceBackButton').mockImplementation();
mockzone.run = jest.fn((fn) => fn());
mockappGlobalService.getCurrentUser = jest.fn(() => ({uid: 'sample_id'})) as any
const mockHeaderEventsSubscription = { unsubscribe: jest.fn() } as Partial<Subscription>;
mockHeaderService.headerEventEmitted$ = {
subscribe: jest.fn((fn) => fn(mockHeaderEventsSubscription) as any)
Expand Down Expand Up @@ -392,6 +401,7 @@ describe('collectionDetailEtbPage', () => {
// arrange
jest.spyOn(collectionDetailEtbPage, 'registerDeviceBackButton').mockImplementation();
mockzone.run = jest.fn((fn) => fn());
mockappGlobalService.getCurrentUser = jest.fn(() => ({uid: 'sample_id'})) as any
const mockHeaderEventsSubscription = { unsubscribe: jest.fn() } as Partial<Subscription>;
mockHeaderService.headerEventEmitted$ = {
subscribe: jest.fn((fn) => mockHeaderEventsSubscription as any)
Expand Down Expand Up @@ -577,13 +587,14 @@ describe('collectionDetailEtbPage', () => {

it('should return content marker', () => {
// arrange
collectionDetailEtbPage.profile = {uid: 'sample-uid'} as any
mockappGlobalService.getCurrentUser = jest.fn(() => ({ uid: 'sample-uid' }));
mockProfileService.addContentAccess = jest.fn(() => of(true));
mockContentService.setContentMarker = jest.fn(() => of(true));
// act
collectionDetailEtbPage.markContent();
// assert
expect(mockappGlobalService.getCurrentUser).toHaveBeenCalled();
// expect(mockappGlobalService.getCurrentUser).toHaveBeenCalled();
expect(mockProfileService.addContentAccess).toHaveBeenCalled();
expect(mockContentService.setContentMarker).toHaveBeenCalled();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ describe('SbAppSharePopupComponent', () => {
dismiss: jest.fn()
};
const mockPlatform: Partial<Platform> = {
is: jest.fn()
is: jest.fn(),
backButton: {
subscribeWithPriority: jest.fn((_, fn) => fn({
unsubscribe: jest.fn()
})),
} as any
};
const mocksocialSharing: Partial<SocialSharing> = {
share: jest.fn()
Expand Down Expand Up @@ -152,14 +157,17 @@ describe('SbAppSharePopupComponent', () => {
});
});

it('should populate apk size and shareUrl', () => {
it('should populate apk size and shareUrl', (done) => {
// arrange
const unsubscribeFn = jest.fn();
mockPlatform.backButton = {
subscribeWithPriority: jest.fn((_, fn) => fn()),
} as any;
sbAppSharePopupComponent.backButtonFunc = {
unsubscribe: unsubscribeFn
subscribeWithPriority: jest.fn((_, cb) => {
setTimeout(() => {
cb();
}, 0);
return {
unsubscribe: jest.fn()
};
}),
} as any;
// act
sbAppSharePopupComponent.ngOnInit();
Expand All @@ -174,17 +182,21 @@ describe('SbAppSharePopupComponent', () => {
expect(sbAppSharePopupComponent.shareUrl).toEqual(
'https://play.google.com/store/apps/details?id=org.sunbird.' +
'app&referrer=utm_source%3Dmobile%26utm_campaign%3Dshare_app');
done()
}, 0);
});

it('should not brek if getAPKSize() gives error response', () => {
it('should not brek if getAPKSize() gives error response', (done) => {
// arrange
const unsubscribeFn = jest.fn();
mockPlatform.backButton = {
subscribeWithPriority: jest.fn((_, fn) => fn()),
} as any;
sbAppSharePopupComponent.backButtonFunc = {
unsubscribe: unsubscribeFn
subscribeWithPriority: jest.fn((_, cb) => {
setTimeout(() => {
cb();
}, 0);
return {
unsubscribe: jest.fn()
};
}),
} as any;

mockUtilityService.getApkSize = jest.fn(() => Promise.reject({}));
Expand All @@ -201,6 +213,7 @@ describe('SbAppSharePopupComponent', () => {
expect(sbAppSharePopupComponent.shareUrl).toEqual(
'https://play.google.com/store/apps/details?id=org.sunbird.' +
'app&referrer=utm_source%3Dmobile%26utm_campaign%3Dshare_app');
done()
}, 0);
});

Expand Down Expand Up @@ -232,14 +245,14 @@ describe('SbAppSharePopupComponent', () => {
// arrange
mockPopoverCtrl.dismiss = jest.fn();
sbAppSharePopupComponent.shareUrl = 'sample_url';
const url = `Get Sunbird from the Play Store:` + '\n' + 'sample_url';
mockCommonUtilService.translateMessage = jest.fn(() => url);
// const url = `Get Sunbird from the Play Store:` + '\n' + 'sample_url';
mockCommonUtilService.translateMessage = jest.fn(() => 'sample_url');
mockPlatform.is = jest.fn((fn) => fn == "android");
// act
sbAppSharePopupComponent.shareLink();
// assert
setTimeout(() => {
expect(mocksocialSharing.share).toHaveBeenCalledWith(null, null, null, url);
expect(mocksocialSharing.share).toHaveBeenCalledWith(null, null, null, 'sample_url');
expect(mockTelemetryGeneratorService.generateInteractTelemetry).toHaveBeenCalledWith(ShareMode.SHARE,
'',
Environment.SETTINGS,
Expand Down Expand Up @@ -341,6 +354,7 @@ describe('SbAppSharePopupComponent', () => {
undefined, undefined, undefined, undefined,
ID.SHARE_CONFIRM);
expect(mockPopoverCtrl.dismiss).toHaveBeenCalled();
done()
}, 0);
});

Expand All @@ -362,6 +376,7 @@ describe('SbAppSharePopupComponent', () => {
setTimeout(() => {
expect(mockCommonUtilService.buildPermissionPopover).toHaveBeenCalled();
expect(presentFN).toHaveBeenCalled();
done()
}, 0);
});

Expand Down Expand Up @@ -411,6 +426,7 @@ describe('SbAppSharePopupComponent', () => {
undefined, undefined, undefined, undefined,
ID.SHARE_CONFIRM);
expect(mockCommonUtilService.getGivenPermissionStatus).toHaveBeenCalled();
done()
}, 0);
});
it('should call permission popup on saveFile if not given', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import {
CourseUtilService, AppGlobalService, TelemetryGeneratorService,
CommonUtilService, UtilityService, AppHeaderService,
LocalCourseService, PageId, InteractType
LocalCourseService, PageId, InteractType, FormAndFrameworkUtilService
} from '../../services';
import { NgZone } from '@angular/core';
import { PopoverController, Platform } from '@ionic/angular';
Expand Down Expand Up @@ -139,6 +139,10 @@ describe('EnrolledCourseDetailsPage', () => {
getForumIds: jest.fn()
};

const mockFormAndFrameworkUtilService: Partial<FormAndFrameworkUtilService> = {
invokedGetFrameworkCategoryList: jest.fn(() => Promise.resolve())
}

global.window['segmentation'] = {
init: jest.fn(),
SBTagService: {
Expand Down Expand Up @@ -178,7 +182,8 @@ describe('EnrolledCourseDetailsPage', () => {
mockSbProgressLoader as SbProgressLoader,
mockCategoryKeyTranslator as CategoryKeyTranslator,
mockConsentService as ConsentService,
mockTncUpdateHandlerService as TncUpdateHandlerService
mockTncUpdateHandlerService as TncUpdateHandlerService,
mockFormAndFrameworkUtilService as FormAndFrameworkUtilService
);
});

Expand Down Expand Up @@ -2698,7 +2703,8 @@ describe('EnrolledCourseDetailsPage', () => {
jest.spyOn(enrolledCourseDetailsPage, 'handleHeaderEvents').mockImplementation(() => {
return Promise.resolve();
});
mockProfileService.getActiveSessionProfile = jest.fn(() => of(mockProfileData));
mockProfileService.getActiveSessionProfile = jest.fn(() => of(mockProfileData)) as any;
mockFormAndFrameworkUtilService.invokedGetFrameworkCategoryList = jest.fn(() => Promise.resolve([{index: 2}, {index: 1}]))
// assert
enrolledCourseDetailsPage.ionViewWillEnter().then(() => {
expect(mockAppGlobalService.getActiveProfileUid).toHaveBeenCalled();
Expand Down Expand Up @@ -2744,6 +2750,7 @@ describe('EnrolledCourseDetailsPage', () => {
mockCourseService.getEnrolledCourses = jest.fn(() => of(mockEnrolledCourses));
mockHeaderService.showHeaderWithBackButton = jest.fn();
mockProfileService.getActiveSessionProfile = jest.fn(() => of(mockProfileData));
mockFormAndFrameworkUtilService.invokedGetFrameworkCategoryList = jest.fn(() => Promise.resolve([{index: 2}, {index: 1}]))
// act
enrolledCourseDetailsPage.ionViewWillEnter();
// assert
Expand Down Expand Up @@ -3103,4 +3110,18 @@ describe('EnrolledCourseDetailsPage', () => {
expect(mockRouter.navigate).toHaveBeenCalled()
});
});

describe('getFrameworkCategory', () => {
it('should get framework category', (done) => {
// arrange
mockFormAndFrameworkUtilService.invokedGetFrameworkCategoryList = jest.fn(() => Promise.resolve([{index: 2}, {index: 1}]))
// act
enrolledCourseDetailsPage.getFrameworkCategory()
// assert
setTimeout(() => {
expect(mockFormAndFrameworkUtilService.invokedGetFrameworkCategoryList).toHaveBeenCalled();
done();
}, 0);
})
})
});
Loading