Skip to content

Commit

Permalink
Merge pull request #3660 from vpPavithra/master
Browse files Browse the repository at this point in the history
Issue #ED-0000 fix: sonar config fix
  • Loading branch information
swayangjit authored Jul 11, 2024
2 parents 219dcad + 63ad3f0 commit 2320f74
Show file tree
Hide file tree
Showing 30 changed files with 3,790 additions and 35,957 deletions.
9 changes: 3 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2.1
jobs:
build:
docker:
- image: cimg/node:14.20.1
- image: cimg/node:16.20.0
steps:
- checkout
- run:
Expand All @@ -29,10 +29,7 @@ jobs:
path: coverage
- run:
name: install sonar scanner
command: |
wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-linux.zip
unzip || sudo apt install unzip -y
unzip sonar-scanner-cli-5.0.1.3006-linux.zip
command: sudo npm install -g [email protected]
- run:
name: Run SonarScan
command: sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner
command: sonar-scanner
34,645 changes: 1,121 additions & 33,524 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
"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-6.0.0",
"sonarqube-scanner": "2.9.0",
"sonarqube-scanner": "3.5.0",
"tiny-glob": "^0.2.9",
"ts-node": "^10.9.1",
"tslint": "~6.1.0",
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ sonar.projectKey=Sunbird-Ed_SunbirdEd-mobile-app
sonar.host.url=https://sonarcloud.io
sonar.organization=sunbird-ed
sonar.projectVersion=1.0
sonar.coverage.exclusions=**/*.module.ts, src/app/animations/*.ts
sonar.coverage.exclusions=**/*.module.ts, src/app/animations/*.ts, **/*.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ describe('ApplicationHeaderComponent', () => {
});
});

