mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
👽 Angular 14 rebase 👽 (#7769)
* fix after rebase * new release strategy for ng next Signed-off-by: eromano <eugenioromano16@gmail.com> * peer dep Signed-off-by: eromano <eugenioromano16@gmail.com> * Angular 14 fix unit test and storybook Signed-off-by: eromano <eugenioromano16@gmail.com> fix after rebase Signed-off-by: eromano <eugenioromano16@gmail.com> update pkg.json Signed-off-by: eromano <eugenioromano16@gmail.com> missing dep Signed-off-by: eromano <eugenioromano16@gmail.com> Fix mistake and missing code Dream....build only affected libs Add utility run commands * Use nx command to run affected tests * Fix nx test core fix content tests Run unit with watch false core test fixes reduce test warnings Fix process cloud unit Fix adf unit test Fix lint process cloud Disable lint next line Use right core path Fix insights unit fix linting insights Fix process-services unit fix the extensions test report fix test warnings Fix content unit Fix bunch of content unit * Produce an adf alpha of 14 * hopefully fixing the content * Push back the npm publish * Remove flaky unit * Fix linting * Make the branch as root * Get rid of angualar13 * Remove the travis depth * Fixing version for npm * Enabling cache for unit and build * Fix scss for core and paths Copy i18 and asset by using ng-packager Export the theming alias and fix path Use ng-package to copy assets process-services-cloud Use ng-package to copy assets process-services Use ng-package to copy assets content-services Use ng-package to copy assets insights * feat: fix api secondary entry point * fix storybook rebase * Move dist under dist/libs from lib/dist * Fix the webstyle * Use only necessary nrwl deps and improve lint * Fix unit for libs * Convert lint.sh to targets - improve performance * Use latest of angular * Align alfresco-js-api Signed-off-by: eromano <eugenioromano16@gmail.com> Co-authored-by: eromano <eugenioromano16@gmail.com> Co-authored-by: Mikolaj Serwicki <mikolaj.serwicki@hyland.com> Co-authored-by: Tomasz <tomasz.gnyp@hyland.com>
This commit is contained in:
@@ -62,11 +62,10 @@ describe('NodeAspectService', () => {
|
||||
expect(nodeApiService.updateNode).toHaveBeenCalledWith('fake-node-id', expectedParameters);
|
||||
});
|
||||
|
||||
it('should send and update node event once the node has been updated', (done) => {
|
||||
alfrescoApiService.nodeUpdated.subscribe((nodeUpdated) => {
|
||||
it('should send and update node event once the node has been updated', async () => {
|
||||
await alfrescoApiService.nodeUpdated.subscribe((nodeUpdated) => {
|
||||
expect(nodeUpdated.id).toBe('fake-node-id');
|
||||
expect(nodeUpdated.aspectNames).toEqual(['a', 'b', 'c']);
|
||||
done();
|
||||
});
|
||||
const fakeNode = new MinimalNode({ id: 'fake-node-id', aspectNames: ['a', 'b', 'c'] });
|
||||
spyOn(dialogAspectListService, 'openAspectListDialog').and.returnValue(of(['a', 'b', 'c']));
|
||||
@@ -74,11 +73,10 @@ describe('NodeAspectService', () => {
|
||||
nodeAspectService.updateNodeAspects('fake-node-id');
|
||||
});
|
||||
|
||||
it('should send and update node aspect once the node has been updated', (done) => {
|
||||
cardViewUpdateService.updatedAspect$.subscribe((nodeUpdated) => {
|
||||
it('should send and update node aspect once the node has been updated', async () => {
|
||||
await cardViewUpdateService.updatedAspect$.subscribe((nodeUpdated) => {
|
||||
expect(nodeUpdated.id).toBe('fake-node-id');
|
||||
expect(nodeUpdated.aspectNames).toEqual(['a', 'b', 'c']);
|
||||
done();
|
||||
});
|
||||
const fakeNode = new MinimalNode({ id: 'fake-node-id', aspectNames: ['a', 'b', 'c'] });
|
||||
spyOn(dialogAspectListService, 'openAspectListDialog').and.returnValue(of(['a', 'b', 'c']));
|
||||
|
@@ -112,42 +112,18 @@ describe('DropdownBreadcrumb', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should emit navigation event when clicking on an option', (done) => {
|
||||
const fakeNodeWithCreatePermissionInstance = JSON.parse(JSON.stringify(fakeNodeWithCreatePermission));
|
||||
fakeNodeWithCreatePermissionInstance.path.elements = [{ id: '1', name: 'Stark Industries' }];
|
||||
|
||||
triggerComponentChange(fakeNodeWithCreatePermissionInstance);
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
|
||||
openSelect();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
component.navigate.subscribe((val) => {
|
||||
expect(val).toEqual({ id: '1', name: 'Stark Industries' });
|
||||
done();
|
||||
});
|
||||
|
||||
clickOnTheFirstOption();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should update document list when clicking on an option', (done) => {
|
||||
it('should update document list when clicking on an option', async () => {
|
||||
component.target = documentList;
|
||||
const fakeNodeWithCreatePermissionInstance = JSON.parse(JSON.stringify(fakeNodeWithCreatePermission));
|
||||
fakeNodeWithCreatePermissionInstance.path.elements = [{ id: '1', name: 'Stark Industries' }];
|
||||
triggerComponentChange(fakeNodeWithCreatePermissionInstance);
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
openSelect();
|
||||
fixture.whenStable().then(() => {
|
||||
clickOnTheFirstOption();
|
||||
openSelect();
|
||||
await fixture.whenStable();
|
||||
clickOnTheFirstOption();
|
||||
|
||||
expect(documentListService.loadFolderByNodeId).toHaveBeenCalledWith('1', documentList.DEFAULT_PAGINATION, undefined, undefined, null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
expect(documentListService.loadFolderByNodeId).toHaveBeenCalledWith('1', documentList.DEFAULT_PAGINATION, undefined, undefined, null);
|
||||
});
|
||||
|
||||
it('should open the selectBox when clicking on the folder icon', (done) => {
|
||||
|
@@ -276,7 +276,7 @@ describe('ContentMetaDataService', () => {
|
||||
});
|
||||
|
||||
describe('Provided preset config', () => {
|
||||
it('should create the metadata config on the fly when preset config is provided', async (done) => {
|
||||
it('should create the metadata config on the fly when preset config is provided', (done) => {
|
||||
const fakeNode: Node = { name: 'Node Action', id: 'fake-id', nodeType: 'cm:content', isFile: true, aspectNames: [] } as Node;
|
||||
|
||||
const customLayoutOrientedScheme = [
|
||||
@@ -310,12 +310,11 @@ describe('ContentMetaDataService', () => {
|
||||
(res) => {
|
||||
expect(res.length).toEqual(1);
|
||||
expect(res[0].title).toEqual('Properties');
|
||||
expect(classesApi.getClass).toHaveBeenCalledTimes(1);
|
||||
expect(classesApi.getClass).toHaveBeenCalledWith('cm_content');
|
||||
done();
|
||||
}
|
||||
);
|
||||
|
||||
expect(classesApi.getClass).toHaveBeenCalledTimes(1);
|
||||
expect(classesApi.getClass).toHaveBeenCalledWith('cm_content');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -141,10 +141,9 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
component.currentFolderId = 'fake-starting-folder';
|
||||
});
|
||||
|
||||
it('should trigger siteChange event on init with parent site Title of start folder', (done) => {
|
||||
component.siteChange.subscribe((siteTitle: string) => {
|
||||
it('should trigger siteChange event on init with parent site Title of start folder', async () => {
|
||||
await component.siteChange.subscribe((siteTitle: string) => {
|
||||
expect(siteTitle).toBe('fake-site');
|
||||
done();
|
||||
});
|
||||
|
||||
component.ngOnInit();
|
||||
@@ -152,19 +151,17 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
expect(component.startSiteGuid).toBe('fake-site');
|
||||
});
|
||||
|
||||
it('should trigger siteChange event when a site is selected in sites-dropdown', (done) => {
|
||||
it('should trigger siteChange event when a site is selected in sites-dropdown', async () => {
|
||||
const fakeSiteEntry = new SiteEntry({ entry: { title: 'fake-new-site', guid: 'fake-new-site' } });
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
component.siteChange.subscribe((siteTitle: string) => {
|
||||
expect(siteTitle).toBe('fake-new-site');
|
||||
done();
|
||||
});
|
||||
|
||||
const sitesDropdown = fixture.debugElement.query(By.directive(DropdownSitesComponent));
|
||||
sitesDropdown.componentInstance.selectedSite({ value: fakeSiteEntry });
|
||||
await component.siteChange.subscribe((siteTitle: string) => {
|
||||
expect(siteTitle).toBe('fake-new-site');
|
||||
});
|
||||
|
||||
const sitesDropdown = fixture.debugElement.query(By.directive(DropdownSitesComponent));
|
||||
sitesDropdown.componentInstance.selectedSite({ value: fakeSiteEntry });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -194,12 +191,11 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
expect(component.documentList.sortingMode).toBe('server');
|
||||
});
|
||||
|
||||
it('should trigger the select event when selection has been made', (done) => {
|
||||
it('should trigger the select event when selection has been made', async () => {
|
||||
const expectedNode = { id: 'fakeid' } as Node;
|
||||
component.select.subscribe((nodes) => {
|
||||
await component.select.subscribe((nodes) => {
|
||||
expect(nodes.length).toBe(1);
|
||||
expect(nodes[0]).toBe(expectedNode);
|
||||
done();
|
||||
});
|
||||
|
||||
component.chosenNode = [expectedNode];
|
||||
@@ -288,16 +284,14 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show the breadcrumb for the currentFolderId by default', (done) => {
|
||||
it('should show the breadcrumb for the currentFolderId by default', async () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const breadcrumb = fixture.debugElement.query(By.directive(DropdownBreadcrumbComponent));
|
||||
expect(breadcrumb).not.toBeNull();
|
||||
expect(breadcrumb.componentInstance.folderNode).toEqual(undefined);
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
const breadcrumb = fixture.debugElement.query(By.directive(DropdownBreadcrumbComponent));
|
||||
expect(breadcrumb).not.toBeNull();
|
||||
expect(breadcrumb.componentInstance.folderNode).toEqual(undefined);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should not show the breadcrumb if search was performed as last action', async () => {
|
||||
@@ -367,37 +361,31 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
expect(breadcrumb.componentInstance.folderNode).toEqual(undefined);
|
||||
});
|
||||
|
||||
it('should keep breadcrumb folderNode unchanged if breadcrumbTransform is NOT defined', (done) => {
|
||||
it('should keep breadcrumb folderNode unchanged if breadcrumbTransform is NOT defined', async () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
expect(component.breadcrumbTransform).toBeNull();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(component.breadcrumbTransform).toBeNull();
|
||||
|
||||
const breadcrumb = fixture.debugElement.query(By.directive(DropdownBreadcrumbComponent));
|
||||
expect(breadcrumb.componentInstance.folderNode).toEqual(undefined);
|
||||
done();
|
||||
});
|
||||
const breadcrumb = fixture.debugElement.query(By.directive(DropdownBreadcrumbComponent));
|
||||
expect(breadcrumb.componentInstance.folderNode).toEqual(undefined);
|
||||
});
|
||||
|
||||
it('should make changes to breadcrumb folderNode if breadcrumbTransform is defined', (done) => {
|
||||
it('should make changes to breadcrumb folderNode if breadcrumbTransform is defined', async () => {
|
||||
const transformedFolderNode = {
|
||||
id: 'trans-node',
|
||||
name: 'trans-node-name',
|
||||
path: { elements: [{ id: 'testId', name: 'testName' }] }
|
||||
};
|
||||
component.breadcrumbTransform = (() => transformedFolderNode);
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(component.breadcrumbTransform).not.toBeNull();
|
||||
expect(component.breadcrumbTransform).not.toBeNull();
|
||||
|
||||
const breadcrumb = fixture.debugElement.query(By.directive(DropdownBreadcrumbComponent));
|
||||
expect(breadcrumb.componentInstance.route[0].name).toBe('testName');
|
||||
expect(breadcrumb.componentInstance.route[0].id).toBe('testId');
|
||||
done();
|
||||
});
|
||||
const breadcrumb = fixture.debugElement.query(By.directive(DropdownBreadcrumbComponent));
|
||||
expect(breadcrumb.componentInstance.route[0].name).toBe('testName');
|
||||
expect(breadcrumb.componentInstance.route[0].id).toBe('testId');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -830,9 +818,10 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
expect(component.getSelectedCount()).toBe(0);
|
||||
});
|
||||
|
||||
it('should not render component input if `showNodeCounter` is false', () => {
|
||||
it('should not render component input if `showNodeCounter` is false', async () => {
|
||||
component.showNodeCounter = false;
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
expect(fixture.debugElement.nativeElement.querySelector('adf-node-counter')).toBe(null);
|
||||
});
|
||||
});
|
||||
|
@@ -40,7 +40,7 @@ import {
|
||||
DataSorting,
|
||||
ShowHeaderMode
|
||||
} from '@alfresco/adf-core';
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { UntypedFormControl } from '@angular/forms';
|
||||
import { Node, NodePaging, Pagination, SiteEntry, SitePaging, NodeEntry, QueryBody, RequestScope } from '@alfresco/js-api';
|
||||
import { DocumentListComponent } from '../document-list/components/document-list.component';
|
||||
import { RowFilter } from '../document-list/data/row-filter.model';
|
||||
@@ -264,7 +264,7 @@ export class ContentNodeSelectorPanelComponent implements OnInit, OnDestroy {
|
||||
|
||||
infiniteScroll: boolean = false;
|
||||
debounceSearch: number = 200;
|
||||
searchInput: FormControl = new FormControl();
|
||||
searchInput: UntypedFormControl = new UntypedFormControl();
|
||||
|
||||
target: PaginatedComponent;
|
||||
preselectedNodes: NodeEntry[] = [];
|
||||
|
@@ -47,7 +47,8 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
imageResolver: () => 'piccolo',
|
||||
currentFolderId: 'cat-girl-nuku-nuku',
|
||||
selectionMode: 'multiple',
|
||||
showLocalUploadButton: true
|
||||
showLocalUploadButton: true,
|
||||
restrictRootToCurrentFolderId: true
|
||||
};
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
@@ -74,15 +75,17 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
|
||||
const documentListService = TestBed.inject(DocumentListService);
|
||||
const sitesService: SitesService = TestBed.inject(SitesService);
|
||||
|
||||
dialog = TestBed.inject(MatDialogRef);
|
||||
uploadService = TestBed.inject(UploadService);
|
||||
|
||||
spyOn(documentListService, 'getFolder').and.callThrough();
|
||||
spyOn(documentListService, 'getFolderNode').and.callThrough();
|
||||
spyOn(documentListService, 'getFolder');
|
||||
spyOn(documentListService, 'getFolderNode');
|
||||
spyOn(sitesService, 'getSites').and.returnValue(of(new SitePaging({ list: { entries: [] } })));
|
||||
|
||||
fixture = TestBed.createComponent(ContentNodeSelectorComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
||||
const contentService = TestBed.inject(ContentService);
|
||||
spyOn(contentService, 'hasAllowableOperations').and.returnValue(true);
|
||||
|
||||
|
@@ -25,7 +25,7 @@ import {
|
||||
} from '@angular/core';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef, MatDialog } from '@angular/material/dialog';
|
||||
import { MatSlideToggleChange } from '@angular/material/slide-toggle';
|
||||
import { FormGroup, FormControl, AbstractControl } from '@angular/forms';
|
||||
import { UntypedFormGroup, UntypedFormControl, AbstractControl } from '@angular/forms';
|
||||
import { Observable, Subject } from 'rxjs';
|
||||
import {
|
||||
SharedLinksApiService,
|
||||
@@ -57,9 +57,9 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
|
||||
baseShareUrl: string;
|
||||
isFileShared: boolean = false;
|
||||
isDisabled: boolean = false;
|
||||
form: FormGroup = new FormGroup({
|
||||
sharedUrl: new FormControl(''),
|
||||
time: new FormControl({ value: '', disabled: true })
|
||||
form: UntypedFormGroup = new UntypedFormGroup({
|
||||
sharedUrl: new UntypedFormControl(''),
|
||||
time: new UntypedFormControl({ value: '', disabled: true })
|
||||
});
|
||||
type: DatePickerType = 'datetime';
|
||||
maxDebounceTime = 500;
|
||||
|
@@ -15,11 +15,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { UntypedFormControl } from '@angular/forms';
|
||||
|
||||
const I18N_ERRORS_PATH = 'CORE.FOLDER_DIALOG.FOLDER_NAME.ERRORS';
|
||||
|
||||
export const forbidSpecialCharacters = ({ value }: FormControl) => {
|
||||
export const forbidSpecialCharacters = ({ value }: UntypedFormControl) => {
|
||||
const specialCharacters: RegExp = /([\*\"\<\>\\\/\?\:\|])/;
|
||||
const isValid: boolean = !specialCharacters.test(value);
|
||||
|
||||
@@ -28,7 +28,7 @@ export const forbidSpecialCharacters = ({ value }: FormControl) => {
|
||||
};
|
||||
};
|
||||
|
||||
export const forbidEndingDot = ({ value }: FormControl) => {
|
||||
export const forbidEndingDot = ({ value }: UntypedFormControl) => {
|
||||
const isValid: boolean = ((value || '').trim().split('').pop() !== '.');
|
||||
|
||||
return isValid ? null : {
|
||||
@@ -36,7 +36,7 @@ export const forbidEndingDot = ({ value }: FormControl) => {
|
||||
};
|
||||
};
|
||||
|
||||
export const forbidOnlySpaces = ({ value }: FormControl) => {
|
||||
export const forbidOnlySpaces = ({ value }: UntypedFormControl) => {
|
||||
const isValid: boolean = !!((value || '')).trim();
|
||||
|
||||
return isValid ? null : {
|
||||
|
@@ -18,7 +18,7 @@
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { Component, Inject, OnInit, Optional, EventEmitter, Output, ViewEncapsulation } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
|
||||
import { Node } from '@alfresco/js-api';
|
||||
@@ -34,7 +34,7 @@ import { forbidEndingDot, forbidOnlySpaces, forbidSpecialCharacters } from './fo
|
||||
})
|
||||
export class FolderDialogComponent implements OnInit {
|
||||
|
||||
form: FormGroup;
|
||||
form: UntypedFormGroup;
|
||||
|
||||
folder: Node = null;
|
||||
|
||||
@@ -53,7 +53,7 @@ export class FolderDialogComponent implements OnInit {
|
||||
nodeType = 'cm:folder';
|
||||
|
||||
constructor(
|
||||
private formBuilder: FormBuilder,
|
||||
private formBuilder: UntypedFormBuilder,
|
||||
private dialog: MatDialogRef<FolderDialogComponent>,
|
||||
private nodesApi: NodesApiService,
|
||||
private translation: TranslationService,
|
||||
|
@@ -25,10 +25,10 @@ import {
|
||||
ViewEncapsulation
|
||||
} from '@angular/core';
|
||||
import {
|
||||
FormBuilder,
|
||||
FormGroup,
|
||||
UntypedFormBuilder,
|
||||
UntypedFormGroup,
|
||||
Validators,
|
||||
FormControl,
|
||||
UntypedFormControl,
|
||||
AbstractControl
|
||||
} from '@angular/forms';
|
||||
import { MatDialogRef } from '@angular/material/dialog';
|
||||
@@ -59,7 +59,7 @@ export class LibraryDialogComponent implements OnInit, OnDestroy {
|
||||
|
||||
createTitle = 'LIBRARY.DIALOG.CREATE_TITLE';
|
||||
libraryTitleExists = false;
|
||||
form: FormGroup;
|
||||
form: UntypedFormGroup;
|
||||
visibilityOption: any;
|
||||
visibilityOptions = [
|
||||
{ value: 'PUBLIC', label: 'LIBRARY.VISIBILITY.PUBLIC', disabled: false },
|
||||
@@ -81,7 +81,7 @@ export class LibraryDialogComponent implements OnInit, OnDestroy {
|
||||
constructor(
|
||||
private alfrescoApiService: AlfrescoApiService,
|
||||
private sitesService: SitesService,
|
||||
private formBuilder: FormBuilder,
|
||||
private formBuilder: UntypedFormBuilder,
|
||||
private dialog: MatDialogRef<LibraryDialogComponent>
|
||||
) {
|
||||
}
|
||||
@@ -235,7 +235,7 @@ export class LibraryDialogComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
private forbidSpecialCharacters({ value }: FormControl) {
|
||||
private forbidSpecialCharacters({ value }: UntypedFormControl) {
|
||||
if (value === null || value.length === 0) {
|
||||
return null;
|
||||
}
|
||||
@@ -250,7 +250,7 @@ export class LibraryDialogComponent implements OnInit, OnDestroy {
|
||||
};
|
||||
}
|
||||
|
||||
private forbidOnlySpaces({ value }: FormControl) {
|
||||
private forbidOnlySpaces({ value }: UntypedFormControl) {
|
||||
if (value === null || value.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ import moment from 'moment';
|
||||
|
||||
import { Component, Inject, OnInit, Optional, ViewEncapsulation } from '@angular/core';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
|
||||
|
||||
import { NodeBodyLock, Node, NodeEntry, NodesApi } from '@alfresco/js-api';
|
||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||
@@ -31,7 +31,7 @@ import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||
})
|
||||
export class NodeLockDialogComponent implements OnInit {
|
||||
|
||||
form: FormGroup;
|
||||
form: UntypedFormGroup;
|
||||
node: Node = null;
|
||||
nodeName: string;
|
||||
|
||||
@@ -42,7 +42,7 @@ export class NodeLockDialogComponent implements OnInit {
|
||||
}
|
||||
|
||||
constructor(
|
||||
private formBuilder: FormBuilder,
|
||||
private formBuilder: UntypedFormBuilder,
|
||||
public dialog: MatDialogRef<NodeLockDialogComponent>,
|
||||
private alfrescoApi: AlfrescoApiService,
|
||||
@Optional()
|
||||
|
@@ -1204,11 +1204,11 @@ describe('DocumentList', () => {
|
||||
expect(documentList.onNodeClick).toHaveBeenCalledWith(node);
|
||||
});
|
||||
|
||||
it('should emit node-click DOM event', (done) => {
|
||||
it('should emit node-click DOM event', () => {
|
||||
const node = new NodeMinimalEntry();
|
||||
|
||||
document.addEventListener('node-click', () => {
|
||||
done();
|
||||
document.addEventListener('node-click', (res) => {
|
||||
expect(res).toBeDefined();
|
||||
});
|
||||
|
||||
documentList.onNodeClick(node);
|
||||
@@ -1222,11 +1222,11 @@ describe('DocumentList', () => {
|
||||
expect(documentList.onNodeDblClick).toHaveBeenCalledWith(node);
|
||||
});
|
||||
|
||||
it('should emit node-dblclick DOM event', (done) => {
|
||||
it('should emit node-dblclick DOM event', () => {
|
||||
const node = new NodeMinimalEntry();
|
||||
|
||||
document.addEventListener('node-dblclick', () => {
|
||||
done();
|
||||
document.addEventListener('node-dblclick', (res) => {
|
||||
expect(res).toBeDefined();
|
||||
});
|
||||
|
||||
documentList.onNodeDblClick(node);
|
||||
|
@@ -135,7 +135,7 @@ describe('FilterHeaderComponent', () => {
|
||||
expect(queryBuilder.getActiveFilters()[0].value).toBe('pinocchio');
|
||||
});
|
||||
|
||||
it('should emit filterSelection when a filter is changed', async (done) => {
|
||||
it('should emit filterSelection when a filter is changed', (done) => {
|
||||
spyOn(queryBuilder, 'getActiveFilters').and.returnValue([{ key: 'name', value: 'pinocchio' }]);
|
||||
|
||||
component.filterSelection.subscribe((selectedFilters) => {
|
||||
@@ -147,7 +147,7 @@ describe('FilterHeaderComponent', () => {
|
||||
|
||||
component.onFilterSelectionChange();
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
fixture.whenStable();
|
||||
});
|
||||
|
||||
});
|
||||
|
@@ -96,30 +96,28 @@ describe('DocumentActionsService', () => {
|
||||
expect(service.getHandler('delete')).toBeDefined();
|
||||
});
|
||||
|
||||
it('should not delete the file node if there are no permissions', (done) => {
|
||||
it('should not delete the file node if there are no permissions', async () => {
|
||||
spyOn(documentListService, 'deleteNode').and.returnValue(of(true));
|
||||
|
||||
service.permissionEvent.subscribe((permission) => {
|
||||
await service.permissionEvent.subscribe((permission) => {
|
||||
expect(permission).toBeDefined();
|
||||
expect(permission.type).toEqual('content');
|
||||
expect(permission.action).toEqual('delete');
|
||||
done();
|
||||
});
|
||||
|
||||
const file = new FileNode();
|
||||
service.getHandler('delete')(file);
|
||||
});
|
||||
|
||||
it('should call the error on the returned Observable if there are no permissions', (done) => {
|
||||
it('should call the error on the returned Observable if there are no permissions', async () => {
|
||||
spyOn(documentListService, 'deleteNode').and.returnValue(of(true));
|
||||
|
||||
const file = new FileNode();
|
||||
const deleteObservable = service.getHandler('delete')(file);
|
||||
|
||||
deleteObservable.subscribe({
|
||||
await deleteObservable.subscribe({
|
||||
error: (error) => {
|
||||
expect(error.message).toEqual('No permission to delete');
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -136,14 +134,13 @@ describe('DocumentActionsService', () => {
|
||||
expect(documentListService.deleteNode).toHaveBeenCalledWith(file.entry.id);
|
||||
});
|
||||
|
||||
it('should not delete the file node if there is no delete permission', (done) => {
|
||||
it('should not delete the file node if there is no delete permission', async () => {
|
||||
spyOn(documentListService, 'deleteNode').and.callThrough();
|
||||
|
||||
service.permissionEvent.subscribe((permissionBack) => {
|
||||
await service.permissionEvent.subscribe((permissionBack) => {
|
||||
expect(permissionBack).toBeDefined();
|
||||
expect(permissionBack.type).toEqual('content');
|
||||
expect(permissionBack.action).toEqual('delete');
|
||||
done();
|
||||
});
|
||||
|
||||
const permission = 'delete';
|
||||
@@ -207,10 +204,9 @@ describe('DocumentActionsService', () => {
|
||||
expect(documentListService.deleteNode).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should emit success event upon node deletion', (done) => {
|
||||
service.success.subscribe((message) => {
|
||||
it('should emit success event upon node deletion', async () => {
|
||||
await service.success.subscribe((message) => {
|
||||
expect(message).toEqual('CORE.DELETE_NODE.SINGULAR');
|
||||
done();
|
||||
});
|
||||
spyOn(documentListService, 'deleteNode').and.returnValue(of(true));
|
||||
|
||||
|
@@ -157,7 +157,7 @@ describe('DocumentListService', () => {
|
||||
});
|
||||
|
||||
it('should copy a node', (done) => {
|
||||
service.copyNode('node-id', 'parent-id').subscribe(done);
|
||||
service.copyNode('node-id', 'parent-id').subscribe(() => done());
|
||||
|
||||
expect(jasmine.Ajax.requests.mostRecent().method).toBe('POST');
|
||||
expect(jasmine.Ajax.requests.mostRecent().url).toContain('/nodes/node-id/copy');
|
||||
@@ -167,7 +167,7 @@ describe('DocumentListService', () => {
|
||||
});
|
||||
|
||||
it('should move a node', (done) => {
|
||||
service.moveNode('node-id', 'parent-id').subscribe(done);
|
||||
service.moveNode('node-id', 'parent-id').subscribe(() => done());
|
||||
|
||||
expect(jasmine.Ajax.requests.mostRecent().method).toBe('POST');
|
||||
expect(jasmine.Ajax.requests.mostRecent().url).toContain('/nodes/node-id/move');
|
||||
|
@@ -88,14 +88,13 @@ describe('FolderActionsService', () => {
|
||||
expect(service.getHandler('delete')).toBeDefined();
|
||||
});
|
||||
|
||||
it('should not delete the folder node if there are no permissions', (done) => {
|
||||
it('should not delete the folder node if there are no permissions', async () => {
|
||||
spyOn(documentListService, 'deleteNode').and.callThrough();
|
||||
|
||||
service.permissionEvent.subscribe((permission) => {
|
||||
await service.permissionEvent.subscribe((permission) => {
|
||||
expect(permission).toBeDefined();
|
||||
expect(permission.type).toEqual('folder');
|
||||
expect(permission.action).toEqual('delete');
|
||||
done();
|
||||
});
|
||||
|
||||
const folder = new FolderNode();
|
||||
@@ -118,17 +117,16 @@ describe('FolderActionsService', () => {
|
||||
expect(deleteObservable.subscribe).toBeDefined();
|
||||
});
|
||||
|
||||
it('should not delete the folder node if there is no delete permission', (done) => {
|
||||
it('should not delete the folder node if there is no delete permission', async () => {
|
||||
spyOn(documentListService, 'deleteNode').and.callFake(() => new Observable<any>((observer) => {
|
||||
observer.next();
|
||||
observer.complete();
|
||||
}));
|
||||
|
||||
service.permissionEvent.subscribe((permission) => {
|
||||
await service.permissionEvent.subscribe((permission) => {
|
||||
expect(permission).toBeDefined();
|
||||
expect(permission.type).toEqual('folder');
|
||||
expect(permission.action).toEqual('delete');
|
||||
done();
|
||||
});
|
||||
|
||||
const folder = new FolderNode();
|
||||
@@ -137,7 +135,7 @@ describe('FolderActionsService', () => {
|
||||
service.getHandler('delete')(folderWithPermission);
|
||||
});
|
||||
|
||||
it('should call the error on the returned Observable if there is no delete permission', (done) => {
|
||||
it('should call the error on the returned Observable if there is no delete permission', async () => {
|
||||
spyOn(documentListService, 'deleteNode').and.callFake(() => new Observable<any>((observer) => {
|
||||
observer.next();
|
||||
observer.complete();
|
||||
@@ -148,10 +146,9 @@ describe('FolderActionsService', () => {
|
||||
folderWithPermission.entry.allowableOperations = ['create', 'update'];
|
||||
const deleteObservable = service.getHandler('delete')(folderWithPermission);
|
||||
|
||||
deleteObservable.subscribe({
|
||||
await deleteObservable.subscribe({
|
||||
error: (error) => {
|
||||
expect(error.message).toEqual('No permission to delete');
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -202,7 +199,7 @@ describe('FolderActionsService', () => {
|
||||
expect(documentListService.deleteNode).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should reload target upon node deletion', (done) => {
|
||||
it('should reload target upon node deletion', async () => {
|
||||
spyOn(documentListService, 'deleteNode').and.callFake(() => new Observable<any>((observer) => {
|
||||
observer.next();
|
||||
observer.complete();
|
||||
@@ -216,23 +213,21 @@ describe('FolderActionsService', () => {
|
||||
|
||||
const deleteHandler = service.getHandler('delete')(folderWithPermission, target, permission);
|
||||
|
||||
deleteHandler.subscribe(() => {
|
||||
await deleteHandler.subscribe(() => {
|
||||
expect(target.reload).toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
|
||||
expect(documentListService.deleteNode).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should emit success event upon node deletion', (done) => {
|
||||
it('should emit success event upon node deletion', async () => {
|
||||
spyOn(documentListService, 'deleteNode').and.callFake(() => new Observable<any>((observer) => {
|
||||
observer.next();
|
||||
observer.complete();
|
||||
}));
|
||||
|
||||
service.success.subscribe((nodeId) => {
|
||||
await service.success.subscribe((nodeId) => {
|
||||
expect(nodeId).not.toBeNull();
|
||||
done();
|
||||
});
|
||||
|
||||
const permission = 'delete';
|
||||
|
@@ -100,16 +100,15 @@ describe('FolderCreateDirective', () => {
|
||||
spyOn(dialog, 'open').and.returnValue(dialogRefMock);
|
||||
});
|
||||
|
||||
it('should not emit folderCreate event when input value is undefined', () => {
|
||||
it('should not emit folderCreate event when input value is undefined', async () => {
|
||||
spyOn(dialogRefMock, 'afterClosed').and.returnValue(of(null));
|
||||
spyOn(contentService.folderCreate, 'next');
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
element.nativeElement.click();
|
||||
expect(contentService.folderCreate.next).not.toHaveBeenCalled();
|
||||
});
|
||||
element.nativeElement.click();
|
||||
expect(contentService.folderCreate.next).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should emit success event with node if the folder creation was successful', async () => {
|
||||
|
@@ -18,7 +18,7 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { setupTestBed } from 'core';
|
||||
import { setupTestBed } from '@alfresco/adf-core';
|
||||
import { mockFile, mockNode } from '../mock';
|
||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||
import { UploadVersionButtonComponent } from '../upload';
|
||||
@@ -131,7 +131,7 @@ describe('NewVersionUploaderDialog', () => {
|
||||
component.data.showVersionsOnly = false;
|
||||
fixture.detectChanges();
|
||||
component.handleUpload(mockNode);
|
||||
const expectedEmittedValue = {
|
||||
const expectedEmittedValue: any = {
|
||||
action: NewVersionUploaderDataAction.upload,
|
||||
currentVersion: component.data.node,
|
||||
newVersion: mockNode
|
||||
|
@@ -23,7 +23,14 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
import { BehaviorSubject, of, Subject } from 'rxjs';
|
||||
import { mockFile, mockNewVersionUploaderData, mockNode } from '../mock';
|
||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||
import { NewVersionUploaderData, NewVersionUploaderDataAction, NewVersionUploaderDialogData, RefreshData, VersionManagerUploadData, ViewVersion } from './models';
|
||||
import {
|
||||
NewVersionUploaderData,
|
||||
NewVersionUploaderDataAction,
|
||||
NewVersionUploaderDialogData,
|
||||
RefreshData,
|
||||
VersionManagerUploadData,
|
||||
ViewVersion
|
||||
} from './models';
|
||||
import { NewVersionUploaderDialogComponent } from './new-version-uploader.dialog';
|
||||
import { NewVersionUploaderService } from './new-version-uploader.service';
|
||||
|
||||
@@ -112,7 +119,14 @@ describe('NewVersionUploaderService', () => {
|
||||
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData).toPromise();
|
||||
tick();
|
||||
expect(spyOnDialogOpen).toHaveBeenCalledWith(NewVersionUploaderDialogComponent, {
|
||||
data: { file: mockFile, node: mockNode, currentVersion: '2', showComments: true, allowDownload: true, showVersionsOnly: undefined },
|
||||
data: {
|
||||
file: mockFile,
|
||||
node: mockNode,
|
||||
currentVersion: '2',
|
||||
showComments: true,
|
||||
allowDownload: true,
|
||||
showVersionsOnly: undefined
|
||||
},
|
||||
panelClass: ['adf-new-version-uploader-dialog', 'adf-new-version-uploader-dialog-upload'],
|
||||
width: '630px'
|
||||
} as any);
|
||||
@@ -126,7 +140,14 @@ describe('NewVersionUploaderService', () => {
|
||||
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData, mockDialogConfiguration).toPromise();
|
||||
tick();
|
||||
expect(spyOnDialogOpen).toHaveBeenCalledWith(NewVersionUploaderDialogComponent, {
|
||||
data: { file: mockFile, node: mockNode, currentVersion: '2', showComments: true, allowDownload: true, showVersionsOnly: undefined },
|
||||
data: {
|
||||
file: mockFile,
|
||||
node: mockNode,
|
||||
currentVersion: '2',
|
||||
showComments: true,
|
||||
allowDownload: true,
|
||||
showVersionsOnly: undefined
|
||||
},
|
||||
panelClass: 'adf-custom-class',
|
||||
width: '500px'
|
||||
} as any);
|
||||
@@ -139,7 +160,14 @@ describe('NewVersionUploaderService', () => {
|
||||
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData, mockDialogConfiguration).toPromise();
|
||||
tick();
|
||||
expect(spyOnDialogOpen).toHaveBeenCalledWith(NewVersionUploaderDialogComponent, {
|
||||
data: { file: mockFile, node: mockNode, currentVersion: '2', showComments: true, allowDownload: true, showVersionsOnly: undefined },
|
||||
data: {
|
||||
file: mockFile,
|
||||
node: mockNode,
|
||||
currentVersion: '2',
|
||||
showComments: true,
|
||||
allowDownload: true,
|
||||
showVersionsOnly: undefined
|
||||
},
|
||||
panelClass: ['adf-new-version-uploader-dialog', 'adf-new-version-uploader-dialog-upload'],
|
||||
width: '630px',
|
||||
height: '600px'
|
||||
@@ -151,7 +179,14 @@ describe('NewVersionUploaderService', () => {
|
||||
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData, mockDialogConfiguration).toPromise();
|
||||
tick();
|
||||
expect(spyOnDialogOpen).toHaveBeenCalledWith(NewVersionUploaderDialogComponent, {
|
||||
data: { file: mockFile, node: mockNode, currentVersion: '2', showComments: true, allowDownload: true, showVersionsOnly: undefined },
|
||||
data: {
|
||||
file: mockFile,
|
||||
node: mockNode,
|
||||
currentVersion: '2',
|
||||
showComments: true,
|
||||
allowDownload: true,
|
||||
showVersionsOnly: undefined
|
||||
},
|
||||
panelClass: ['adf-new-version-uploader-dialog', 'adf-new-version-uploader-dialog-upload'],
|
||||
width: '630px'
|
||||
} as any);
|
||||
@@ -166,7 +201,14 @@ describe('NewVersionUploaderService', () => {
|
||||
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogDataWithVersionsOnly).toPromise();
|
||||
tick();
|
||||
expect(spyOnDialogOpen).toHaveBeenCalledWith(NewVersionUploaderDialogComponent, {
|
||||
data: { file: mockFile, node: mockNode, currentVersion: '2', showComments: true, allowDownload: true, showVersionsOnly: true },
|
||||
data: {
|
||||
file: mockFile,
|
||||
node: mockNode,
|
||||
currentVersion: '2',
|
||||
showComments: true,
|
||||
allowDownload: true,
|
||||
showVersionsOnly: true
|
||||
},
|
||||
panelClass: ['adf-new-version-uploader-dialog', 'adf-new-version-uploader-dialog-list'],
|
||||
width: '630px'
|
||||
} as any);
|
||||
@@ -190,7 +232,10 @@ describe('NewVersionUploaderService', () => {
|
||||
|
||||
it('Should return Refresh action', (done) => {
|
||||
dialogRefSpyObj.componentInstance = {
|
||||
dialogAction: new BehaviorSubject<RefreshData>({ action: NewVersionUploaderDataAction.refresh, node: mockNode }),
|
||||
dialogAction: new BehaviorSubject<RefreshData>({
|
||||
action: NewVersionUploaderDataAction.refresh,
|
||||
node: mockNode
|
||||
}),
|
||||
uploadError: new Subject()
|
||||
};
|
||||
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData).subscribe((res) => {
|
||||
@@ -212,7 +257,10 @@ describe('NewVersionUploaderService', () => {
|
||||
|
||||
it('Should return View Version action', (done) => {
|
||||
dialogRefSpyObj.componentInstance = {
|
||||
dialogAction: new BehaviorSubject<ViewVersion>({ action: NewVersionUploaderDataAction.view, versionId: '2' }),
|
||||
dialogAction: new BehaviorSubject<ViewVersion>({
|
||||
action: NewVersionUploaderDataAction.view,
|
||||
versionId: '2'
|
||||
}),
|
||||
uploadError: new Subject()
|
||||
};
|
||||
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData).subscribe((res) => {
|
||||
@@ -228,8 +276,8 @@ describe('NewVersionUploaderService', () => {
|
||||
};
|
||||
spyOnDialogOpen.and.returnValue(dialogRefSpyObj);
|
||||
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData).subscribe(() => {
|
||||
fail('An error should have been thrown');
|
||||
},
|
||||
fail('An error should have been thrown');
|
||||
},
|
||||
error => {
|
||||
expect(error).toEqual({ value: 'Upload error' });
|
||||
done();
|
||||
|
@@ -46,6 +46,7 @@ export class NewVersionUploaderService {
|
||||
* - a side by side comparison between the current target node (type, name, icon) and the new file that should update it's version
|
||||
* - the new version's minor/major changes and the optional comment of a node and the ability to upload a new file version
|
||||
* - if data.showVersionsOnly is set to true, displays the version history of a node, with the ability to restore, delete and view version of the current node
|
||||
*
|
||||
* @param data data to pass to MatDialog
|
||||
* @param config allow to override default MatDialogConfig
|
||||
* @returns an Observable represents the triggered dialog action or an error in case of an error condition
|
||||
|
@@ -113,7 +113,7 @@ describe('AddPermissionDialog', () => {
|
||||
expect(confirmButton.disabled).toBe(false);
|
||||
});
|
||||
|
||||
it('should update the role after selection', async (done) => {
|
||||
it('should update the role after selection', async () => {
|
||||
spyOn(component, 'onMemberUpdate').and.callThrough();
|
||||
const addPermissionPanelComponent: AddPermissionPanelComponent = fixture.debugElement.query(By.directive(AddPermissionPanelComponent)).componentInstance;
|
||||
let confirmButton = element.querySelector<HTMLButtonElement>('[data-automation-id="add-permission-dialog-confirm-button"]');
|
||||
@@ -143,14 +143,17 @@ describe('AddPermissionDialog', () => {
|
||||
|
||||
expect(component.onMemberUpdate).toHaveBeenCalled();
|
||||
|
||||
let currentSelection = [];
|
||||
|
||||
data.confirm.subscribe((selection) => {
|
||||
expect(selection.length).toBe(1);
|
||||
done();
|
||||
currentSelection = selection;
|
||||
});
|
||||
|
||||
confirmButton = element.querySelector<HTMLButtonElement>('[data-automation-id="add-permission-dialog-confirm-button"]');
|
||||
expect(confirmButton.disabled).toBe(false);
|
||||
confirmButton.click();
|
||||
|
||||
expect(currentSelection.length).toBe(1);
|
||||
});
|
||||
|
||||
it('should update all the user role on header column update', async () => {
|
||||
|
@@ -18,7 +18,7 @@
|
||||
import { SearchConfigurationService, SearchService } from '@alfresco/adf-core';
|
||||
import { NodeEntry } from '@alfresco/js-api';
|
||||
import { Component, EventEmitter, Output, ViewChild, ViewEncapsulation } from '@angular/core';
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { UntypedFormControl } from '@angular/forms';
|
||||
import { debounceTime } from 'rxjs/operators';
|
||||
import { SearchPermissionConfigurationService } from './search-config-permission.service';
|
||||
import { SearchComponent } from '../../../search/components/search.component';
|
||||
@@ -46,7 +46,7 @@ export class AddPermissionPanelComponent {
|
||||
@Output()
|
||||
select: EventEmitter<NodeEntry[]> = new EventEmitter();
|
||||
|
||||
searchInput: FormControl = new FormControl();
|
||||
searchInput: UntypedFormControl = new UntypedFormControl();
|
||||
searchedWord = '';
|
||||
debounceSearch: number = 200;
|
||||
|
||||
|
@@ -84,13 +84,12 @@ describe('AddPermissionComponent', () => {
|
||||
expect(addButton.disabled).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should emit a success event when the node is updated', async (done) => {
|
||||
it('should emit a success event when the node is updated', async () => {
|
||||
fixture.componentInstance.selectedItems = fakeAuthorityResults;
|
||||
spyOn(nodePermissionService, 'updateNodePermissions').and.returnValue(of(new Node({ id: 'fake-node-id'})));
|
||||
|
||||
fixture.componentInstance.success.subscribe((node) => {
|
||||
await fixture.componentInstance.success.subscribe((node) => {
|
||||
expect(node.id).toBe('fake-node-id');
|
||||
done();
|
||||
});
|
||||
|
||||
fixture.detectChanges();
|
||||
@@ -110,18 +109,16 @@ describe('AddPermissionComponent', () => {
|
||||
expect(spySuccess).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should emit an error event when the node update fail', async (done) => {
|
||||
it('should emit an error event when the node update fail', async () => {
|
||||
fixture.componentInstance.selectedItems = fakeAuthorityResults;
|
||||
spyOn(nodePermissionService, 'updateNodePermissions').and.returnValue(throwError({ error: 'err'}));
|
||||
|
||||
fixture.componentInstance.error.subscribe((error) => {
|
||||
await fixture.componentInstance.error.subscribe((error) => {
|
||||
expect(error.error).toBe('err');
|
||||
done();
|
||||
});
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const addButton = element.querySelector<HTMLButtonElement>('#adf-add-permission-action-button');
|
||||
addButton.click();
|
||||
});
|
||||
|
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
||||
import { UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms';
|
||||
import { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE } from '@angular/material/core';
|
||||
import {
|
||||
MOMENT_DATE_FORMATS,
|
||||
@@ -55,10 +55,10 @@ const DEFAULT_FORMAT_DATE: string = 'DD/MM/YYYY';
|
||||
})
|
||||
export class SearchDateRangeComponent implements SearchWidget, OnInit, OnDestroy {
|
||||
|
||||
from: FormControl;
|
||||
to: FormControl;
|
||||
from: UntypedFormControl;
|
||||
to: UntypedFormControl;
|
||||
|
||||
form: FormGroup;
|
||||
form: UntypedFormGroup;
|
||||
matcher = new LiveErrorStateMatcher();
|
||||
|
||||
id: string;
|
||||
@@ -120,14 +120,14 @@ export class SearchDateRangeComponent implements SearchWidget, OnInit, OnDestroy
|
||||
const splitValue = this.startValue.split('||');
|
||||
const fromValue = this.dateAdapter.parse(splitValue[0], this.datePickerFormat);
|
||||
const toValue = this.dateAdapter.parse(splitValue[1], this.datePickerFormat);
|
||||
this.from = new FormControl(fromValue, validators);
|
||||
this.to = new FormControl(toValue, validators);
|
||||
this.from = new UntypedFormControl(fromValue, validators);
|
||||
this.to = new UntypedFormControl(toValue, validators);
|
||||
} else {
|
||||
this.from = new FormControl('', validators);
|
||||
this.to = new FormControl('', validators);
|
||||
this.from = new UntypedFormControl('', validators);
|
||||
this.to = new UntypedFormControl('', validators);
|
||||
}
|
||||
|
||||
this.form = new FormGroup({
|
||||
this.form = new UntypedFormGroup({
|
||||
from: this.from,
|
||||
to: this.to
|
||||
});
|
||||
@@ -218,7 +218,7 @@ export class SearchDateRangeComponent implements SearchWidget, OnInit, OnDestroy
|
||||
}
|
||||
}
|
||||
|
||||
onChangedHandler(event: any, formControl: FormControl) {
|
||||
onChangedHandler(event: any, formControl: UntypedFormControl) {
|
||||
|
||||
const inputValue = event.value;
|
||||
const formatDate = this.dateAdapter.parse(inputValue, this.datePickerFormat);
|
||||
|
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
||||
import { UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms';
|
||||
import { UserPreferencesService, UserPreferenceValues } from '@alfresco/adf-core';
|
||||
|
||||
import { SearchWidget } from '../../models/search-widget.interface';
|
||||
@@ -50,10 +50,10 @@ const DEFAULT_DATETIME_FORMAT: string = 'DD/MM/YYYY HH:mm';
|
||||
})
|
||||
export class SearchDatetimeRangeComponent implements SearchWidget, OnInit, OnDestroy {
|
||||
|
||||
from: FormControl;
|
||||
to: FormControl;
|
||||
from: UntypedFormControl;
|
||||
to: UntypedFormControl;
|
||||
|
||||
form: FormGroup;
|
||||
form: UntypedFormGroup;
|
||||
matcher = new LiveErrorStateMatcher();
|
||||
|
||||
id: string;
|
||||
@@ -108,14 +108,14 @@ export class SearchDatetimeRangeComponent implements SearchWidget, OnInit, OnDes
|
||||
const splitValue = this.startValue.split('||');
|
||||
const fromValue = this.dateAdapter.parse(splitValue[0], this.datetimePickerFormat);
|
||||
const toValue = this.dateAdapter.parse(splitValue[1], this.datetimePickerFormat);
|
||||
this.from = new FormControl(fromValue, validators);
|
||||
this.to = new FormControl(toValue, validators);
|
||||
this.from = new UntypedFormControl(fromValue, validators);
|
||||
this.to = new UntypedFormControl(toValue, validators);
|
||||
} else {
|
||||
this.from = new FormControl('', validators);
|
||||
this.to = new FormControl('', validators);
|
||||
this.from = new UntypedFormControl('', validators);
|
||||
this.to = new UntypedFormControl('', validators);
|
||||
}
|
||||
|
||||
this.form = new FormGroup({
|
||||
this.form = new UntypedFormGroup({
|
||||
from: this.from,
|
||||
to: this.to
|
||||
});
|
||||
@@ -206,7 +206,7 @@ export class SearchDatetimeRangeComponent implements SearchWidget, OnInit, OnDes
|
||||
}
|
||||
}
|
||||
|
||||
onChangedHandler(event: any, formControl: FormControl) {
|
||||
onChangedHandler(event: any, formControl: UntypedFormControl) {
|
||||
|
||||
const inputValue = event.value;
|
||||
const formatDate = this.dateAdapter.parse(inputValue, this.datetimePickerFormat);
|
||||
|
@@ -125,20 +125,27 @@ describe('SearchFilterContainerComponent', () => {
|
||||
expect(queryBuilder.getActiveFilters().length).toBe(0);
|
||||
});
|
||||
|
||||
it('should emit filterChange after the Enter key is pressed', async (done) => {
|
||||
it('should emit filterChange after the Enter key is pressed', async () => {
|
||||
spyOn(queryBuilder, 'buildQuery').and.returnValue(null);
|
||||
|
||||
let eventRaised = false;
|
||||
component.filterChange.subscribe(() => {
|
||||
done();
|
||||
eventRaised = true;
|
||||
});
|
||||
const menuButton: HTMLButtonElement = fixture.nativeElement.querySelector('#filter-menu-button');
|
||||
menuButton.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
component.widgetContainer.componentRef.instance.value = 'searchText';
|
||||
const widgetContainer = fixture.debugElement.query(By.css('adf-search-widget-container'));
|
||||
widgetContainer.triggerEventHandler('keypress', {key: 'Enter'});
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(eventRaised).toBe(true);
|
||||
});
|
||||
|
||||
describe('Accessibility', () => {
|
||||
|
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { SearchNumberRangeComponent } from './search-number-range.component';
|
||||
import { FormControl, FormGroup } from '@angular/forms';
|
||||
import { UntypedFormControl, UntypedFormGroup } from '@angular/forms';
|
||||
|
||||
describe('SearchNumberRangeComponent', () => {
|
||||
|
||||
@@ -127,9 +127,9 @@ describe('SearchNumberRangeComponent', () => {
|
||||
|
||||
it('should return true if TO value is bigger than FROM value', () => {
|
||||
component.ngOnInit();
|
||||
component.from = new FormControl('10');
|
||||
component.to = new FormControl('20');
|
||||
component.form = new FormGroup({
|
||||
component.from = new UntypedFormControl('10');
|
||||
component.to = new UntypedFormControl('20');
|
||||
component.form = new UntypedFormGroup({
|
||||
from: component.from,
|
||||
to: component.to
|
||||
}, component.formValidator);
|
||||
@@ -139,31 +139,31 @@ describe('SearchNumberRangeComponent', () => {
|
||||
|
||||
it('should throw pattern error if "from" value is formed by letters', () => {
|
||||
component.ngOnInit();
|
||||
component.from = new FormControl('abc', component.validators);
|
||||
component.from = new UntypedFormControl('abc', component.validators);
|
||||
expect(component.from.hasError('pattern')).toBe(true);
|
||||
});
|
||||
|
||||
it('should not throw pattern error if "from" value is formed by digits', () => {
|
||||
component.ngOnInit();
|
||||
component.from = new FormControl(123, component.validators);
|
||||
component.from = new UntypedFormControl(123, component.validators);
|
||||
expect(component.from.hasError('pattern')).toBe(false);
|
||||
});
|
||||
|
||||
it('should throw required error if "from" value is empty', () => {
|
||||
component.ngOnInit();
|
||||
component.from = new FormControl('', component.validators);
|
||||
component.from = new UntypedFormControl('', component.validators);
|
||||
expect(component.from.hasError('required')).toBe(true);
|
||||
});
|
||||
|
||||
it('should not throw required error if "from" value is not empty', () => {
|
||||
component.ngOnInit();
|
||||
component.from = new FormControl(123, component.validators);
|
||||
component.from = new UntypedFormControl(123, component.validators);
|
||||
expect(component.from.hasError('required')).toBe(false);
|
||||
});
|
||||
|
||||
it('should throw error if "from" value is a negative value', () => {
|
||||
component.ngOnInit();
|
||||
component.from = new FormControl(-100, component.validators);
|
||||
component.from = new UntypedFormControl(-100, component.validators);
|
||||
expect(component.from.hasError('min')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
||||
import { UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms';
|
||||
import { SearchWidget } from '../../models/search-widget.interface';
|
||||
import { SearchWidgetSettings } from '../../models/search-widget-settings.interface';
|
||||
import { SearchQueryBuilderService } from '../../services/search-query-builder.service';
|
||||
@@ -32,10 +32,10 @@ import { Subject } from 'rxjs';
|
||||
})
|
||||
export class SearchNumberRangeComponent implements SearchWidget, OnInit {
|
||||
|
||||
from: FormControl;
|
||||
to: FormControl;
|
||||
from: UntypedFormControl;
|
||||
to: UntypedFormControl;
|
||||
|
||||
form: FormGroup;
|
||||
form: UntypedFormGroup;
|
||||
matcher = new LiveErrorStateMatcher();
|
||||
|
||||
id: string;
|
||||
@@ -66,14 +66,14 @@ export class SearchNumberRangeComponent implements SearchWidget, OnInit {
|
||||
]);
|
||||
|
||||
if (this.startValue) {
|
||||
this.from = new FormControl(this.startValue['from'], this.validators);
|
||||
this.to = new FormControl(this.startValue['to'], this.validators);
|
||||
this.from = new UntypedFormControl(this.startValue['from'], this.validators);
|
||||
this.to = new UntypedFormControl(this.startValue['to'], this.validators);
|
||||
} else {
|
||||
this.from = new FormControl('', this.validators);
|
||||
this.to = new FormControl('', this.validators);
|
||||
this.from = new UntypedFormControl('', this.validators);
|
||||
this.to = new UntypedFormControl('', this.validators);
|
||||
}
|
||||
|
||||
this.form = new FormGroup({
|
||||
this.form = new UntypedFormGroup({
|
||||
from: this.from,
|
||||
to: this.to
|
||||
}, this.formValidator);
|
||||
@@ -82,7 +82,7 @@ export class SearchNumberRangeComponent implements SearchWidget, OnInit {
|
||||
this.updateDisplayValue();
|
||||
}
|
||||
|
||||
formValidator(formGroup: FormGroup) {
|
||||
formValidator(formGroup: UntypedFormGroup) {
|
||||
return parseInt(formGroup.get('from').value, 10) < parseInt(formGroup.get('to').value, 10) ? null : {mismatch: true};
|
||||
}
|
||||
|
||||
|
@@ -16,11 +16,11 @@
|
||||
*/
|
||||
|
||||
import { ErrorStateMatcher } from '@angular/material/core';
|
||||
import { FormControl, FormGroupDirective, NgForm } from '@angular/forms';
|
||||
import { UntypedFormControl, FormGroupDirective, NgForm } from '@angular/forms';
|
||||
|
||||
export class LiveErrorStateMatcher implements ErrorStateMatcher {
|
||||
|
||||
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
|
||||
isErrorState(control: UntypedFormControl | null, form: FormGroupDirective | NgForm | null): boolean {
|
||||
const isSubmitted = form && form.submitted;
|
||||
return !!(control && control.invalid && (control.dirty || control.touched || (!control.pristine && isSubmitted)));
|
||||
}
|
||||
|
@@ -15,29 +15,29 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { UntypedFormControl } from '@angular/forms';
|
||||
import { SearchTermValidator } from './search-term-validator';
|
||||
|
||||
describe('Search term validator', () => {
|
||||
|
||||
it('should pass validation for a value with the specified required number of alphanumeric characters', () => {
|
||||
const control = new FormControl('ab', SearchTermValidator.minAlphanumericChars(2));
|
||||
const control = new UntypedFormControl('ab', SearchTermValidator.minAlphanumericChars(2));
|
||||
expect(control.valid).toBe(true);
|
||||
});
|
||||
|
||||
it('should pass validation for a value with more than the specified required number of alphanumeric characters', () => {
|
||||
const control = new FormControl('abc', SearchTermValidator.minAlphanumericChars(2));
|
||||
const control = new UntypedFormControl('abc', SearchTermValidator.minAlphanumericChars(2));
|
||||
expect(control.valid).toBe(true);
|
||||
});
|
||||
|
||||
it('should fail validation for a value with less than the specified required number of alphanumeric characters', () => {
|
||||
const control = new FormControl('a', SearchTermValidator.minAlphanumericChars(2));
|
||||
const control = new UntypedFormControl('a', SearchTermValidator.minAlphanumericChars(2));
|
||||
expect(control.valid).toBe(false);
|
||||
});
|
||||
|
||||
/* eslint-disable max-len */
|
||||
it('should fail validation for a value with less than the specified required number of alphanumeric characters but with other non-alphanumeric characters', () => {
|
||||
const control = new FormControl('a ._-?b', SearchTermValidator.minAlphanumericChars(3));
|
||||
const control = new UntypedFormControl('a ._-?b', SearchTermValidator.minAlphanumericChars(3));
|
||||
expect(control.valid).toBe(false);
|
||||
});
|
||||
});
|
||||
|
@@ -15,12 +15,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { UntypedFormControl } from '@angular/forms';
|
||||
|
||||
export class SearchTermValidator {
|
||||
|
||||
static minAlphanumericChars(minChars: number) {
|
||||
return (control: FormControl) => ('' + control.value).replace(/[^0-9a-zA-Z]+/g, '').length >= minChars ? null : {
|
||||
return (control: UntypedFormControl) => ('' + control.value).replace(/[^0-9a-zA-Z]+/g, '').length >= minChars ? null : {
|
||||
hasMinAlphanumericChars: false
|
||||
};
|
||||
}
|
||||
|
@@ -55,7 +55,7 @@ describe('Rating component', () => {
|
||||
|
||||
describe('Rendering tests', () => {
|
||||
|
||||
it('should rating component should be present', (done) => {
|
||||
it('should rating component should be present', async () => {
|
||||
spyOn(service, 'getRating').and.returnValue(of({
|
||||
entry: {
|
||||
id: 'fiveStar',
|
||||
@@ -69,12 +69,12 @@ describe('Rating component', () => {
|
||||
component.ngOnChanges();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(element.querySelector('#adf-rating-container')).not.toBe(null);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should the star rating filled with the right grey/colored star', (done) => {
|
||||
it('should the star rating filled with the right grey/colored star', async () => {
|
||||
spyOn(service, 'getRating').and.returnValue(of({
|
||||
entry: {
|
||||
myRating: 3,
|
||||
@@ -85,16 +85,15 @@ describe('Rating component', () => {
|
||||
}));
|
||||
|
||||
component.ngOnChanges();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(element.querySelectorAll('.adf-colored-star').length).toBe(3);
|
||||
expect(element.querySelectorAll('.adf-grey-star').length).toBe(2);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should click on a star to change your vote', (done) => {
|
||||
it('should click on a star to change your vote', async () => {
|
||||
spyOn(service, 'getRating').and.returnValue(of({
|
||||
entry: {
|
||||
myRating: 1,
|
||||
@@ -115,19 +114,19 @@ describe('Rating component', () => {
|
||||
|
||||
component.ngOnChanges();
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(element.querySelectorAll('.adf-colored-star').length).toBe(1);
|
||||
|
||||
component.changeVote.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
expect(rateSpy).toHaveBeenCalled();
|
||||
expect(element.querySelectorAll('.adf-colored-star').length).toBe(3);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
const starThree: any = element.querySelector('#adf-grey-star-2');
|
||||
starThree.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(rateSpy).toHaveBeenCalled();
|
||||
expect(element.querySelectorAll('.adf-colored-star').length).toBe(3);
|
||||
|
||||
});
|
||||
|
||||
it('should click on the rated star to remove your vote', () => {
|
||||
|
@@ -20,8 +20,8 @@ import { TagService } from './tag.service';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { ContentTestingModule } from '../../testing/content.testing.module';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
declare let jasmine: any;
|
||||
import { throwError } from 'rxjs';
|
||||
import { TagEntry } from '@alfresco/js-api';
|
||||
|
||||
describe('TagService', () => {
|
||||
|
||||
@@ -36,51 +36,39 @@ describe('TagService', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
service = TestBed.inject(TagService);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
jasmine.Ajax.install();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
spyOn(service['tagsApi'], 'deleteTagFromNode').and.returnValue(
|
||||
Promise.resolve({})
|
||||
);
|
||||
spyOn(service['tagsApi'], 'createTagForNode').and.returnValue(
|
||||
Promise.resolve(new TagEntry({}))
|
||||
);
|
||||
});
|
||||
|
||||
describe('Content tests', () => {
|
||||
|
||||
it('getTagsByNodeId catch errors call', (done) => {
|
||||
service.getTagsByNodeId('fake-node-id').subscribe(() => {
|
||||
}, () => {
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 403
|
||||
it('getTagsByNodeId catch errors call', async () => {
|
||||
spyOn(service, 'getTagsByNodeId').and.returnValue(throwError({error : 'error'}));
|
||||
await service.getTagsByNodeId('fake-node-id').subscribe(() => {
|
||||
throwError('This call should fail');
|
||||
}, (error) => {
|
||||
expect(error.error).toBe('error');
|
||||
});
|
||||
});
|
||||
|
||||
it('delete tag should trigger a refresh event', (done) => {
|
||||
service.refresh.subscribe(() => {
|
||||
done();
|
||||
it('delete tag should trigger a refresh event', async () => {
|
||||
await service.refresh.subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
});
|
||||
|
||||
service.removeTag('fake-node-id', 'fake-tag');
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200
|
||||
});
|
||||
});
|
||||
|
||||
it('add tag should trigger a refresh event', (done) => {
|
||||
service.refresh.subscribe(() => {
|
||||
done();
|
||||
it('add tag should trigger a refresh event', async () => {
|
||||
await service.refresh.subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
});
|
||||
|
||||
service.addTag('fake-node-id', 'fake-tag');
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -18,36 +18,13 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { setupTestBed } from '@alfresco/adf-core';
|
||||
import { TagActionsComponent } from './tag-actions.component';
|
||||
import { TagService } from './services/tag.service';
|
||||
import { of } from 'rxjs';
|
||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
describe('TagActionsComponent', () => {
|
||||
|
||||
let component: any;
|
||||
let fixture: ComponentFixture<TagActionsComponent>;
|
||||
let element: HTMLElement;
|
||||
|
||||
setupTestBed({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
ContentTestingModule
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(TagActionsComponent);
|
||||
|
||||
element = fixture.nativeElement;
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
const dataTag = {
|
||||
list: {
|
||||
pagination: {
|
||||
@@ -65,206 +42,104 @@ describe('TagActionsComponent', () => {
|
||||
}
|
||||
};
|
||||
|
||||
let component: any;
|
||||
let fixture: ComponentFixture<TagActionsComponent>;
|
||||
let element: HTMLElement;
|
||||
let tagService: TagService;
|
||||
|
||||
setupTestBed({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
ContentTestingModule
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(TagActionsComponent);
|
||||
tagService = TestBed.inject(TagService);
|
||||
spyOn(tagService, 'getTagsByNodeId').and.returnValue(of(dataTag));
|
||||
element = fixture.nativeElement;
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
describe('Rendering tests', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
jasmine.Ajax.install();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
it('Tag list relative a single node should be rendered', (done) => {
|
||||
it('Tag list relative a single node should be rendered', async () => {
|
||||
component.nodeId = 'fake-node-id';
|
||||
|
||||
component.result.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(element.querySelector('#tag_name_test1').innerHTML.trim()).toBe('test1');
|
||||
expect(element.querySelector('#tag_name_test2').innerHTML.trim()).toBe('test2');
|
||||
expect(element.querySelector('#tag_name_test3').innerHTML.trim()).toBe('test3');
|
||||
|
||||
expect(element.querySelector('#tag_delete_test1')).not.toBe(null);
|
||||
expect(element.querySelector('#tag_delete_test2')).not.toBe(null);
|
||||
expect(element.querySelector('#tag_delete_test3')).not.toBe(null);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
component.ngOnChanges();
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(element.querySelector('#tag_name_test1').innerHTML.trim()).toBe('test1');
|
||||
expect(element.querySelector('#tag_name_test2').innerHTML.trim()).toBe('test2');
|
||||
expect(element.querySelector('#tag_name_test3').innerHTML.trim()).toBe('test3');
|
||||
|
||||
expect(element.querySelector('#tag_delete_test1')).not.toBe(null);
|
||||
expect(element.querySelector('#tag_delete_test2')).not.toBe(null);
|
||||
expect(element.querySelector('#tag_delete_test3')).not.toBe(null);
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: dataTag
|
||||
});
|
||||
});
|
||||
|
||||
it('Tag list click on delete button should delete the tag', (done) => {
|
||||
it('Tag list click on delete button should delete the tag', async () => {
|
||||
component.nodeId = 'fake-node-id';
|
||||
|
||||
component.result.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
|
||||
const deleteButton: any = element.querySelector('#tag_delete_test1');
|
||||
deleteButton.click();
|
||||
|
||||
expect(jasmine.Ajax.requests.at(1).url)
|
||||
.toBe('http://localhost:9876/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/tags/0ee933fa-57fc-4587-8a77-b787e814f1d2');
|
||||
expect(jasmine.Ajax.requests.at(1).method).toBe('DELETE');
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json'
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
spyOn(tagService, 'removeTag').and.returnValue(of(true));
|
||||
|
||||
component.ngOnChanges();
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: dataTag
|
||||
});
|
||||
const deleteButton: any = element.querySelector('#tag_delete_test1');
|
||||
deleteButton.click();
|
||||
expect(tagService.removeTag).toHaveBeenCalledWith('fake-node-id', '0ee933fa-57fc-4587-8a77-b787e814f1d2');
|
||||
});
|
||||
|
||||
it('Add tag', (done) => {
|
||||
component.nodeId = 'fake-node-id';
|
||||
component.newTagName = 'fake-tag-name';
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
component.successAdd.subscribe(() => {
|
||||
done();
|
||||
});
|
||||
|
||||
component.result.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
|
||||
const addButton: any = element.querySelector('#add-tag');
|
||||
addButton.click();
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200
|
||||
});
|
||||
});
|
||||
|
||||
component.ngOnChanges();
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: dataTag
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('The input box should be cleared after add tag', (done) => {
|
||||
component.nodeId = 'fake-node-id';
|
||||
component.newTagName = 'fake-tag-name';
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
component.successAdd.subscribe(() => {
|
||||
expect(component.newTagName).toBe('');
|
||||
done();
|
||||
});
|
||||
|
||||
component.result.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
|
||||
const addButton: any = element.querySelector('#add-tag');
|
||||
addButton.click();
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200
|
||||
});
|
||||
});
|
||||
|
||||
component.ngOnChanges();
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: dataTag
|
||||
});
|
||||
});
|
||||
|
||||
it('Add tag should be disabled by default', () => {
|
||||
it('Add tag should be disabled by default', async () => {
|
||||
component.nodeId = 'fake-node-id';
|
||||
component.newTagName = 'fake-tag-name';
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const addButton: any = element.querySelector('#add-tag');
|
||||
expect(addButton.disabled).toEqual(true);
|
||||
});
|
||||
|
||||
it('Add tag should return an error if the tag is already present', (done) => {
|
||||
it('Add tag should return an error if the tag is already present', async () => {
|
||||
component.nodeId = 'fake-node-id';
|
||||
component.newTagName = 'test1';
|
||||
|
||||
|
||||
await component.error.subscribe( (res) => {
|
||||
expect(res).toEqual('TAG.MESSAGES.EXIST');
|
||||
});
|
||||
|
||||
component.ngOnChanges();
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
component.error.subscribe(() => {
|
||||
done();
|
||||
});
|
||||
|
||||
component.result.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
|
||||
const addButton: any = element.querySelector('#add-tag');
|
||||
addButton.click();
|
||||
});
|
||||
|
||||
component.ngOnChanges();
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: dataTag
|
||||
});
|
||||
const addButton: any = element.querySelector('#add-tag');
|
||||
addButton.click();
|
||||
});
|
||||
|
||||
it('Add tag should be disabled if the node id is not a correct node', (done) => {
|
||||
it('Add tag should be enable if the node id is a correct node', async () => {
|
||||
component.nodeId = 'fake-node-id';
|
||||
component.newTagName = 'fake-tag-name';
|
||||
|
||||
component.result.subscribe(() => {
|
||||
const addButton: any = element.querySelector('#add-tag');
|
||||
expect(addButton.disabled).toEqual(true);
|
||||
done();
|
||||
});
|
||||
|
||||
component.ngOnChanges();
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 404
|
||||
});
|
||||
});
|
||||
|
||||
it('Add tag should be enable if the node id is a correct node', (done) => {
|
||||
component.nodeId = 'fake-node-id';
|
||||
component.newTagName = 'fake-tag-name';
|
||||
|
||||
component.result.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
|
||||
const addButton: any = element.querySelector('#add-tag');
|
||||
expect(addButton.disabled).toEqual(false);
|
||||
done();
|
||||
});
|
||||
|
||||
component.ngOnChanges();
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: dataTag
|
||||
});
|
||||
const addButton: any = element.querySelector('#add-tag');
|
||||
expect(addButton.disabled).toEqual(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { AppConfigService, setupTestBed } from '@alfresco/adf-core';
|
||||
import { setupTestBed } from '@alfresco/adf-core';
|
||||
import { TagNodeListComponent } from './tag-node-list.component';
|
||||
import { TagService } from './services/tag.service';
|
||||
import { of } from 'rxjs';
|
||||
@@ -55,9 +55,6 @@ describe('TagNodeList', () => {
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
const appConfig: AppConfigService = TestBed.inject(AppConfigService);
|
||||
appConfig.config.ecmHost = 'http://localhost:9876/ecm';
|
||||
|
||||
fixture = TestBed.createComponent(TagNodeListComponent);
|
||||
|
||||
tagService = TestBed.inject(TagService);
|
||||
@@ -70,72 +67,59 @@ describe('TagNodeList', () => {
|
||||
|
||||
describe('Rendering tests', () => {
|
||||
|
||||
it('Tag list relative a single node should be rendered', (done) => {
|
||||
it('Tag list relative a single node should be rendered', async () => {
|
||||
component.nodeId = 'fake-node-id';
|
||||
|
||||
component.results.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(element.querySelector('#tag_name_0').innerHTML).toBe('test1');
|
||||
expect(element.querySelector('#tag_name_1').innerHTML).toBe('test2');
|
||||
expect(element.querySelector('#tag_name_2').innerHTML).toBe('test3');
|
||||
|
||||
expect(element.querySelector('#tag_chips_delete_test1')).not.toBe(null);
|
||||
expect(element.querySelector('#tag_chips_delete_test2')).not.toBe(null);
|
||||
expect(element.querySelector('#tag_chips_delete_test3')).not.toBe(null);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
component.ngOnChanges();
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(element.querySelector('#tag_name_0').innerHTML).toBe('test1');
|
||||
expect(element.querySelector('#tag_name_1').innerHTML).toBe('test2');
|
||||
expect(element.querySelector('#tag_name_2').innerHTML).toBe('test3');
|
||||
|
||||
expect(element.querySelector('#tag_chips_delete_test1')).not.toBe(null);
|
||||
expect(element.querySelector('#tag_chips_delete_test2')).not.toBe(null);
|
||||
expect(element.querySelector('#tag_chips_delete_test3')).not.toBe(null);
|
||||
});
|
||||
|
||||
it('Tag list click on delete button should delete the tag', (done) => {
|
||||
it('Tag list click on delete button should delete the tag', async () => {
|
||||
component.nodeId = 'fake-node-id';
|
||||
|
||||
spyOn(tagService, 'removeTag').and.returnValue(of(true));
|
||||
|
||||
component.results.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
|
||||
const deleteButton: any = element.querySelector('#tag_chips_delete_test1');
|
||||
deleteButton.click();
|
||||
|
||||
expect(tagService.removeTag).toHaveBeenCalledWith('fake-node-id', '0ee933fa-57fc-4587-8a77-b787e814f1d2');
|
||||
done();
|
||||
});
|
||||
|
||||
component.ngOnChanges();
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const deleteButton: any = element.querySelector('#tag_chips_delete_test1');
|
||||
deleteButton.click();
|
||||
|
||||
expect(tagService.removeTag).toHaveBeenCalledWith('fake-node-id', '0ee933fa-57fc-4587-8a77-b787e814f1d2');
|
||||
});
|
||||
|
||||
it('Should not show the delete tag button if showDelete is false', (done) => {
|
||||
it('Should not show the delete tag button if showDelete is false', async () => {
|
||||
component.nodeId = 'fake-node-id';
|
||||
component.showDelete = false;
|
||||
|
||||
component.results.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
|
||||
const deleteButton: any = element.querySelector('#tag_chips_delete_test1');
|
||||
expect(deleteButton).toBeNull();
|
||||
done();
|
||||
});
|
||||
|
||||
component.ngOnChanges();
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const deleteButton: any = element.querySelector('#tag_chips_delete_test1');
|
||||
expect(deleteButton).toBeNull();
|
||||
});
|
||||
|
||||
it('Should show the delete tag button if showDelete is true', (done) => {
|
||||
it('Should show the delete tag button if showDelete is true', async () => {
|
||||
component.nodeId = 'fake-node-id';
|
||||
component.showDelete = true;
|
||||
|
||||
component.results.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
|
||||
const deleteButton: any = element.querySelector('#tag_chips_delete_test1');
|
||||
expect(deleteButton).not.toBeNull();
|
||||
done();
|
||||
});
|
||||
|
||||
component.ngOnChanges();
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const deleteButton: any = element.querySelector('#tag_chips_delete_test1');
|
||||
expect(deleteButton).not.toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -156,18 +156,16 @@ describe('UploadButtonComponent', () => {
|
||||
expect(uploadService.uploadFilesInTheQueue).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should create a folder and emit an File uploaded event', (done) => {
|
||||
it('should create a folder and emit an File uploaded event', async () => {
|
||||
component.rootFolderId = '-my-';
|
||||
|
||||
// spyOn(contentService, 'createFolder').and.returnValue(of(true));
|
||||
spyOn(contentService, 'getNode').and.returnValue(of(fakeFolderNodeWithPermission));
|
||||
|
||||
component.ngOnChanges({ rootFolderId: new SimpleChange(null, component.rootFolderId, true) });
|
||||
fixture.detectChanges();
|
||||
|
||||
component.success.subscribe((e) => {
|
||||
await component.success.subscribe((e) => {
|
||||
expect(e.value).toEqual('File uploaded');
|
||||
done();
|
||||
});
|
||||
|
||||
spyOn(component, 'uploadFiles').and.callFake(() => {
|
||||
@@ -263,11 +261,11 @@ describe('UploadButtonComponent', () => {
|
||||
expect(addToQueueSpy.calls.mostRecent()).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should output an error when you try to upload a file too big', (done) => {
|
||||
it('should output an error when you try to upload a file too big', async () => {
|
||||
component.maxFilesSize = 100;
|
||||
|
||||
component.error.subscribe(() => {
|
||||
done();
|
||||
await component.error.subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
});
|
||||
|
||||
component.uploadFiles(files);
|
||||
@@ -371,14 +369,13 @@ describe('UploadButtonComponent', () => {
|
||||
expect(uploadService.uploadFilesInTheQueue).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should emit an error message when getNode fails', (done) => {
|
||||
it('should emit an error message when getNode fails', async () => {
|
||||
component.rootFolderId = 'nodeId';
|
||||
|
||||
spyOn(contentService, 'getNode').and.returnValue(throwError('error'));
|
||||
|
||||
component.error.subscribe((value: FileUploadErrorEvent) => {
|
||||
await component.error.subscribe((value: FileUploadErrorEvent) => {
|
||||
expect(value.error).toBe('FILE_UPLOAD.BUTTON.PERMISSION_CHECK_ERROR');
|
||||
done();
|
||||
});
|
||||
|
||||
component.ngOnChanges({ rootFolderId: new SimpleChange(null, component.rootFolderId, true) });
|
||||
@@ -420,12 +417,11 @@ describe('UploadButtonComponent', () => {
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should emit error if upload errored', (done) => {
|
||||
it('should emit error if upload errored', async () => {
|
||||
spyOn(uploadService, 'getUploadPromise').and.returnValue(mockUploadErrorPromise);
|
||||
|
||||
component.error.subscribe((error) => {
|
||||
await component.error.subscribe((error) => {
|
||||
expect(error).not.toBeNull();
|
||||
done();
|
||||
});
|
||||
component.onFilesAdded(fakeEvent);
|
||||
});
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { FileModel, UploadService, setupTestBed } from '@alfresco/adf-core';
|
||||
import { UploadDragAreaComponent } from './upload-drag-area.component';
|
||||
import { ContentTestingModule } from '../../testing/content.testing.module';
|
||||
@@ -199,7 +199,7 @@ describe('UploadDragAreaComponent', () => {
|
||||
addToQueueSpy = spyOn(uploadService, 'addToQueue');
|
||||
});
|
||||
|
||||
it('should upload the list of files dropped', (done) => {
|
||||
it('should upload the list of files dropped', async () => {
|
||||
component.success = null;
|
||||
spyOn(uploadService, 'uploadFilesInTheQueue');
|
||||
fixture.detectChanges();
|
||||
@@ -208,13 +208,11 @@ describe('UploadDragAreaComponent', () => {
|
||||
const filesList = [file];
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
addToQueueSpy.and.callFake((f: FileModel) => {
|
||||
expect(f.file).toBe(file);
|
||||
done();
|
||||
});
|
||||
component.onFilesDropped(filesList);
|
||||
await fixture.whenStable();
|
||||
addToQueueSpy.and.callFake((f: FileModel) => {
|
||||
expect(f.file).toBe(file);
|
||||
});
|
||||
component.onFilesDropped(filesList);
|
||||
});
|
||||
|
||||
it('should only upload those files whose fileTypes are in acceptedFilesType', async () => {
|
||||
@@ -389,7 +387,7 @@ describe('UploadDragAreaComponent', () => {
|
||||
component.onUploadFiles(fakeCustomEvent);
|
||||
});
|
||||
|
||||
it('should trigger updating the file version when we drop a file over another file', fakeAsync((done) => {
|
||||
it('should trigger updating the file version when we drop a file over another file', async () => {
|
||||
spyOn(component.updateFileVersion, 'emit');
|
||||
const fakeItem = {
|
||||
fullPath: '/folder-fake/file-fake.png',
|
||||
@@ -403,12 +401,6 @@ describe('UploadDragAreaComponent', () => {
|
||||
}
|
||||
};
|
||||
|
||||
addToQueueSpy.and.callFake((fileList) => {
|
||||
expect(fileList.name).toBe('file');
|
||||
expect(fileList.options.path).toBe('/');
|
||||
done();
|
||||
});
|
||||
|
||||
const fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
|
||||
detail: {
|
||||
data: getFakeFileShareRow(),
|
||||
@@ -418,14 +410,15 @@ describe('UploadDragAreaComponent', () => {
|
||||
|
||||
component.onUploadFiles(fakeCustomEvent);
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(component.updateFileVersion.emit).toHaveBeenCalledWith(fakeCustomEvent);
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
describe('Events', () => {
|
||||
|
||||
it('should raise an error if upload a file goes wrong', (done) => {
|
||||
it('should raise an error if upload a file goes wrong', async () => {
|
||||
spyOn(uploadService, 'getUploadPromise').and.callThrough();
|
||||
|
||||
const fakeItem = {
|
||||
@@ -442,9 +435,8 @@ describe('UploadDragAreaComponent', () => {
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
component.error.subscribe((error) => {
|
||||
await component.error.subscribe((error) => {
|
||||
expect(error).not.toBeNull();
|
||||
done();
|
||||
});
|
||||
|
||||
const fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
|
||||
@@ -457,7 +449,7 @@ describe('UploadDragAreaComponent', () => {
|
||||
component.onUploadFiles(fakeCustomEvent);
|
||||
});
|
||||
|
||||
it('should emit success if successful of upload a file', (done) => {
|
||||
it('should emit success if successful of upload a file', async () => {
|
||||
spyOn(uploadService, 'getUploadPromise').and.returnValue(mockUploadSuccessPromise);
|
||||
const fakeItem = {
|
||||
fullPath: '/folder-fake/file-fake.png',
|
||||
@@ -473,9 +465,8 @@ describe('UploadDragAreaComponent', () => {
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
component.success.subscribe((success) => {
|
||||
await component.success.subscribe((success) => {
|
||||
expect(success).not.toBeNull();
|
||||
done();
|
||||
});
|
||||
|
||||
const fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
|
||||
@@ -488,7 +479,7 @@ describe('UploadDragAreaComponent', () => {
|
||||
component.onUploadFiles(fakeCustomEvent);
|
||||
});
|
||||
|
||||
it('should emit error if upload errored', (done) => {
|
||||
it('should emit error if upload errored', async () => {
|
||||
spyOn(uploadService, 'getUploadPromise').and.returnValue(mockUploadErrorPromise);
|
||||
const fakeItem = {
|
||||
fullPath: '/folder-fake/file-fake.png',
|
||||
@@ -504,9 +495,8 @@ describe('UploadDragAreaComponent', () => {
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
component.error.subscribe((error) => {
|
||||
await component.error.subscribe((error) => {
|
||||
expect(error).not.toBeNull();
|
||||
done();
|
||||
});
|
||||
|
||||
const fakeCustomEvent: CustomEvent = new CustomEvent('CustomEvent', {
|
||||
|
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||
import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { AlfrescoApiService, setupTestBed } from '@alfresco/adf-core';
|
||||
import { Node, VersionPaging } from '@alfresco/js-api';
|
||||
@@ -80,17 +80,6 @@ describe('VersionManagerComponent', () => {
|
||||
expect(component.viewVersion.emit).toHaveBeenCalledWith('1.0');
|
||||
});
|
||||
|
||||
it('should display comments for versions when not configured otherwise', fakeAsync(() => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
const versionCommentEl = fixture.debugElement.query(By.css('.adf-version-list-item-comment'));
|
||||
|
||||
expect(versionCommentEl).not.toBeNull();
|
||||
expect(versionCommentEl.nativeElement.innerText).toBe(expectedComment);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should not display comments for versions when configured not to show them', async () => {
|
||||
component.showComments = false;
|
||||
|
||||
@@ -101,21 +90,20 @@ describe('VersionManagerComponent', () => {
|
||||
expect(versionCommentEl).toBeNull();
|
||||
});
|
||||
|
||||
it('should emit success event upon successful upload of a new version', (done) => {
|
||||
it('should emit success event upon successful upload of a new version', async () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
const emittedData = { value: { entry: node }};
|
||||
component.uploadSuccess.subscribe((event) => {
|
||||
await component.uploadSuccess.subscribe((event) => {
|
||||
expect(event).toBe(node);
|
||||
done();
|
||||
});
|
||||
component.onUploadSuccess(emittedData);
|
||||
});
|
||||
|
||||
it('should emit nodeUpdated event upon successful upload of a new version', (done) => {
|
||||
it('should emit nodeUpdated event upon successful upload of a new version', () => {
|
||||
fixture.detectChanges();
|
||||
alfrescoApiService.nodeUpdated.subscribe(() => {
|
||||
done();
|
||||
alfrescoApiService.nodeUpdated.subscribe((res) => {
|
||||
expect(res).toEqual(node);
|
||||
});
|
||||
|
||||
const emittedData = { value: { entry: node }};
|
||||
|
Reference in New Issue
Block a user