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
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 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-v9": "5.0.2",
"@project-sunbird/sunbird-sdk": "6.0.2",
"@project-sunbird/sunbird-sdk": "7.0.12",
"@project-sunbird/sunbird-video-player-web-component": "^1.0.1",
"chart.js": "^2.9.4",
"chartjs-plugin-datalabels": "^0.7.0",
Expand Down Expand Up @@ -113,7 +113,6 @@
"cordova-plugin-secure-storage-echo": "^5.1.1",
"cordova-plugin-statusbar": "^2.4.3",
"cordova-plugin-streaming-media": "^2.3.0",
"cordova-plugin-sunbirdsplash": "git+https://github.com/project-sunbird/cordova-plugin-sunbirdsplash.git#release-5.1.0.10",
"cordova-plugin-webview-checker": "^1.0.1",
"cordova-plugin-x-socialsharing": "^6.0.3",
"cordova-plugin-zip": "^3.1.0",
Expand Down
5 changes: 5 additions & 0 deletions src/__tests__/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ global.sbsync = {
onSyncSucces: () => {}
}

global.customtabs = {
launchInBrowser: (url, callbackUrl, error) => {}
}


global.qrScanner = {
startScanner: (screenTitle, displayText, displayTextColor, buttonText, showButton, isRTL, callback) => {},
stopScanner: () => {}
Expand Down
4 changes: 4 additions & 0 deletions src/app/profile/profile.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@
<span class="value align-middle">{{'ADD_RECOVERY_ID' | translate}}</span>
</div>
</div>
<button type="submit" (click)="verifyUser()"
class="delete_button">
{{'DELETE_YOUR_ACCOUNT' | translate}}
</button>
</div>

<div class="self-declare-teacher-details" *ngIf="isCustodianOrgId && profile?.declarations?.length">
Expand Down
10 changes: 10 additions & 0 deletions src/app/profile/profile.page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,16 @@
}
}

.delete_button {
border-radius: 20px!important;
background-color:white;
color: #024F9D;
height: 2.5rem!important;
width: 16rem!important;
margin-bottom: 6%;
margin-top: 5%;
}

