diff --git a/projects/aca-content/src/lib/components/info-drawer/metadata-tab/metadata-tab.component.spec.ts b/projects/aca-content/src/lib/components/info-drawer/metadata-tab/metadata-tab.component.spec.ts index f990d7b3d5..074aa08002 100644 --- a/projects/aca-content/src/lib/components/info-drawer/metadata-tab/metadata-tab.component.spec.ts +++ b/projects/aca-content/src/lib/components/info-drawer/metadata-tab/metadata-tab.component.spec.ts @@ -32,7 +32,8 @@ import { AppState, EditOfflineAction, SetInfoDrawerMetadataAspectAction } from ' import { By } from '@angular/platform-browser'; import { AppExtensionService, NodePermissionService } from '@alfresco/aca-shared'; import { Actions } from '@ngrx/effects'; -import { Subject } from 'rxjs'; +import { of, Subject } from 'rxjs'; +import { ContentActionType } from '@alfresco/adf-extensions'; describe('MetadataTabComponent', () => { let fixture: ComponentFixture; @@ -42,6 +43,7 @@ describe('MetadataTabComponent', () => { let extensions: AppExtensionService; let nodePermissionService: NodePermissionService; let actions$: Subject; + let appExtensionService: AppExtensionService; const presets = { default: { @@ -61,6 +63,7 @@ describe('MetadataTabComponent', () => { ] }); nodePermissionService = TestBed.inject(NodePermissionService); + appExtensionService = TestBed.inject(AppExtensionService); spyOn(nodePermissionService, 'check').and.callFake((source: Node, permissions: string[]) => { return permissions.some((permission) => source.allowableOperations.includes(permission)); }); @@ -270,4 +273,19 @@ describe('MetadataTabComponent', () => { expect(initialState.componentInstance.displayAspect).toBe('EXIF'); }); }); + + describe('Custom metadata panels', () => { + it('should get custom metadata panels', (done) => { + spyOn(appExtensionService, 'getCustomMetadataPanels').and.returnValue( + of([{ id: 'test', type: ContentActionType.custom, title: 'testTitle', component: 'test-id' }]) + ); + const localComponent = TestBed.createComponent(MetadataTabComponent); + localComponent.componentInstance.customPanels.subscribe((panels) => { + expect(panels.length).toBe(1); + expect(panels[0].title).toEqual('testTitle'); + expect(panels[0].component).toEqual('test-id'); + done(); + }); + }); + }); }); diff --git a/projects/aca-shared/src/lib/services/app.extension.service.spec.ts b/projects/aca-shared/src/lib/services/app.extension.service.spec.ts index 966b8865ba..f7faa7e5c6 100644 --- a/projects/aca-shared/src/lib/services/app.extension.service.spec.ts +++ b/projects/aca-shared/src/lib/services/app.extension.service.spec.ts @@ -1736,4 +1736,60 @@ describe('AppExtensionService', () => { done(); }); }); + + it('should get custom metadata panels from config', (done) => { + extensions.setEvaluators({ + 'action.enabled': () => true + }); + + applyConfig({ + $id: 'test', + $name: 'test', + $version: '1.0.0', + $license: 'MIT', + $vendor: 'Good company', + $runtime: '1.5.0', + features: { + customMetadataPanels: [ + { + id: 'panel1-id', + title: 'testTitle', + component: 'testComponent1', + rules: { + visible: 'action.enabled' + } + }, + { + id: 'panel2-id', + title: 'testTitle2', + component: 'testComponent2', + rules: { + visible: 'action.enabled' + } + } + ] + } + }); + + const node: NodeEntry = { + entry: { + id: 'testId', + name: 'testName', + nodeType: 'test', + isFile: true, + isFolder: false, + modifiedAt: undefined, + createdAt: undefined, + modifiedByUser: undefined, + createdByUser: undefined + } + }; + + service.getCustomMetadataPanels(node).subscribe((panels) => { + expect(panels.length).toBe(2); + expect(panels[0].id).toEqual('panel1-id'); + expect(panels[1].id).toEqual('panel2-id'); + done(); + }); + }); });