diff --git a/projects/aca-content/assets/app.extensions.json b/projects/aca-content/assets/app.extensions.json index bff4ed87b2..7c6182fd4c 100644 --- a/projects/aca-content/assets/app.extensions.json +++ b/projects/aca-content/assets/app.extensions.json @@ -1261,7 +1261,7 @@ "click": "EXPAND_INFO_DRAWER" }, "rules": { - "visible": "canNotShowExpand" + "visible": "canShowExpand" } } ], diff --git a/projects/aca-content/src/lib/aca-content.module.ts b/projects/aca-content/src/lib/aca-content.module.ts index 5df9187d8c..c0163de6c7 100644 --- a/projects/aca-content/src/lib/aca-content.module.ts +++ b/projects/aca-content/src/lib/aca-content.module.ts @@ -192,7 +192,7 @@ export class ContentServiceExtensionModule { canToggleFavorite: rules.canToggleFavorite, isLibraryManager: rules.isLibraryManager, canEditAspects: rules.canEditAspects, - canNotShowExpand: rules.canNotShowExpand, + canShowExpand: rules.canShowExpand, canInfoPreview: rules.canInfoPreview, showInfoSelectionButton: rules.showInfoSelectionButton, diff --git a/projects/aca-content/src/lib/components/details/details.component.spec.ts b/projects/aca-content/src/lib/components/details/details.component.spec.ts index 0988ca7033..d3d8c25bcd 100644 --- a/projects/aca-content/src/lib/components/details/details.component.spec.ts +++ b/projects/aca-content/src/lib/components/details/details.component.spec.ts @@ -26,7 +26,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { AppTestingModule } from '../../testing/app-testing.module'; import { DetailsComponent } from './details.component'; import { ActivatedRoute } from '@angular/router'; -import { of, Subject } from 'rxjs'; +import { BehaviorSubject, of, Subject } from 'rxjs'; import { NO_ERRORS_SCHEMA } from '@angular/core'; import { Store } from '@ngrx/store'; import { ContentApiService } from '@alfresco/aca-shared'; @@ -49,6 +49,16 @@ describe('DetailsComponent', () => { select: () => mockStream }; + const extensionsServiceMock = { + getAllowedSidebarActions: jasmine.createSpy('getAllowedSidebarActions') + }; + + const mockAspectActions = []; + + // Mock the observable returned by getAllowedSidebarActions + const mockObservable = new BehaviorSubject(mockAspectActions); + extensionsServiceMock.getAllowedSidebarActions.and.returnValue(mockObservable); + beforeEach(() => { TestBed.configureTestingModule({ imports: [AppTestingModule, DetailsComponent], @@ -128,4 +138,12 @@ describe('DetailsComponent', () => { fixture.detectChanges(); expect(store.dispatch).toHaveBeenCalledWith(new SetSelectedNodesAction([node])); }); + + it('should set aspectActions from extensions', () => { + extensionsServiceMock.getAllowedSidebarActions.and.returnValue(of(mockAspectActions)); + fixture.detectChanges(); + fixture.whenStable().then(() => { + expect(component.aspectActions).toEqual(mockAspectActions); + }); + }); }); diff --git a/projects/aca-content/src/lib/components/toolbar/toggle-edit-offline/toggle-edit-offline.component.spec.ts b/projects/aca-content/src/lib/components/toolbar/toggle-edit-offline/toggle-edit-offline.component.spec.ts index e061c2a599..c1dc90e3e8 100644 --- a/projects/aca-content/src/lib/components/toolbar/toggle-edit-offline/toggle-edit-offline.component.spec.ts +++ b/projects/aca-content/src/lib/components/toolbar/toggle-edit-offline/toggle-edit-offline.component.spec.ts @@ -29,6 +29,7 @@ import { Store } from '@ngrx/store'; import { NodeEntry } from '@alfresco/js-api'; import { DownloadNodesAction, EditOfflineAction, SnackbarErrorAction } from '@alfresco/aca-shared/store'; import { AppTestingModule } from '../../../testing/app-testing.module'; +import { AppExtensionService } from '@alfresco/aca-shared'; describe('ToggleEditOfflineComponent', () => { let fixture: ComponentFixture; @@ -38,6 +39,10 @@ describe('ToggleEditOfflineComponent', () => { let selectSpy: jasmine.Spy; let selection: any; + const extensionsMock = { + updateSidebarActions: jasmine.createSpy('updateSidebarActions') + }; + beforeEach(() => { TestBed.configureTestingModule({ imports: [AppTestingModule, ToggleEditOfflineComponent], @@ -48,6 +53,10 @@ describe('ToggleEditOfflineComponent', () => { select: () => {}, dispatch: () => {} } + }, + { + provide: AppExtensionService, + useValue: extensionsMock } ] }); @@ -133,4 +142,14 @@ describe('ToggleEditOfflineComponent', () => { }) ]); }); + + it('should call updateSidebarActions on click', async () => { + selectSpy.and.returnValue(of(selection)); + fixture.detectChanges(); + + await component.onClick(); + fixture.detectChanges(); + + expect(extensionsMock.updateSidebarActions).toHaveBeenCalled(); + }); }); diff --git a/projects/aca-shared/rules/src/app.rules.spec.ts b/projects/aca-shared/rules/src/app.rules.spec.ts index 6e5d538d1f..68713f275e 100644 --- a/projects/aca-shared/rules/src/app.rules.spec.ts +++ b/projects/aca-shared/rules/src/app.rules.spec.ts @@ -121,6 +121,28 @@ describe('app.evaluators', () => { }); }); + describe('canShowExpand', () => { + it('should return false when isLibraries returns true', () => { + const context: any = { + navigation: { + url: '/libraries' + } + }; + + expect(app.canShowExpand(context)).toBe(false); + }); + + it('should return false when isDetails returns true', () => { + const context: any = { + navigation: { + url: '/details' + } + }; + + expect(app.canShowExpand(context)).toBe(false); + }); + }); + describe('hasLockedFiles', () => { it('should return [false] if selection not present', () => { const context: any = {}; diff --git a/projects/aca-shared/rules/src/app.rules.ts b/projects/aca-shared/rules/src/app.rules.ts index ef23e53556..bf06469f2d 100644 --- a/projects/aca-shared/rules/src/app.rules.ts +++ b/projects/aca-shared/rules/src/app.rules.ts @@ -511,7 +511,7 @@ export const canEditAspects = (context: RuleContext): boolean => repository.isMajorVersionAvailable(context, '7') ].every(Boolean); -export const canNotShowExpand = (context: RuleContext): boolean => [!navigation.isLibraries(context), !navigation.isDetails(context)].every(Boolean); +export const canShowExpand = (context: RuleContext): boolean => [!navigation.isLibraries(context), !navigation.isDetails(context)].every(Boolean); /** * Checks if user can manage permissions for the selected node. diff --git a/projects/aca-shared/rules/src/navigation.rules.spec.ts b/projects/aca-shared/rules/src/navigation.rules.spec.ts index b0cae7b299..5f7941f177 100644 --- a/projects/aca-shared/rules/src/navigation.rules.spec.ts +++ b/projects/aca-shared/rules/src/navigation.rules.spec.ts @@ -225,6 +225,38 @@ describe('navigation.evaluators', () => { }); }); + describe('isDetails', () => { + it('should return [true] if url ends with `/details`', () => { + const context: any = { + navigation: { + url: '/path/details' + } + }; + + expect(app.isDetails(context)).toBe(true); + }); + + it('should return [true] if url starts with `/details`', () => { + const context: any = { + navigation: { + url: '/details/path' + } + }; + + expect(app.isDetails(context)).toBe(true); + }); + + it('should return [true] if url includes with `/details`', () => { + const context: any = { + navigation: { + url: '/details/path' + } + }; + + expect(app.isDetails(context)).toBe(true); + }); + }); + describe('isRecentFiles', () => { it('should return [true] if url starts with `/recent-files`', () => { const context: any = {