diff --git a/src/app/content-details/content-details.page.html b/src/app/content-details/content-details.page.html index 0ab4805a16..5fddbf9631 100644 --- a/src/app/content-details/content-details.page.html +++ b/src/app/content-details/content-details.page.html @@ -61,14 +61,14 @@
+ *ngIf="!contentDownloadPlay">

{{'PLAY' | translate}}

+ *ngIf="contentDownloadPlay"> diff --git a/src/app/content-details/content-details.page.spec.ts b/src/app/content-details/content-details.page.spec.ts index d8ee19e9da..33967543d7 100644 --- a/src/app/content-details/content-details.page.spec.ts +++ b/src/app/content-details/content-details.page.spec.ts @@ -60,7 +60,7 @@ describe('ContentDetailsPage', () => { addContentAccess: jest.fn(() => of()) }; const mockContentService: Partial = { - getContentDetails: jest.fn(() => of({ contentData: { size: '12KB', status: 'Retired' } })), + getContentDetails: jest.fn(() => of({ contentData: { size: '12KB', status: 'Retired' }, mimeType: 'application/vnd.ekstep.ecml-archive' })), setContentMarker: jest.fn(() => of()) } as any; const mockEventBusService: Partial = {}; @@ -150,7 +150,9 @@ describe('ContentDetailsPage', () => { }; const mockPlayerService: Partial = {}; const mockSantizer: Partial = {}; - const mockScreenOrientation: Partial = {}; + const mockScreenOrientation: Partial = { + ORIENTATIONS: {PORTRAIT: 'portrait'} + } as any; beforeAll(() => { contentDetailsPage = new ContentDetailsPage( @@ -2815,9 +2817,7 @@ describe('ContentDetailsPage', () => { it('should get extras from content || navigation when getExtras() called', (done) => { // arrange - // contentDetailsPage.content = mockContentData.extras.state; mockRouter.getCurrentNavigation = jest.fn(() => mockContentData); - // jest.spyOn(contentDetailsPage, 'getNavParams'); jest.spyOn(contentDetailsPage, 'checkLimitedContentSharingFlag').mockImplementation(() => { return {}; }); @@ -2832,7 +2832,6 @@ describe('ContentDetailsPage', () => { contentDetailsPage.getNavParams(); // assert setTimeout(() => { - // expect(contentDetailsPage.getNavParams).toHaveBeenCalled(); done(); }, 0); }); @@ -2849,13 +2848,13 @@ describe('ContentDetailsPage', () => { } called[topic] = true; if (topic === EventTopics.DEEPLINK_CONTENT_PAGE_OPEN) { - fn({ content: {} }); + fn({ content: {mimeType: 'application/vnd.ekstep.ecml-archive'} }); } if (topic === EventTopics.PLAYER_CLOSED) { fn({ selectedUser: 'sampleUser' }); } if (topic === EventTopics.NEXT_CONTENT) { - fn({ data: 'sample_data' }); + fn({content: {mimeType: 'application/vnd.ekstep.ecml-archive' }}); } }); mockRatingHandler.resetRating = jest.fn(); @@ -2864,11 +2863,12 @@ describe('ContentDetailsPage', () => { mockProfileService.getActiveProfileSession = jest.fn(() => of({ uid: 'sample_uid', sid: 'sample_session_id', createdTime: Date.now() })); mockProfileSwitchHandler.switchUser = jest.fn(); - jest.spyOn(contentDetailsPage, 'calculateAvailableUserCount').mockImplementation(); - jest.spyOn(contentDetailsPage, 'generateEndEvent').mockImplementation(); - jest.spyOn(contentDetailsPage, 'getNavParams').mockImplementation(() => { - return Promise.resolve(); - }); + mockProfileService.getAllProfiles = jest.fn(() => of([{ + uid: 'SAMPLE_UID', + handle: 'SAMPLE_HANDLE', + profileType: 'student', + source: 'local' + }])); mockEvents.unsubscribe = jest.fn((topic) => { console.log(topic); called[topic] = false; @@ -2949,11 +2949,24 @@ describe('ContentDetailsPage', () => { it('should call subscribeEvents when ngOnInit() invoked', (done) => { // arrange - jest.spyOn(contentDetailsPage, 'subscribeEvents').mockImplementation(() => { - return; - }); - jest.spyOn(mockContentService, 'getContentDetails').mockResolvedValue(of({ contentData: { size: '12KB', status: 'Retired' } })); - + const called: { [topic: EventTopics]: boolean } = {}; + mockEvents.subscribe = jest.fn((topic, fn) => { + if (called[topic]) { + return; + } + called[topic] = true; + if (topic === EventTopics.DEEPLINK_CONTENT_PAGE_OPEN) { + fn({ content: {mimeType: 'application/vnd.ekstep.ecml-archive'} }); + } + if (topic === EventTopics.PLAYER_CLOSED) { + fn({ selectedUser: 'sampleUser' }); + } + if (topic === EventTopics.NEXT_CONTENT) { + fn({ content: {mimeType: 'application/vnd.ekstep.ecml-archive' }}); + } + }) + mockContentService.getContentDetails = jest.fn(() => of({ contentData: { size: '12KB', status: 'Retired' }, mimeType: 'application/vnd.ekstep.ecml-archive' })) as any; + mockProfileService.getActiveProfileSession = jest.fn(() => of()) const dismissFn = jest.fn(() => Promise.resolve()); const presentFn = jest.fn(() => Promise.resolve()); mockCommonUtilService.getLoader = jest.fn(() => ({ @@ -2975,7 +2988,6 @@ describe('ContentDetailsPage', () => { contentDetailsPage.ngOnInit(); // assert setTimeout(() => { - expect(contentDetailsPage.subscribeEvents).toHaveBeenCalled(); expect(mockFormFrameworkUtilService.getFormFields).toHaveBeenCalled(); done(); }, 0); @@ -3022,7 +3034,7 @@ describe('ContentDetailsPage', () => { rollUp: { l1: 'do_123', l2: 'do_123', l3: 'do_1' } }; const contentId = contentDetailsPage.content.identifier; - mockAppGlobalService.getCurrentUser = jest.fn(() => ({uid: 'user_id'})); + mockAppGlobalService.getCurrentUser = jest.fn(() => ({uid: 'user_id'})) as any; if(event.edata['type'] === 'END') { mockPlayerService.savePlayerState = jest.fn(() => of()); contentDetailsPage.isPlayerPlaying = false; @@ -3045,7 +3057,7 @@ describe('ContentDetailsPage', () => { rollUp: { l1: 'do_123', l2: 'do_123', l3: 'do_1' } }; const contentId = contentDetailsPage.content.identifier; - mockAppGlobalService.getCurrentUser = jest.fn(() => ({uid: 'user_id'})); + mockAppGlobalService.getCurrentUser = jest.fn(() => ({uid: 'user_id'})) as any; if(event.edata['type'] === 'EXIT') { mockPlayerService.deletePlayerSaveState = jest.fn(() => of()); mockScreenOrientation.type = 'landscape-primary'; @@ -3117,6 +3129,7 @@ describe('ContentDetailsPage', () => { isContentDisabled: event.edata.maxLimitExceeded, isLastAttempt: event.edata.isLastAttempt }; + mockAppGlobalService.getCurrentUser = jest.fn(() => ({uid: 'user_id'})) as any; mockCommonUtilService.handleAssessmentStatus = jest.fn(() => of()); // act contentDetailsPage.playerEvents(event); @@ -3139,6 +3152,7 @@ describe('ContentDetailsPage', () => { } else if (mockScreenOrientation.type == 'landscape-primary') { mockScreenOrientation.lock = jest.fn(() => Promise.resolve()); } + mockAppGlobalService.getCurrentUser = jest.fn(() => ({uid: 'user_id'})) as any; // act contentDetailsPage.playerEvents(event); // assert @@ -3165,10 +3179,20 @@ describe('ContentDetailsPage', () => { }); it('should check on type REPLAY', () => { // arrange + mockAppGlobalService.getCurrentUser = jest.fn(() => ({uid: 'user_id'})) as any; const event = {edata: '', type: ''}; // act contentDetailsPage.playerEvents(event); // assert }); }); + + describe('downloadAndPlayContents', () => { + it('should download the content with mimetype ', () => { + // arrange + // act + contentDetailsPage.downloadAndPlayContents({mimeType: 'application/vnd.ekstep.ecml-archive'}) + // assert + }) + }) }); \ No newline at end of file diff --git a/src/app/content-details/content-details.page.ts b/src/app/content-details/content-details.page.ts index 8cbe0a4a2a..f3e36f8cd7 100644 --- a/src/app/content-details/content-details.page.ts +++ b/src/app/content-details/content-details.page.ts @@ -197,6 +197,8 @@ export class ContentDetailsPage implements OnInit, OnDestroy { showMoreFlag: any = false; navigateBackFlag = false; @ViewChild('video') video: ElementRef | undefined; + contentDownloadPlay = false; + mimeTypesDownloadAndPlay = ['application/vnd.ekstep.h5p-archive', 'application/vnd.ekstep.ecml-archive'] constructor( @Inject('PROFILE_SERVICE') private profileService: ProfileService, @@ -347,6 +349,7 @@ export class ContentDetailsPage implements OnInit, OnDestroy { this.events.subscribe(EventTopics.NEXT_CONTENT, async (data) => { this.generateEndEvent(); this.content = data.content; + this.downloadAndPlayContents(this.content); this.course = data.course; await this.getNavParams(); setTimeout(() => { @@ -559,6 +562,7 @@ export class ContentDetailsPage implements OnInit, OnDestroy { } this.content = data; + this.downloadAndPlayContents(this.content); if (data.contentData.licenseDetails && Object.keys(data.contentData.licenseDetails).length) { this.licenseDetails = data.contentData.licenseDetails; } @@ -1528,6 +1532,7 @@ export class ContentDetailsPage implements OnInit, OnDestroy { content.contentData.status === ContentFilterConfig.CONTENT_STATUS_UNLISTED); if (this.limitedShareContentFlag) { this.content = content; + this.downloadAndPlayContents(this.content); this.playingContent = content; this.identifier = content.contentId || content.identifier; this.telemetryObject = ContentUtil.getTelemetryObject(content); @@ -1751,4 +1756,13 @@ export class ContentDetailsPage implements OnInit, OnDestroy { }, 100); } } + + downloadAndPlayContents(content: any) { + this.contentDownloadPlay = false + this.mimeTypesDownloadAndPlay.forEach(mimetype => { + if(mimetype === content.mimeType) { + this.contentDownloadPlay = true + } + }) + } } diff --git a/src/app/curriculum-courses/chapter-details/chapter-details.page.spec.ts b/src/app/curriculum-courses/chapter-details/chapter-details.page.spec.ts index aacd23c4c0..a8b4fca287 100644 --- a/src/app/curriculum-courses/chapter-details/chapter-details.page.spec.ts +++ b/src/app/curriculum-courses/chapter-details/chapter-details.page.spec.ts @@ -32,7 +32,9 @@ describe('ChapterDetailsPage', () => { let chapterDetailsPage: ChapterDetailsPage; const mockProfileService: Partial = {}; - const mockAppHeaderService: Partial = {}; + const mockAppHeaderService: Partial = { + hideHeader: jest.fn() + }; const mockCommonUtilService: Partial = {}; const mockRouter: Partial = { getCurrentNavigation: jest.fn(() => ({ diff --git a/src/app/profile/categories-edit/categories-edit.page.spec.ts b/src/app/profile/categories-edit/categories-edit.page.spec.ts index 95cdadc025..c371c9df8b 100644 --- a/src/app/profile/categories-edit/categories-edit.page.spec.ts +++ b/src/app/profile/categories-edit/categories-edit.page.spec.ts @@ -2,12 +2,16 @@ import { CategoriesEditPage } from './categories-edit.page'; import { FrameworkService, FrameworkUtilService, - ProfileService + ProfileService, + CachedItemRequestSourceFrom, + Framework, FrameworkCategoryCodesGroup, + GetSuggestedFrameworksRequest, SharedPreferences, + UpdateServerProfileInfoRequest } from '@project-sunbird/sunbird-sdk'; import { TranslateService } from '@ngx-translate/core'; import { Platform } from '@ionic/angular'; import { Events } from '../../../util/events'; -import { Router, ActivatedRoute, NavigationExtras } from '@angular/router'; +import { Router, ActivatedRoute } from '@angular/router'; import { AppGlobalService, CommonUtilService, @@ -23,8 +27,7 @@ import { ProfileHandler } from '../../services/profile-handler'; import { SbProgressLoader } from '../../../services/sb-progress-loader.service'; import { ExternalIdVerificationService } from '../../services/externalid-verification.service'; import { TncUpdateHandlerService } from '../../services/handlers/tnc-update-handler.service'; -import { of, throwError } from 'rxjs'; -import { CachedItemRequestSourceFrom, Framework, FrameworkCategoryCodesGroup, GetSuggestedFrameworksRequest, SharedPreferences, UpdateServerProfileInfoRequest } from '@project-sunbird/sunbird-sdk'; +import { of } from 'rxjs'; import { PreferenceKey, ProfileConstants, RouterLinks } from '../../app.constant'; import { SegmentationTagService } from '../../../services/segmentation-tag/segmentation-tag.service'; import { CategoriesEditService } from './categories-edit.service'; @@ -1275,6 +1278,7 @@ describe('CategoryEditPage', () => { boards: [] } } as any; + categoryEditPage.mediumList = [{name: 'english', code:'english'}] categoryEditPage.isBoardAvailable = true; categoryEditPage.showOnlyMandatoryFields = false; mockCommonUtilService.showToast = jest.fn(); @@ -1294,6 +1298,7 @@ describe('CategoryEditPage', () => { medium: [] } } as any; + categoryEditPage.mediumList = [{name: 'english', code:'english'}] categoryEditPage.supportedProfileAttributes = { medium: 'sample-medium' }; categoryEditPage.showOnlyMandatoryFields = true; const openFn = jest.fn(() => Promise.resolve()); @@ -1316,6 +1321,7 @@ describe('CategoryEditPage', () => { medium: [] } } as any; + categoryEditPage.mediumList = [{name: 'english', code:'english'}] categoryEditPage.supportedProfileAttributes = { medium: 'sample-medium' }; categoryEditPage.showOnlyMandatoryFields = false; mockCommonUtilService.showToast = jest.fn(); @@ -1339,6 +1345,7 @@ describe('CategoryEditPage', () => { grades: [] } } as any; + categoryEditPage.mediumList = [{name: 'english', code:'english'}] categoryEditPage.supportedProfileAttributes = { gradeLevel: 'sample-gradeLevel' }; categoryEditPage.showOnlyMandatoryFields = true; const openFn = jest.fn(() => Promise.resolve()); @@ -1380,11 +1387,13 @@ describe('CategoryEditPage', () => { // arrange categoryEditPage.profileEditForm = { value: { - boards: ['cbsc'], + boards: ['ka'], medium: ['english'], - grades: ['class 1'] + grades: ['ka'] } } as any; + categoryEditPage.mediumList = [{name: 'english', code:'english'}] + mockProfileService.updateServerProfile = jest.fn(() => of()) // act categoryEditPage.onSubmit(); // assert @@ -1412,7 +1421,7 @@ describe('CategoryEditPage', () => { // arrange categoryEditPage.profileEditForm = { value: { - boards: ['cbsc'], + boards: ['ka'], medium: ['english'], grades: ['class 1'] } @@ -1461,6 +1470,7 @@ describe('CategoryEditPage', () => { mockCommonUtilService.getLoader = jest.fn(() => Promise.resolve({ present: presentFn })); + categoryEditPage.mediumList = [{name: 'english', code:'english'}] categoryEditPage.isBoardAvailable = false; const req: UpdateServerProfileInfoRequest = { userId: 'sample_uid', framework: {} } @@ -1500,6 +1510,7 @@ describe('CategoryEditPage', () => { categoryEditPage.isBoardAvailable = true; const req: UpdateServerProfileInfoRequest = { userId: 'sample_uid', framework: {} } + categoryEditPage.mediumList = [{name: 'english', code:'english'}] const formVal = { grades: [ 'class 1' ], subjects:['english'] }; mockProfileService.updateServerProfile = jest.fn(() => of({req} as any)); //act @@ -1514,10 +1525,11 @@ describe('CategoryEditPage', () => { mockCommonUtilService.getLoader = jest.fn(() => Promise.resolve({ present: presentFn })); + categoryEditPage.mediumList = [{name: 'english', code:'english'}] categoryEditPage.isBoardAvailable = true; const req: UpdateServerProfileInfoRequest = { userId: 'sample_uid', framework: {} } - const formVal = { syllabus: 'cbsc', boards:'board', medium: 'english', grades: 'class 1', subjects: 'english' }; + const formVal = { syllabus: 'cbsc', boards:['ka'], medium: ['english'], grades: ['class 1'], subjects: ['english'] }; mockProfileService.updateServerProfile = jest.fn(() => of({req} as any)); //act categoryEditPage.submitForm(formVal); diff --git a/src/app/qrcoderesult/qrcoderesult.page.html b/src/app/qrcoderesult/qrcoderesult.page.html index 5388cf064e..52f3c78ca8 100644 --- a/src/app/qrcoderesult/qrcoderesult.page.html +++ b/src/app/qrcoderesult/qrcoderesult.page.html @@ -87,7 +87,7 @@
{{content?.contentData?.name}}
+ *ngIf="content.contentData?.streamingUrl && !(content.mimeType === 'application/vnd.ekstep.h5p-archive' || content.mimeType === 'application/vnd.ekstep.ecml-archive')"> diff --git a/src/services/download-pdf/download-pdf.service.spec.ts b/src/services/download-pdf/download-pdf.service.spec.ts index eb44133ddb..1491845087 100644 --- a/src/services/download-pdf/download-pdf.service.spec.ts +++ b/src/services/download-pdf/download-pdf.service.spec.ts @@ -211,3 +211,4 @@ describe('DownloadPdfService', () => { }); }); }); +})