mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
* Updated ACA to Angular 16 * Updated Subject types to void in cases where no values was being emitted * [ACS-8375] [ACA] [General] Selecting a checkbox gives a light green color on focus (#3937) * [ACS-8376] [ACA] [[Manage Rules] Multiple UI issues in create rule dialog (#3943) * [ACS-8378] Fixed inputs having fill styling throughout ACA (#3944) * [ACS-8378] Mat form fields now have white background instead of grey * [ACS-8378] Fixed issue where the background of the boolean mode control dropdown was appearing as white when in condition groups. Labels in create rules window are now black * [ACS-8415] Sidenav labels are now grey (#3946) * [ACS-8379] Fixed issue where icons in menus were coming as black after ng16 upgrade (#3935) * refactor DI into inject() methods (#3954) * Cleanup and remove unneeded commits and changes * Fix eslint (#4032) * [REVERTABLE] - this is a quick temp fix to be able to release ACA with NG16 * [MIGRATION] - added some fix after rebase * Refactor AppEffects (#4079) * Refactor effects to use inject() (#4080) * Refactor effects to use inject() (#4081) * Rebase fixes * [ACS-8739] Fix e2e tests (#4106) * Updated ADF deps * Fixed unit passing mandatory value * Updated ADF version * Updated ADF version * [ACS-8743] [ADW] click on search button open a blank page (#4125) * Updating ADF dep * Updating ADF * Refactor injections in effects (#4137) * Upstream dependencies * Refactor SearchAiEffects * Updating ADF and rebased * Rebased and updated * Rebased and updated * Updating deps * Updating deps * Updating deps * Rebased and updated deps * Pushing package-lock.json * Moved the JWT storage injection token at app level * Updated dependencies * Fixed unit test * Improved solutio for token with no need to set it explicitly * Updating dependencies * Updated package version * Updated ADF deps * Use latest ADF --------- Co-authored-by: swapnil.verma <swapnil.verma@globallogic.com> Co-authored-by: swapnil-verma-gl <92505353+swapnil-verma-gl@users.noreply.github.com> Co-authored-by: VitoAlbano <vito.albano.123@gmail.com> Co-authored-by: Ehsan Rezaei <ehsan.rezaei@hyland.com> Co-authored-by: MichalKinas <michal.kinas@hyland.com>
211 lines
7.1 KiB
TypeScript
211 lines
7.1 KiB
TypeScript
/*!
|
|
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
|
|
*
|
|
* Alfresco Example Content Application
|
|
*
|
|
* This file is part of the Alfresco Example Content Application.
|
|
* If the software was purchased under a paid Alfresco license, the terms of
|
|
* the paid license agreement will prevail. Otherwise, the software is
|
|
* provided under the following open source license terms:
|
|
*
|
|
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
import { ContentActionRef, SidebarTabRef } from '@alfresco/adf-extensions';
|
|
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
import { Store } from '@ngrx/store';
|
|
import { SetInfoDrawerStateAction, ToggleInfoDrawerAction } from '@alfresco/aca-shared/store';
|
|
import { EMPTY, of, Subject } from 'rxjs';
|
|
import { InfoDrawerComponent } from './info-drawer.component';
|
|
import { LibTestingModule } from '../../testing/lib-testing-module';
|
|
import { AppExtensionService } from '../../services/app.extension.service';
|
|
import { ContentApiService } from '../../services/content-api.service';
|
|
import { ContentService } from '@alfresco/adf-content-services';
|
|
import { RedirectAuthService } from '@alfresco/adf-core';
|
|
|
|
describe('InfoDrawerComponent', () => {
|
|
let fixture: ComponentFixture<InfoDrawerComponent>;
|
|
let component: InfoDrawerComponent;
|
|
let contentApiService: ContentApiService;
|
|
let contentService: ContentService;
|
|
let tab: SidebarTabRef;
|
|
let appExtensionService: AppExtensionService;
|
|
const mockStream = new Subject();
|
|
const storeMock = {
|
|
dispatch: jasmine.createSpy('dispatch'),
|
|
select: () => mockStream
|
|
};
|
|
const extensionServiceMock = {
|
|
getSidebarTabs: () => {},
|
|
getAllowedSidebarActions: () =>
|
|
of([
|
|
{
|
|
id: 'app.sidebar.close',
|
|
order: 100,
|
|
title: 'close',
|
|
icon: 'highlight_off'
|
|
}
|
|
])
|
|
};
|
|
|
|
beforeEach(() => {
|
|
TestBed.configureTestingModule({
|
|
imports: [LibTestingModule, InfoDrawerComponent],
|
|
providers: [
|
|
{ provide: AppExtensionService, useValue: extensionServiceMock },
|
|
{ provide: Store, useValue: storeMock },
|
|
{ provide: RedirectAuthService, useValue: { onLogin: EMPTY, onTokenReceived: EMPTY } }
|
|
],
|
|
schemas: [NO_ERRORS_SCHEMA]
|
|
});
|
|
|
|
fixture = TestBed.createComponent(InfoDrawerComponent);
|
|
component = fixture.componentInstance;
|
|
appExtensionService = TestBed.inject(AppExtensionService);
|
|
contentApiService = TestBed.inject(ContentApiService);
|
|
contentService = TestBed.inject(ContentService);
|
|
tab = { title: 'tab1', id: 'tab1', component: '' };
|
|
spyOn(appExtensionService, 'getSidebarTabs').and.returnValue([tab]);
|
|
});
|
|
|
|
afterEach(() => {
|
|
fixture.destroy();
|
|
});
|
|
|
|
it('should get tabs configuration on initialization', () => {
|
|
fixture.detectChanges();
|
|
|
|
expect(component.tabs).toEqual([tab]);
|
|
});
|
|
|
|
it('should set state to false OnDestroy event', () => {
|
|
fixture.detectChanges();
|
|
component.ngOnDestroy();
|
|
|
|
expect(storeMock.dispatch).toHaveBeenCalledWith(new SetInfoDrawerStateAction(false));
|
|
});
|
|
|
|
it('should set displayNode when node is library', () => {
|
|
spyOn(contentApiService, 'getNodeInfo');
|
|
const nodeMock: any = {
|
|
entry: { id: 'nodeId' },
|
|
isLibrary: true
|
|
};
|
|
component.node = nodeMock;
|
|
|
|
fixture.detectChanges();
|
|
component.ngOnChanges();
|
|
|
|
expect(component.displayNode).toBe(nodeMock);
|
|
expect(contentApiService.getNodeInfo).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it('should call getNodeInfo() when node is a shared file', () => {
|
|
const response: any = { entry: { id: 'nodeId' } };
|
|
spyOn(contentApiService, 'getNodeInfo').and.returnValue(of(response));
|
|
const nodeMock: any = { entry: { nodeId: 'nodeId' }, isLibrary: false };
|
|
component.node = nodeMock;
|
|
|
|
fixture.detectChanges();
|
|
component.ngOnChanges();
|
|
|
|
expect(component.displayNode).toBe(response);
|
|
expect(contentApiService.getNodeInfo).toHaveBeenCalled();
|
|
});
|
|
|
|
it('should call getNodeInfo() when node is a favorite file', () => {
|
|
const response: any = { entry: { id: 'nodeId' } };
|
|
spyOn(contentApiService, 'getNodeInfo').and.returnValue(of(response));
|
|
const nodeMock: any = {
|
|
entry: { id: 'nodeId', guid: 'guidId' },
|
|
isLibrary: false
|
|
};
|
|
component.node = nodeMock;
|
|
|
|
fixture.detectChanges();
|
|
component.ngOnChanges();
|
|
|
|
expect(component.displayNode).toBe(response);
|
|
expect(contentApiService.getNodeInfo).toHaveBeenCalled();
|
|
});
|
|
|
|
it('should call getNodeInfo() when node is a recent file', () => {
|
|
const response: any = { entry: { id: 'nodeId' } };
|
|
spyOn(contentApiService, 'getNodeInfo').and.returnValue(of(response));
|
|
|
|
const nodeMock: any = {
|
|
entry: {
|
|
id: 'nodeId',
|
|
content: { mimeType: 'image/jpeg' }
|
|
},
|
|
isLibrary: false
|
|
};
|
|
component.node = nodeMock;
|
|
|
|
fixture.detectChanges();
|
|
component.ngOnChanges();
|
|
|
|
expect(component.displayNode).toBe(response);
|
|
expect(component.node.entry).toBe(response);
|
|
expect(contentApiService.getNodeInfo).toHaveBeenCalled();
|
|
});
|
|
|
|
it('should dispatch close panel on Esc keyboard event', () => {
|
|
const event = new KeyboardEvent('keydown', {
|
|
code: 'Escape',
|
|
key: 'Escape',
|
|
keyCode: 27
|
|
} as KeyboardEventInit);
|
|
|
|
fixture.detectChanges();
|
|
|
|
fixture.debugElement.nativeElement.dispatchEvent(event);
|
|
|
|
expect(storeMock.dispatch).toHaveBeenCalledWith(new ToggleInfoDrawerAction());
|
|
});
|
|
|
|
it('should show the icons from extension', () => {
|
|
fixture.detectChanges();
|
|
mockStream.next({});
|
|
expect(component.actions).toEqual([
|
|
{
|
|
id: 'app.sidebar.close',
|
|
order: 100,
|
|
title: 'close',
|
|
icon: 'highlight_off'
|
|
} as ContentActionRef
|
|
]);
|
|
});
|
|
|
|
it('should get node icon for documents', () => {
|
|
const expectedIcon = 'assets/images/ft_ic_folder';
|
|
const response: any = { entry: { id: 'nodeId' } };
|
|
spyOn(contentApiService, 'getNodeInfo').and.returnValue(of(response));
|
|
spyOn(contentService, 'getNodeIcon').and.returnValue(expectedIcon);
|
|
const nodeMock: any = {
|
|
entry: { id: 'nodeId', guid: 'guidId' },
|
|
isFolder: true
|
|
};
|
|
component.node = nodeMock;
|
|
|
|
fixture.detectChanges();
|
|
component.ngOnChanges();
|
|
|
|
expect(contentService.getNodeIcon).toHaveBeenCalledWith(response);
|
|
expect(component.icon).toBe(expectedIcon);
|
|
expect(contentApiService.getNodeInfo).toHaveBeenCalled();
|
|
});
|
|
});
|