Skip to content

Commit

Permalink
[ACS-5645] unit test updated
Browse files Browse the repository at this point in the history
  • Loading branch information
AnukritiGL committed Dec 12, 2023
1 parent 8dc4f89 commit 1665d74
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="aca-details-title">
<div class="aca-details-breadcrumb" role="heading" aria-level="2" *ngIf="node">
<span class="aca-details-breadcrumb-library">
<img class="aca-details-breadcrumb-icon" alt="{{ 'APP.INFO_DRAWER.ICON' | translate }}" src="{{ getIcon }}">
<img class="aca-details-breadcrumb-icon" alt="{{ 'APP.INFO_DRAWER.ICON' | translate }}" src="{{ nodeIcon }}">
{{ node.name }} </span>
</div>
<div class="acs-details-buttons">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ app-details-manager {
.aca-details-breadcrumb {
font-size: 18px;
margin-left: 20px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;

&-library {
font-weight: 900;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,6 @@ describe('DetailsComponent', () => {
const mockAspectActionsSubject$ = new BehaviorSubject(mockAspectActions);
extensionsServiceMock.getAllowedSidebarActions.and.returnValue(mockAspectActionsSubject$.asObservable());

const mockNode = {
isFile: false,
createdByUser: { id: 'admin', displayName: 'Administrator' },
modifiedAt: new Date('2017-05-24T15:08:55.640Z'),
nodeType: 'cm:content',
content: {
mimeType: 'application/rtf',
mimeTypeName: 'Rich Text Format',
sizeInBytes: 14530
},
createdAt: new Date('2017-05-24T15:08:55.640Z'),
isFolder: true,
modifiedByUser: { id: 'admin', displayName: 'Administrator' },
name: 'b_txt_file.rtf',
id: 'test node 1'
};

beforeEach(() => {
TestBed.configureTestingModule({
imports: [AppTestingModule, DetailsComponent],
Expand Down Expand Up @@ -170,10 +153,10 @@ describe('DetailsComponent', () => {
expect(store.dispatch).toHaveBeenCalledWith(new SetSelectedNodesAction([node]));
});

it('should set aspectActions from extensions', () => {
it('should set aspectActions from extensions', async () => {
extensionsServiceMock.getAllowedSidebarActions.and.returnValue(of(mockAspectActions));
fixture.detectChanges();
fixture.whenStable().then(() => {
await fixture.whenStable().then(() => {
expect(component.aspectActions).toEqual(mockAspectActions);
});
});
Expand All @@ -182,11 +165,11 @@ describe('DetailsComponent', () => {
const expectedIcon = 'assets/images/ft_ic_folder';
spyOn(thumbnailService, 'getNodeIcon').and.returnValue(expectedIcon);
fixture.detectChanges();
component.getNodeIcon(mockNode);
expect(component.getIcon).toContain(expectedIcon);
component.ngOnInit();
expect(component.nodeIcon).toContain(expectedIcon);
});

it('should set aspectActions from extensions', async () => {
it('should set aspectActions from extensions', () => {
const extensionMock = {
getAllowedSidebarActions: () =>
of([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { MatProgressBarModule } from '@angular/material/progress-bar';
import { MatButtonModule } from '@angular/material/button';
import { MetadataTabComponent } from '../info-drawer/metadata-tab/metadata-tab.component';
import { CommentsTabComponent } from '../info-drawer/comments-tab/comments-tab.component';
import { NodeEntry, Node, PathElement } from '@alfresco/js-api';
import { NodeEntry, PathElement } from '@alfresco/js-api';
import { takeUntil } from 'rxjs/operators';
import { ContentActionRef } from '@alfresco/adf-extensions';
import { ThumbnailService } from '@alfresco/adf-core';
Expand Down Expand Up @@ -68,7 +68,7 @@ export class DetailsComponent extends PageComponent implements OnInit, OnDestroy
onDestroy$ = new Subject<boolean>();
activeTab = 1;
aspectActions: Array<ContentActionRef> = [];
getIcon: string;
nodeIcon: string;

constructor(private route: ActivatedRoute, private contentApi: ContentApiService, private thumbnailService: ThumbnailService) {
super();
Expand All @@ -88,7 +88,7 @@ export class DetailsComponent extends PageComponent implements OnInit, OnDestroy
this.contentApi.getNode(this.nodeId).subscribe((node) => {
this.node = node.entry;
this.isLoading = false;
this.getNodeIcon(this.node);
this.nodeIcon = this.thumbnailService.getNodeIcon(this.node);
this.store.dispatch(new SetSelectedNodesAction([{ entry: this.node }]));
});
});
Expand All @@ -100,10 +100,6 @@ export class DetailsComponent extends PageComponent implements OnInit, OnDestroy
});
}

getNodeIcon(node: Node): void {
this.getIcon = this.thumbnailService.getNodeIcon(node);
}

setActiveTab(tabName: string) {
switch (tabName) {
case 'comments':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ import { AppStore, EditOfflineAction, infoDrawerMetadataAspect, NodeActionTypes
import { AppConfigService, NotificationService } from '@alfresco/adf-core';
import { Observable, Subject } from 'rxjs';
import { Store } from '@ngrx/store';
import { ContentMetadataModule, ContentMetadataService, ContentMetadataCustomPanel } from '@alfresco/adf-content-services';
import {
ContentMetadataModule,
ContentMetadataService,
ContentMetadataCustomPanel,
TagService,
CategoryService
} from '@alfresco/adf-content-services';
import { filter, map, takeUntil } from 'rxjs/operators';
import { CommonModule } from '@angular/common';
import { Actions, ofType } from '@ngrx/effects';
Expand All @@ -45,6 +51,8 @@ import { Actions, ofType } from '@ngrx/effects';
[node]="node"
[displayAspect]="displayAspect$ | async"
[customPanels]="customPanels | async"
[displayCategories]="displayCategories"
[displayTags]="displayTags"
>
</adf-content-metadata>
`,
Expand All @@ -53,21 +61,33 @@ import { Actions, ofType } from '@ngrx/effects';
})
export class MetadataTabComponent implements OnInit, OnDestroy {
protected onDestroy$ = new Subject<boolean>();
private _displayCategories = true;
private _displayTags = true;

@Input()
node: Node;

displayAspect$: Observable<string>;
readOnly = false;
customPanels: Observable<ContentMetadataCustomPanel[]>;

get displayCategories(): boolean {
return this._displayCategories;
}
get displayTags(): boolean {
return this._displayTags;
}

constructor(
private permission: NodePermissionService,
protected extensions: AppExtensionService,
private appConfig: AppConfigService,
private store: Store<AppStore>,
private notificationService: NotificationService,
private contentMetadataService: ContentMetadataService,
private actions$: Actions
private actions$: Actions,
private tagService: TagService,
private categoryService: CategoryService
) {
if (this.extensions.contentMetadata) {
this.appConfig.config['content-metadata'].presets = this.extensions.contentMetadata.presets;
Expand All @@ -76,6 +96,9 @@ export class MetadataTabComponent implements OnInit, OnDestroy {
}

ngOnInit() {
this._displayTags = this.tagService.areTagsEnabled();
this._displayCategories = this.categoryService.areCategoriesEnabled();

this.contentMetadataService.error.pipe(takeUntil(this.onDestroy$)).subscribe((err: { message: string }) => {
this.notificationService.showError(err.message);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { AppStore } from '@alfresco/aca-shared/store';
import {
ContentActionType,
ExtensionConfig,
ExtensionLoaderService,
ExtensionService,
filterEnabled,
mergeArrays,
Expand All @@ -53,6 +54,7 @@ describe('AppExtensionService', () => {
let logService: LogService;
let iconRegistry: MatIconRegistry;
let sanitizer: DomSanitizer;
let loader: ExtensionLoaderService;

beforeEach(() => {
TestBed.configureTestingModule({
Expand All @@ -70,6 +72,7 @@ describe('AppExtensionService', () => {

extensions = TestBed.inject(ExtensionService);
logService = TestBed.inject(LogService);
loader = TestBed.inject(ExtensionLoaderService);
});

const applyConfig = (config: ExtensionConfig, selection?: boolean) => {
Expand Down Expand Up @@ -1836,9 +1839,9 @@ describe('AppExtensionService', () => {
});
});

it('should update the sidebarActions', () => {
spyOn(service, 'updateSidebarActions').and.callThrough();
it('should update sidebar actions correctly', () => {
spyOn(loader, 'getContentActions').and.callThrough();
service.updateSidebarActions();
expect(service.updateSidebarActions).toHaveBeenCalled();
expect(loader.getContentActions).toHaveBeenCalledWith(service.config, 'features.sidebar.toolbar');
});
});

0 comments on commit 1665d74

Please sign in to comment.