From f0418d41d5a1e2bd8b9289aa8ddf28045d592b5f Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Fri, 19 May 2023 10:37:12 +0100 Subject: [PATCH] fix tests --- .../aca-shared/rules/src/app.rules.spec.ts | 20 +++++++++++++++++++ projects/aca-shared/rules/src/app.rules.ts | 5 +++-- .../aca-mobile-app-switcher.service.spec.ts | 2 +- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/projects/aca-shared/rules/src/app.rules.spec.ts b/projects/aca-shared/rules/src/app.rules.spec.ts index 5d6f88ba6..6e5d538d1 100644 --- a/projects/aca-shared/rules/src/app.rules.spec.ts +++ b/projects/aca-shared/rules/src/app.rules.spec.ts @@ -550,8 +550,13 @@ describe('app.evaluators', () => { }); describe('canOpenWithOffice', () => { + const appConfig = { + get: (key: string) => key + }; + it('should return [false] if using SSO', () => { const context: any = { + appConfig, auth: { isOauth: () => true } @@ -562,6 +567,7 @@ describe('app.evaluators', () => { it('should return [false] if no selection present', () => { const context: any = { + appConfig, selection: null }; @@ -570,6 +576,7 @@ describe('app.evaluators', () => { it('should return [false] if no file selected', () => { const context: any = { + appConfig, selection: { file: null } @@ -580,6 +587,7 @@ describe('app.evaluators', () => { it('should return [false] if selected file has no entry', () => { const context: any = { + appConfig, selection: { file: { entry: null @@ -592,6 +600,7 @@ describe('app.evaluators', () => { it('should return [false] if selected file has no properties', () => { const context: any = { + appConfig, selection: { file: { entry: { @@ -606,6 +615,7 @@ describe('app.evaluators', () => { it('should return [false] if selected file is locked', () => { const context: any = { + appConfig, selection: { file: { entry: { @@ -621,6 +631,7 @@ describe('app.evaluators', () => { it('should return [false] if selected file has no extension', () => { const context: any = { + appConfig, selection: { file: { entry: { @@ -637,6 +648,7 @@ describe('app.evaluators', () => { it('should return [false] if extension is not supported', () => { const context: any = { + appConfig, selection: { file: { entry: { @@ -653,6 +665,7 @@ describe('app.evaluators', () => { it('should return [false] if selected file has write lock', () => { const context: any = { + appConfig, selection: { file: { entry: { @@ -671,6 +684,7 @@ describe('app.evaluators', () => { it('should return [false] if selected file has read-only lock', () => { const context: any = { + appConfig, selection: { file: { entry: { @@ -689,6 +703,7 @@ describe('app.evaluators', () => { it('should return [false] if current user is not lock owner', () => { const context: any = { + appConfig, profile: { id: 'user1' }, @@ -713,6 +728,7 @@ describe('app.evaluators', () => { it('should return [false] if current user is lock owner', () => { const context: any = { + appConfig, profile: { id: 'user1' }, @@ -737,6 +753,7 @@ describe('app.evaluators', () => { it('should return [false] if permissions check is false', () => { const context: any = { + appConfig, selection: { file: { entry: { @@ -756,6 +773,9 @@ describe('app.evaluators', () => { it('should return [true] if all checks succeed', () => { const context: any = { + appConfig: { + get: () => true + }, selection: { file: { entry: { diff --git a/projects/aca-shared/rules/src/app.rules.ts b/projects/aca-shared/rules/src/app.rules.ts index 8d4bf13ab..7732d6108 100644 --- a/projects/aca-shared/rules/src/app.rules.ts +++ b/projects/aca-shared/rules/src/app.rules.ts @@ -583,8 +583,9 @@ export const showInfoSelectionButton = (context: RuleContext): boolean => naviga * @param context Rule execution context */ export function canOpenWithOffice(context: AcaRuleContext): boolean { - const flag = context.appConfig.get('plugins.aosPlugin'); - if (flag === false || flag !== 'true') { + const flag = `${context.appConfig.get('plugins.aosPlugin', false)}`; + + if (flag !== 'true') { return false; } diff --git a/projects/aca-shared/src/lib/services/aca-mobile-app-switcher.service.spec.ts b/projects/aca-shared/src/lib/services/aca-mobile-app-switcher.service.spec.ts index b269faaa3..4cb0c203f 100644 --- a/projects/aca-shared/src/lib/services/aca-mobile-app-switcher.service.spec.ts +++ b/projects/aca-shared/src/lib/services/aca-mobile-app-switcher.service.spec.ts @@ -45,7 +45,7 @@ describe('AcaMobileAppSwitcherService', () => { }); appConfig = TestBed.inject(AppConfigService); appConfig.config.mobileAppSwitch = { - enabled: 'true', + enabled: true, iphoneUrl: 'iosamw://', androidUrlPart1: 'intent:///', androidUrlPart2: '#Intent;scheme=androidamw;package=com.alfresco.content.app;end',