diff --git a/projects/aca-shared/rules/src/app.rules.spec.ts b/projects/aca-shared/rules/src/app.rules.spec.ts index 1f37fd342..3306e147e 100644 --- a/projects/aca-shared/rules/src/app.rules.spec.ts +++ b/projects/aca-shared/rules/src/app.rules.spec.ts @@ -362,4 +362,81 @@ describe('app.evaluators', () => { expect(app.canUploadVersion(context)).toBe(true); }); }); + + describe('isShared', () => { + it('should return true if route is shared files and single selection', () => { + const context: any = { + selection: { + file: {} + }, + navigation: { + url: '/shared' + } + }; + + expect(app.isShared(context)).toBe(true); + }); + + it('should return false if route is shared files and multiple selection', () => { + const context: any = { + selection: { + file: null + }, + navigation: { + url: '/shared' + } + }; + + expect(app.isShared(context)).toBe(false); + }); + + it('should return false if route is trashcan route', () => { + const context: any = { + selection: { + file: {} + }, + navigation: { + url: '/trashcan' + } + }; + + expect(app.isShared(context)).toBe(false); + }); + + it('should return false if selection is not shared', () => { + const context: any = { + selection: { + file: { + entry: { + properties: {} + } + } + }, + navigation: { + url: '/other' + } + }; + + expect(app.isShared(context)).toBe(false); + }); + + it('should return true if selection is shared', () => { + const context: any = { + selection: { + file: { + entry: { + properties: { + 'qshare:sharedId': 'some-id' + } + } + } + }, + navigation: { + url: '/other' + } + }; + + expect(app.isShared(context)).toBe(true); + }); + }); }); diff --git a/projects/aca-shared/rules/src/app.rules.ts b/projects/aca-shared/rules/src/app.rules.ts index 129c4d585..426d49eab 100644 --- a/projects/aca-shared/rules/src/app.rules.ts +++ b/projects/aca-shared/rules/src/app.rules.ts @@ -114,7 +114,7 @@ export function canEditFolder(context: RuleContext): boolean { * JSON ref: `app.selection.file.isShared` */ export function isShared(context: RuleContext): boolean { - if (navigation.isSharedFiles(context) && !context.selection.isEmpty) { + if (navigation.isSharedFiles(context) && context.selection.file) { return true; }