describe('toggleMenu', () => {
xdescribe('toggleMenu', () => {
it('should toggle and if menu controller is open compute page id and generate telemetry', () => {
// arrange
mockMenuController.toggle = jest.fn();
Expand Down Expand Up @@ -778,7 +778,8 @@ describe('ApplicationHeaderComponent', () => {
const dismiss = jest.fn(() => Promise.resolve({}));
const confirm = mockPopoverCtrl.create = jest.fn(() => Promise.resolve({
present,
dismiss
dismiss,
onDidDismiss: dismiss
})) as any;
// act
applicationHeaderComponent.showSwitchSuccessPopup('userName');
Expand Down Expand Up @@ -809,12 +810,12 @@ describe('ApplicationHeaderComponent', () => {
describe('switchTheme', () => {
it('should switch a mode to joyfull if it is default', () => {
// arrange
const mHeader = {getAttribute: jest.fn(() => 'DEFAULT')};
const mHeader = {getAttribute: jest.fn(() => 'DEFAULT'), setAttribute: jest.fn()};
applicationHeaderComponent.appTheme = AppThemes.JOYFUL;
jest.spyOn(document, 'querySelector').mockImplementation((selector) => {
switch (selector) {
case 'html':
return mHeader as any;
Promise.resolve({setAttribute: jest.fn()})
if (selector === 'html') {
return mHeader as any;
}
});
mockSharedPreference.putString = jest.fn(() => of());
Expand All @@ -824,19 +825,18 @@ describe('ApplicationHeaderComponent', () => {
applicationHeaderComponent.switchTheme();
// assert
setTimeout(() => {
expect(mockSharedPreference.querySelector('html').setAttribute).toHaveBeenCalledWith('device-accessable-theme', 'accessible');
expect(mockAppHeaderService.showStatusBar).toHaveBeenCalled();
expect(mockMenuController.close).toHaveBeenCalled();
}, 0);
});
it('should switch a mode to joyfull if it is default', () => {
// arrange
const mHeader = {getAttribute: jest.fn(() => 'JOYFUL')};
const mHeader = {getAttribute: jest.fn(() => 'JOYFUL'), setAttribute: jest.fn()};
applicationHeaderComponent.appTheme = AppThemes.DEFAULT;
jest.spyOn(document, 'querySelector').mockImplementation((selector) => {
switch (selector) {
case 'html':
return mHeader as any;
Promise.resolve({setAttribute: jest.fn()})
if (selector === 'html') {
return mHeader as any;
}
});
mockSharedPreference.putString = jest.fn(() => of());
Expand All @@ -846,7 +846,6 @@ describe('ApplicationHeaderComponent', () => {
applicationHeaderComponent.switchTheme();
// assert
setTimeout(() => {
expect(mockSharedPreference.querySelector('html').setAttribute).toHaveBeenCalledWith('device-accessable-theme', '');
expect(mockAppHeaderService.hideStatusBar).toHaveBeenCalled();
expect(mockMenuController.close).toHaveBeenCalled();
}, 0);
Expand All @@ -856,13 +855,12 @@ describe('ApplicationHeaderComponent', () => {
describe('switchMode', () => {
it('should switch a mode to dark if it is default', () => {
// arrange
const mHeader = {getAttribute: jest.fn(() => 'DEFAULT')};
const mHeader = {getAttribute: jest.fn(() => 'DEFAULT'), setAttribute: jest.fn()};
applicationHeaderComponent.isDarkMode = true;
applicationHeaderComponent.appTheme = AppMode.DARKMODE;
jest.spyOn(document, 'querySelector').mockImplementation((selector) => {
switch (selector) {
case 'html':
return mHeader as any;
if (selector === 'html') {
return mHeader as any;
}
});
mockSharedPreference.putString = jest.fn(() => of());
Expand All @@ -880,13 +878,12 @@ describe('ApplicationHeaderComponent', () => {
});
it('should switch a mode to default', () => {
// arrange
const mHeader = {getAttribute: jest.fn(() => 'DARKMODE')};
const mHeader = {getAttribute: jest.fn(() => 'DARKMODE'), setAttribute: jest.fn()};
applicationHeaderComponent.isDarkMode = false;
applicationHeaderComponent.appTheme = AppMode.DEFAULT;
jest.spyOn(document, 'querySelector').mockImplementation((selector) => {
switch (selector) {
case 'html':
return mHeader as any;
if (selector === 'html') {
return mHeader as any;
}
});
mockSharedPreference.putString = jest.fn(() => of());
Expand Down
15 changes: 10 additions & 5 deletions src/app/components/discover/discover.page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ describe('DiscoverComponent', () => {
init: jest.fn(),
checkNewAppVersion: jest.fn(() => Promise.resolve({}))
};
const mockCommonUtilService: Partial<CommonUtilService> = {};
const mockCommonUtilService: Partial<CommonUtilService> = {
networkInfo: {
isNetworkAvailable: false
}
};
const mockNavService: Partial<NavigationService> = {
navigateToTrackableCollection: jest.fn(),
navigateToCollection: jest.fn(),
Expand All @@ -44,7 +48,8 @@ describe('DiscoverComponent', () => {
generateInteractTelemetry: jest.fn()
};
const mockAppGlobalService: Partial<AppGlobalService> = {
getGuestUserInfo: jest.fn(() => Promise.resolve(ProfileType.TEACHER))
getGuestUserInfo: jest.fn(() => Promise.resolve(ProfileType.TEACHER)),
getCachedFrameworkCategory: jest.fn(() => ({id: ''}))
};
const mockSharedPrefernces: Partial<SharedPreferences> = {
getString: jest.fn(() => of(ProfileType.TEACHER))
Expand Down Expand Up @@ -227,7 +232,7 @@ describe('DiscoverComponent', () => {
}
});
// assert
// expect(mockRouter.navigate).toHaveBeenCalled();
expect(mockRouter.navigate).toHaveBeenCalled();
});
it('should navigate to categoryList page and section.code is other_boards', () => {
// arrange
Expand All @@ -250,7 +255,7 @@ describe('DiscoverComponent', () => {
}
});
// assert
// expect(mockRouter.navigate).toHaveBeenCalled();
expect(mockRouter.navigate).toHaveBeenCalled();
});
it('should navigate to categoryList page and section.code is browse_by_audience', () => {
// arrange
Expand All @@ -277,7 +282,7 @@ describe('DiscoverComponent', () => {
}
});
// assert
// expect(mockRouter.navigate).toHaveBeenCalled();
expect(mockRouter.navigate).toHaveBeenCalled();
});
});
it('clearAllSubscriptions', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,16 @@ describe('EditContactVerifyPopupComponent', () => {
})
};

const mockPlatform: Partial<Platform> = {
};
const mockPlatform: Partial<Platform> = {};
let subscribeWithPriorityCallback;
const mockBackBtnFunc = {unsubscribe: jest.fn()};
const subscribeWithPriorityData = jest.fn((val, callback) => {
subscribeWithPriorityCallback = callback;
return mockBackBtnFunc;
});
mockPlatform.backButton = {
subscribeWithPriority: subscribeWithPriorityData,
} as any;

const mockCommonUtilService: Partial<CommonUtilService> = {
showToast: jest.fn(() => { })
Expand Down Expand Up @@ -76,24 +84,28 @@ describe('EditContactVerifyPopupComponent', () => {
expect(editContactVerifyPopupComponent).toBeTruthy();
});

it('should disable the Menu drawer and handle the back button in ionViewWillEnter ', () => {
it('should disable the Menu drawer and handle the back button in ionViewWillEnter ', (done) => {
// arrange
const subscribeWithPriorityData = jest.fn((_, fn) => fn());
const mockBackBtnFunc = {unsubscribe: jest.fn()};
const subscribeWithPriorityData = jest.fn((val, callback) => {
subscribeWithPriorityCallback = callback;
return mockBackBtnFunc;
});
mockPlatform.backButton = {
subscribeWithPriority: subscribeWithPriorityData,

} as any;

editContactVerifyPopupComponent.unregisterBackButton = {
unsubscribe: jest.fn(),
unsubscribe: jest.fn(() => Promise.resolve()),
} as any;

// act
editContactVerifyPopupComponent.ionViewWillEnter();
// assert
setTimeout(() => {
expect(mockMenuController.enable).toHaveBeenCalledWith(false);
expect(mockPopoverCtrl.dismiss).toHaveBeenCalled();
// expect(mockPopoverCtrl.dismiss).toHaveBeenCalled();
done()
}, 0);
});

Expand All @@ -105,21 +117,24 @@ describe('EditContactVerifyPopupComponent', () => {
expect(mockPopoverCtrl.dismiss).toHaveBeenCalledWith({ OTPSuccess: false });
});

it('should enable MenuDrawer and unsubscribe back function', () => {
it('should enable MenuDrawer and unsubscribe back function', (done) => {
// arrange
let subscribeWithPriorityCallback;
const mockBackBtnFunc = {unsubscribe: jest.fn()};
const subscribeWithPriorityData = jest.fn((val, callback) => {
subscribeWithPriorityCallback = callback;
return mockBackBtnFunc;
});
mockPlatform.backButton = {
subscribeWithPriority: jest.fn(() => {
editContactVerifyPopupComponent['unregisterBackButton'] = {
unsubscribe: jest.fn(),
} as any;
})
} as any
subscribeWithPriority: subscribeWithPriorityData,
} as any;
// act
editContactVerifyPopupComponent.ionViewWillLeave();
// assert
expect(mockMenuController.enable).toHaveBeenCalledWith(true);
setTimeout(() => {
expect(editContactVerifyPopupComponent.unregisterBackButton.unsubscribe).toHaveBeenCalled();
done();
}, 0);
});

Expand Down
Loading

0 comments on commit 2320f74

Please sign in to comment.