.contributions {
min-height: 14.375rem;
@include margin(0, 0, 16px, 0);
Expand Down
136 changes: 128 additions & 8 deletions src/app/profile/profile.page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ import {
AppGlobalService,
AppHeaderService,
CommonUtilService, Environment,
FormAndFrameworkUtilService, InteractSubtype, InteractType, PageId,
TelemetryGeneratorService
FormAndFrameworkUtilService, ID, InteractSubtype, InteractType, LogoutHandlerService, PageId,
TelemetryGeneratorService,
UtilityService
} from '../../services';
import { SocialSharing } from '@awesome-cordova-plugins/social-sharing/ngx';
import { AppVersion } from '@awesome-cordova-plugins/app-version/ngx';
Expand All @@ -35,6 +36,7 @@ import { SegmentationTagService } from '../../services/segmentation-tag/segmenta
import { CertificateService } from '@project-sunbird/sunbird-sdk';
import { LocationHandler } from '../../services/location-handler';
import { UnnatiDataService } from '../manage-learn/core/services/unnati-data.service';
import { ToastService } from '../manage-learn/core';

describe('Profile.page', () => {
let profilePage: ProfilePage;
Expand All @@ -48,7 +50,9 @@ describe('Profile.page', () => {
mockProfileData
)),
isDefaultChannelProfile: jest.fn(() => of(true)),
generateOTP: jest.fn(() => true)
generateOTP: jest.fn(() => true),
getActiveProfileSession: jest.fn().mockResolvedValue({ uid: 'mockedUID' }),
deleteProfileData: jest.fn().mockResolvedValue(true)
};
const mockAuthService: Partial<AuthService> = {
getSession: jest.fn(() => of({
Expand All @@ -57,9 +61,6 @@ describe('Profile.page', () => {
userToken: 'sample_user_token'
}))
};
const mockPlatform: Partial<Platform> = {
is: jest.fn(platform => platform === 'ios')
};
const mockContentService: Partial<ContentService> = {};
const mockCourseService: Partial<CourseService> = {};
const mockFormService: Partial<FormService> = {};
Expand Down Expand Up @@ -106,7 +107,8 @@ describe('Profile.page', () => {
}),
getOrgLocation: jest.fn(() => {
return { state: 'tripura', district: 'west_tripura', block: 'dhaleshwar' };
})
}),
getLoader: jest.fn()
};
const mockSocialSharing: Partial<SocialSharing> = {};
const mockAppHeaderService: Partial<AppHeaderService> = {};
Expand Down Expand Up @@ -146,10 +148,23 @@ describe('Profile.page', () => {
const mockSegmentationTagService: Partial<SegmentationTagService> = {
evalCriteria: jest.fn()
};
const mockPlatform: Partial<Platform> = {
is: jest.fn(platform => platform === 'ios')
};
const mockLocationHandler: Partial<LocationHandler> = {};
const mockUnnatiDataService: Partial<UnnatiDataService> = {
get: jest.fn(() => of())
}as any
const mockUtilityService: Partial<UtilityService> = {
};
const mockLogoutHandlerService: Partial<LogoutHandlerService> = {
onLogout: jest.fn()
};
const mockToastService: Partial<ToastService> = {
showMessage: jest.fn()
};


beforeAll(() => {
profilePage = new ProfilePage(
mockProfileService as ProfileService,
Expand Down Expand Up @@ -181,7 +196,10 @@ describe('Profile.page', () => {
mockSegmentationTagService as SegmentationTagService,
mockPlatform as Platform,
mockLocationHandler as LocationHandler,
mockUnnatiDataService as UnnatiDataService
mockUnnatiDataService as UnnatiDataService,
mockUtilityService as UtilityService,
mockLogoutHandlerService as LogoutHandlerService,
mockToastService as ToastService
);
});

Expand Down Expand Up @@ -1373,6 +1391,108 @@ describe('Profile.page', () => {
});
});



describe('it should verify user based on user roles', () => {
it('should call launchDeleteUrl if user roles are empty', () => {
// Arrange
profilePage.profile = { roles: [] };
// Act
profilePage.verifyUser();

// Assert

});

it('should call showMessage if user roles are not empty', () => {
// Arrange
profilePage.profile = { roles: ['sample_role'] };

// Act
profilePage.verifyUser();

// Assert
expect(mockToastService.showMessage).toHaveBeenCalledWith('FRMELEMNTS_LBL_DELETE_AUTH', 'danger');
});
})

describe('launchInBrowser()', () => {
it('should open launchInBrowser', () => {
//arrange
mockTelemetryGeneratorService.generateInteractTelemetry = jest.fn(() => {
InteractType.TOUCH,
InteractSubtype.DELETE_CLICKED,
undefined,
PageId.PROFILE,
undefined,
undefined,
undefined,
undefined,
ID.DELETE_CLICKED
});
mockUtilityService.getBuildConfigValue = jest.fn((key) => {
switch(key) {
case 'BASE_URL':
return Promise.resolve('http://dev/');

case 'URL_SCHEME':
return Promise.resolve('dev');

default:
return Promise.resolve('default');
}
})
mockProfileService.getActiveSessionProfile = jest.fn(() => of({
profile : {
uid: "001"
}
} as any))
//act
profilePage.launchDeleteUrl();
//assert
setTimeout(() => {
expect(mockTelemetryGeneratorService.generateInteractTelemetry).toHaveBeenCalledWith(
InteractType.TOUCH,
InteractSubtype.DELETE_CLICKED,
undefined,
PageId.PROFILE,
undefined,
undefined,
undefined,
undefined,
ID.DELETE_CLICKED
);
expect(mockUtilityService.getBuildConfigValue).toHaveBeenCalledWith('BASE_URL');
expect(mockUtilityService.getBuildConfigValue).toHaveBeenCalledWith('URL_SCHEME');
expect(mockProfileService.getActiveProfileSession).toHaveBeenCalled();
}, 0);

})
})


describe('isUserDeleted()', () => {
it('should return true if an error occurs', async () => {
//arrange
mockProfileService.getServerProfilesDetails = jest.fn(() => throwError('sample_error'));
//act
const result = await profilePage.isUserDeleted('mocked-user-id');
//assert
expect(result).toBe(true);
});

it('should return false if profileResponse is not null', async () => {
//arrange
mockProfileService.getServerProfilesDetails = jest.fn(() => of(mockProfileData));
//act
const result = await profilePage.isUserDeleted('mocked-user-id');
//assert
expect(result).toBe(false);
});
});



it('shareUsername', () => {
// arrange
profilePage.profile = {
Expand Down
Loading