mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
Adjust ADF to latest JS-API version (#8882)
* Bump js-api version * Fix imports * Fix content-services unit tests * Fix process-services unit tests * [ci:force] Trigger CI * Fix code smells * Fix orderBy param * Fix code smells * Fix failing unit tests * Bump js-api version and align with new changes * Remove dangling coma * Fix delete return type * Add correct date format in task filters e2es * Fix typing in task filter sorting * Fix activiti content api import * Add null check for has avatar * Make User class instead of type * Fix user type in comment model * Fix sonar cloud issue * Type fixes * Update js-api version
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
|
||||
import { PersonEntry, Person, PersonPaging } from '@alfresco/js-api';
|
||||
|
||||
export const fakeEcmUser = {
|
||||
export const fakeEcmUser: Person = {
|
||||
id: 'fake-id',
|
||||
firstName: 'fake-ecm-first-name',
|
||||
lastName: 'fake-ecm-last-name',
|
||||
@@ -32,7 +32,7 @@ export const fakeEcmUser = {
|
||||
location: 'fake location',
|
||||
mobile: '000000000',
|
||||
telephone: '11111111',
|
||||
statusUpdatedAt: 'fake-date',
|
||||
statusUpdatedAt: new Date(),
|
||||
userStatus: 'active',
|
||||
enabled: true,
|
||||
emailNotificationsEnabled: true
|
||||
|
@@ -18,7 +18,7 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { ContentService } from './content.service';
|
||||
import { AppConfigService, AuthenticationService, StorageService, CoreTestingModule } from '@alfresco/adf-core';
|
||||
import { Node } from '@alfresco/js-api';
|
||||
import { Node, PermissionsInfo } from '@alfresco/js-api';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
declare let jasmine: any;
|
||||
@@ -140,12 +140,12 @@ describe('ContentService', () => {
|
||||
});
|
||||
|
||||
it('should havePermission return true if the permissions is empty and the permission to check is Consumer', () => {
|
||||
const permissionNode = new Node({ permissions: [] });
|
||||
const permissionNode = new Node({ permissions: new PermissionsInfo() });
|
||||
expect(contentService.hasPermissions(permissionNode, 'Consumer', 'user1')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should havePermission return false if the permissions is empty and the permission to check is not Consumer', () => {
|
||||
const permissionNode = new Node({ permissions: [] });
|
||||
const permissionNode = new Node({ permissions: new PermissionsInfo() });
|
||||
expect(contentService.hasPermissions(permissionNode, '!Consumer', 'user1')).toBeFalsy();
|
||||
});
|
||||
|
||||
|
@@ -321,7 +321,7 @@ describe('UploadService', () => {
|
||||
},
|
||||
undefined,
|
||||
undefined,
|
||||
{ newVersion: true },
|
||||
{ newVersion: true, name: 'fake-name', nodeType: undefined },
|
||||
{
|
||||
renditions: 'doclib',
|
||||
include: ['allowableOperations'],
|
||||
@@ -376,7 +376,7 @@ describe('UploadService', () => {
|
||||
},
|
||||
undefined,
|
||||
undefined,
|
||||
{ newVersion: false },
|
||||
{ newVersion: false, name: 'file-name', nodeType: undefined },
|
||||
{
|
||||
include: [ 'allowableOperations' ],
|
||||
renditions: 'doclib',
|
||||
@@ -402,7 +402,7 @@ describe('UploadService', () => {
|
||||
},
|
||||
undefined,
|
||||
undefined,
|
||||
{ newVersion: false },
|
||||
{ newVersion: false, name: 'file-name', nodeType: undefined },
|
||||
{
|
||||
include: [ 'allowableOperations' ],
|
||||
renditions: 'doclib',
|
||||
@@ -434,6 +434,8 @@ describe('UploadService', () => {
|
||||
'123',
|
||||
{
|
||||
newVersion: false,
|
||||
name: 'fake-name',
|
||||
nodeType: undefined,
|
||||
parentId: '123',
|
||||
path: 'fake-dir',
|
||||
secondaryChildren: [ { assocType: 'assoc-1', childId: 'child-id' }],
|
||||
@@ -547,7 +549,7 @@ describe('UploadService', () => {
|
||||
},
|
||||
undefined,
|
||||
undefined,
|
||||
{ newVersion: true },
|
||||
{ newVersion: true, name: 'fake-name', nodeType: undefined },
|
||||
{
|
||||
include: ['allowableOperations'],
|
||||
overwrite: true,
|
||||
|
@@ -28,7 +28,7 @@ import { FileModel, FileUploadProgress, FileUploadStatus } from '../models/file.
|
||||
import { AppConfigService, AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import { filter } from 'rxjs/operators';
|
||||
import { DiscoveryApiService } from '../../common/services/discovery-api.service';
|
||||
import { NodesApi, UploadApi, VersionsApi } from '@alfresco/js-api';
|
||||
import { NodeBodyCreate, NodesApi, UploadApi, VersionsApi } from '@alfresco/js-api';
|
||||
|
||||
const MIN_CANCELLABLE_FILE_SIZE = 1000000;
|
||||
const MAX_CANCELLABLE_FILE_PERCENTAGE = 50;
|
||||
@@ -237,7 +237,7 @@ export class UploadService {
|
||||
if (file.id) {
|
||||
return this.nodesApi.updateNodeContent(file.id, file.file as any, opts);
|
||||
} else {
|
||||
const nodeBody = {...file.options};
|
||||
const nodeBody: NodeBodyCreate = { ...file.options, name: file.name, nodeType: file.options.nodeType };
|
||||
delete nodeBody['versioningEnabled'];
|
||||
|
||||
return this.uploadApi.uploadFile(
|
||||
|
@@ -50,11 +50,11 @@ const fakeSiteList: SitePaging = new SitePaging({
|
||||
},
|
||||
entries: [
|
||||
{
|
||||
entry: {
|
||||
entry: new Site({
|
||||
id: 'FAKE',
|
||||
guid: 'FAKE-GUID',
|
||||
title: 'FAKE-SITE-TITLE'
|
||||
}
|
||||
})
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@
|
||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||
import { ComponentFixture, fakeAsync, flush, TestBed, tick } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { Node, NodeEntry, NodePaging, RequestScope, ResultSetPaging, SiteEntry, SitePaging } from '@alfresco/js-api';
|
||||
import { Node, NodeEntry, NodePaging, RequestScope, ResultSetPaging, SiteEntry, SitePaging, SitePagingList } from '@alfresco/js-api';
|
||||
import { of } from 'rxjs';
|
||||
import { ContentNodeSelectorPanelComponent } from './content-node-selector-panel.component';
|
||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||
@@ -134,13 +134,13 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
list: {
|
||||
pagination: {},
|
||||
entries: [],
|
||||
source: {}
|
||||
source: new Node()
|
||||
}
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
spyOn(sitesService, 'getSites').and.returnValue(of(new SitePaging({ list: { entries: [] } })));
|
||||
spyOn(sitesService, 'getSites').and.returnValue(of(new SitePaging({ list: new SitePagingList({ entries: [] }) })));
|
||||
|
||||
customResourcesService = TestBed.inject(CustomResourcesService);
|
||||
getCorrespondingNodeIdsSpy = spyOn(customResourcesService, 'getCorrespondingNodeIds').and.callFake((id) => {
|
||||
|
@@ -18,7 +18,7 @@
|
||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { Node, NodeEntry, NodePaging, ResultSetPaging, SiteEntry, SitePaging, UserInfo } from '@alfresco/js-api';
|
||||
import { Node, NodeEntry, NodePaging, PathElement, ResultSetPaging, Site, SiteEntry, SitePaging, SitePagingList, UserInfo } from '@alfresco/js-api';
|
||||
import { AppConfigService, DataRow, ThumbnailService, DataColumn } from '@alfresco/adf-core';
|
||||
import { ContentService } from '../common/services/content.service';
|
||||
import { UploadService } from '../common/services/upload.service';
|
||||
@@ -123,7 +123,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
|
||||
describe('Site selection', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(sitesService, 'getSites').and.returnValue(of(new SitePaging({ list: { entries: [] } })));
|
||||
spyOn(sitesService, 'getSites').and.returnValue(of(new SitePaging({ list: new SitePagingList({ entries: [] }) })));
|
||||
component.currentFolderId = 'fake-starting-folder';
|
||||
});
|
||||
|
||||
@@ -138,7 +138,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
});
|
||||
|
||||
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' } });
|
||||
const fakeSiteEntry = new SiteEntry({ entry: new Site({ title: 'fake-new-site', guid: 'fake-new-site' }) });
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
@@ -162,9 +162,9 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
spyOn(sitesService, 'getSites').and.returnValue(
|
||||
of(
|
||||
new SitePaging({
|
||||
list: {
|
||||
entries: [{ entry: { guid: 'namek', id: 'namek' } }, { entry: { guid: 'blog', id: 'blog' } }]
|
||||
}
|
||||
list: new SitePagingList({
|
||||
entries: [{ entry: new Site({ guid: 'namek', id: 'namek' }) }, { entry: new Site({ guid: 'blog', id: 'blog' }) }]
|
||||
})
|
||||
})
|
||||
)
|
||||
);
|
||||
@@ -262,7 +262,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
|
||||
spyOn(documentListService, 'getFolderNode').and.returnValue(of(new NodeEntry()));
|
||||
spyOn(documentListService, 'getFolder').and.returnValue(throwError('No results for test'));
|
||||
spyOn(sitesService, 'getSites').and.returnValue(of(new SitePaging({ list: { entries: [] } })));
|
||||
spyOn(sitesService, 'getSites').and.returnValue(of(new SitePaging({ list: new SitePagingList({ entries: [] }) })));
|
||||
|
||||
component.currentFolderId = 'cat-girl-nuku-nuku';
|
||||
fixture.detectChanges();
|
||||
@@ -303,7 +303,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
searchQueryBuilderService.update();
|
||||
triggerSearchResults(fakeResultSetPaging);
|
||||
|
||||
const chosenNode = new Node({ path: { elements: ['one'] } });
|
||||
const chosenNode = new Node({ path: { elements: [new PathElement({ name: 'one' })] } });
|
||||
component.onCurrentSelection([{ entry: chosenNode }]);
|
||||
fixture.detectChanges();
|
||||
|
||||
@@ -318,7 +318,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
searchQueryBuilderService.update();
|
||||
triggerSearchResults(fakeResultSetPaging);
|
||||
|
||||
const chosenNode = new Node({ path: { elements: ['fake-path'] }, isFile: false, isFolder: true });
|
||||
const chosenNode = new Node({ path: { elements: [new PathElement({ name: 'fake-path' })] }, isFile: false, isFolder: true });
|
||||
component.onCurrentSelection([{ entry: chosenNode }]);
|
||||
fixture.detectChanges();
|
||||
|
||||
@@ -384,7 +384,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
const rows = [{}, {}] as DataRow[];
|
||||
component.documentList.data = new ShareDataTableAdapter(thumbnailService, contentService, schema);
|
||||
spyOn(component.documentList.data, 'getRows').and.returnValue(rows);
|
||||
spyOn(sitesService, 'getSites').and.returnValue(of(new SitePaging({ list: { entries: [] } })));
|
||||
spyOn(sitesService, 'getSites').and.returnValue(of(new SitePaging({ list: new SitePagingList({ entries: [] }) })));
|
||||
});
|
||||
|
||||
it('should the selection become the currently navigated folder when the folder loads (Acts as destination for cases like copy action)', () => {
|
||||
@@ -655,7 +655,10 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
|
||||
it('should return only the last uploaded node to become preselected when the selection mode is single', () => {
|
||||
fixture.detectChanges();
|
||||
const fakeNodes = [new NodeEntry({ id: 'fakeNode1' }), new NodeEntry({ id: 'fakeNode2' })];
|
||||
const fakeNodes = [
|
||||
new NodeEntry({ entry: new Node({ id: 'fakeNode1' }) }),
|
||||
new NodeEntry({ entry: new Node({ id: 'fakeNode2' }) })
|
||||
];
|
||||
component.currentUploadBatch = fakeNodes;
|
||||
component.selectionMode = 'single';
|
||||
|
||||
@@ -664,7 +667,10 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
|
||||
it('should return all the uploaded nodes to become preselected when the selection mode is multiple', () => {
|
||||
fixture.detectChanges();
|
||||
const fakeNodes = [new NodeEntry({ id: 'fakeNode1' }), new NodeEntry({ id: 'fakeNode2' })];
|
||||
const fakeNodes = [
|
||||
new NodeEntry({ entry: new Node({ id: 'fakeNode1' }) }),
|
||||
new NodeEntry({ entry: new Node({ id: 'fakeNode2' }) })
|
||||
];
|
||||
component.currentUploadBatch = fakeNodes;
|
||||
component.selectionMode = 'multiple';
|
||||
|
||||
|
@@ -19,7 +19,7 @@ import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/materia
|
||||
import { CUSTOM_ELEMENTS_SCHEMA, EventEmitter } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ContentNodeSelectorComponent } from './content-node-selector.component';
|
||||
import { Node, NodeEntry, SitePaging } from '@alfresco/js-api';
|
||||
import { Node, NodeEntry, SitePaging, SitePagingList } from '@alfresco/js-api';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { FileModel } from '../common/models/file.model';
|
||||
import { FileUploadEvent } from '../common/events/file.event';
|
||||
@@ -88,7 +88,7 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
|
||||
spyOn(documentListService, 'getFolder');
|
||||
spyOn(documentListService, 'getFolderNode');
|
||||
spyOn(sitesService, 'getSites').and.returnValue(of(new SitePaging({ list: { entries: [] } })));
|
||||
spyOn(sitesService, 'getSites').and.returnValue(of(new SitePaging({ list: new SitePagingList({ entries: [] }) })));
|
||||
|
||||
fixture = TestBed.createComponent(ContentNodeSelectorComponent);
|
||||
component = fixture.componentInstance;
|
||||
@@ -97,15 +97,12 @@ describe('ContentNodeSelectorComponent', () => {
|
||||
spyOn(contentService, 'hasAllowableOperations').and.returnValue(true);
|
||||
|
||||
const fakeFolderNodeWithPermission = new NodeEntry({
|
||||
entry: {
|
||||
allowableOperations: [
|
||||
'create',
|
||||
'update'
|
||||
],
|
||||
entry: new Node({
|
||||
allowableOperations: ['create', 'update'],
|
||||
isFolder: true,
|
||||
name: 'Folder Fake Name',
|
||||
nodeType: 'cm:folder'
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
const nodesApiService = TestBed.inject(NodesApiService);
|
||||
|
@@ -113,7 +113,7 @@ describe('LibraryMembershipDirective', () => {
|
||||
mockSupportedVersion = false;
|
||||
getMembershipSpy = spyOn(directive['sitesApi'], 'getSiteMembershipRequestForPerson').and.returnValue(Promise.resolve({ entry: requestedMembershipResponse }));
|
||||
addMembershipSpy = spyOn(directive['sitesApi'], 'createSiteMembershipRequestForPerson').and.returnValue(Promise.resolve({ entry: requestedMembershipResponse }));
|
||||
deleteMembershipSpy = spyOn(directive['sitesApi'], 'deleteSiteMembershipRequestForPerson').and.returnValue(Promise.resolve({}));
|
||||
deleteMembershipSpy = spyOn(directive['sitesApi'], 'deleteSiteMembershipRequestForPerson').and.returnValue(Promise.resolve());
|
||||
});
|
||||
|
||||
it('should do nothing if there is no selected library ', fakeAsync(() => {
|
||||
|
@@ -18,7 +18,7 @@
|
||||
import { Directive, EventEmitter, HostListener, Input, OnChanges, Output, SimpleChanges } from '@angular/core';
|
||||
import {
|
||||
SiteEntry,
|
||||
SiteMembershipRequestBody,
|
||||
SiteMembershipRequestBodyCreate,
|
||||
SiteMemberEntry,
|
||||
SiteMembershipRequestEntry,
|
||||
SitesApi
|
||||
@@ -208,7 +208,7 @@ export class LibraryMembershipDirective implements OnChanges {
|
||||
private joinLibraryRequest(): Observable<SiteMembershipRequestEntry> {
|
||||
const memberBody = {
|
||||
id: this.targetSite.id
|
||||
} as SiteMembershipRequestBody;
|
||||
} as SiteMembershipRequestBodyCreate;
|
||||
|
||||
if (this.versionCompatibilityService.isVersionSupported('7.0.0')) {
|
||||
memberBody.client = 'workspace';
|
||||
|
@@ -18,7 +18,7 @@
|
||||
/* eslint-disable @angular-eslint/no-input-rename */
|
||||
|
||||
import { Directive, ElementRef, EventEmitter, HostListener, Input, OnChanges, Output } from '@angular/core';
|
||||
import { NodeEntry, Node, DeletedNodeEntity, DeletedNode, TrashcanApi, NodesApi } from '@alfresco/js-api';
|
||||
import { NodeEntry, Node, DeletedNodeEntry, DeletedNode, TrashcanApi, NodesApi } from '@alfresco/js-api';
|
||||
import { Observable, forkJoin, from, of } from 'rxjs';
|
||||
import { AlfrescoApiService, TranslationService } from '@alfresco/adf-core';
|
||||
import { map, catchError, retry } from 'rxjs/operators';
|
||||
@@ -51,7 +51,7 @@ interface ProcessStatus {
|
||||
export class NodeDeleteDirective implements OnChanges {
|
||||
/** Array of nodes to delete. */
|
||||
@Input('adf-delete')
|
||||
selection: NodeEntry[] | DeletedNodeEntity[];
|
||||
selection: NodeEntry[] | DeletedNodeEntry[];
|
||||
|
||||
/** If true then the nodes are deleted immediately rather than being put in the trash */
|
||||
@Input()
|
||||
@@ -97,7 +97,7 @@ export class NodeDeleteDirective implements OnChanges {
|
||||
this.elementRef.nativeElement.disabled = disable;
|
||||
}
|
||||
|
||||
private process(selection: NodeEntry[] | DeletedNodeEntity[]) {
|
||||
private process(selection: NodeEntry[] | DeletedNodeEntry[]) {
|
||||
if (selection && selection.length) {
|
||||
|
||||
const batch = this.getDeleteNodesBatch(selection);
|
||||
@@ -118,7 +118,7 @@ export class NodeDeleteDirective implements OnChanges {
|
||||
return selection.map((node) => this.deleteNode(node));
|
||||
}
|
||||
|
||||
private deleteNode(node: NodeEntry | DeletedNodeEntity): Observable<ProcessedNodeData> {
|
||||
private deleteNode(node: NodeEntry | DeletedNodeEntry): Observable<ProcessedNodeData> {
|
||||
const id = (node.entry as any).nodeId || node.entry.id;
|
||||
|
||||
let promise: Promise<any>;
|
||||
|
@@ -51,7 +51,7 @@ import { DocumentListService } from './../services/document-list.service';
|
||||
import { CustomResourcesService } from './../services/custom-resources.service';
|
||||
import { DocumentListComponent } from './document-list.component';
|
||||
import { ContentTestingModule } from '../../testing/content.testing.module';
|
||||
import { FavoritePaging, NodeEntry, NodePaging, Node } from '@alfresco/js-api';
|
||||
import { FavoritePaging, NodeEntry, NodePaging, Node, FavoritePagingList } from '@alfresco/js-api';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { DocumentListModule } from '../document-list.module';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
@@ -106,15 +106,15 @@ describe('DocumentList', () => {
|
||||
appConfigService = TestBed.inject(AppConfigService);
|
||||
|
||||
spyFolder = spyOn(documentListService, 'getFolder').and.returnValue(of({ list: {} }));
|
||||
spyFolderNode = spyOn(documentListService, 'getFolderNode').and.returnValue(of(new NodeEntry({ entry: {} })));
|
||||
spyOn(documentList['nodesApi'], 'getNode').and.returnValue(Promise.resolve(new NodeEntry({ entry: {} })));
|
||||
spyFolderNode = spyOn(documentListService, 'getFolderNode').and.returnValue(of(new NodeEntry({ entry: new Node() })));
|
||||
spyOn(documentList['nodesApi'], 'getNode').and.returnValue(Promise.resolve(new NodeEntry({ entry: new Node() })));
|
||||
|
||||
documentList.ngOnInit();
|
||||
documentList.currentFolderId = 'no-node';
|
||||
|
||||
spyGetSites = spyOn(customResourcesService.sitesApi, 'listSites').and.returnValue(Promise.resolve(fakeGetSitesAnswer));
|
||||
spyFavorite = spyOn(customResourcesService.favoritesApi, 'listFavorites').and.returnValue(
|
||||
Promise.resolve(new FavoritePaging({ list: { entries: [] } }))
|
||||
Promise.resolve(new FavoritePaging({ list: new FavoritePagingList({ entries: [] }) }))
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1208,7 +1208,7 @@ describe('DocumentList', () => {
|
||||
expect(folderNode.value.id).toBe('fake-node');
|
||||
done();
|
||||
});
|
||||
documentList.onNodeDblClick(new NodeEntry({ entry: { id: 'fake-node', isFolder: true } }));
|
||||
documentList.onNodeDblClick(new NodeEntry({ entry: new Node({ id: 'fake-node', isFolder: true }) }));
|
||||
});
|
||||
|
||||
it('should set no permission when getFolderNode fails with 403', (done) => {
|
||||
|
@@ -19,7 +19,7 @@ import { CustomResourcesService } from './custom-resources.service';
|
||||
import { PaginationModel } from '@alfresco/adf-core';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { ContentTestingModule } from '../../testing/content.testing.module';
|
||||
import { FavoritePaging } from '@alfresco/js-api';
|
||||
import { Favorite, FavoritePaging, FavoritePagingList } from '@alfresco/js-api';
|
||||
|
||||
describe('CustomResourcesService', () => {
|
||||
let customResourcesService: CustomResourcesService;
|
||||
@@ -34,22 +34,26 @@ describe('CustomResourcesService', () => {
|
||||
|
||||
describe('loadFavorites', () => {
|
||||
it('should return a list of items with default properties when target properties does not exist', (done) => {
|
||||
spyOn(customResourcesService.favoritesApi, 'listFavorites').and.returnValue(Promise.resolve(new FavoritePaging({
|
||||
list: {
|
||||
entries: [
|
||||
{
|
||||
entry: {
|
||||
target: {
|
||||
file: {
|
||||
title: 'some-title',
|
||||
description: 'some-description'
|
||||
}
|
||||
spyOn(customResourcesService.favoritesApi, 'listFavorites').and.returnValue(
|
||||
Promise.resolve(
|
||||
new FavoritePaging({
|
||||
list: new FavoritePagingList({
|
||||
entries: [
|
||||
{
|
||||
entry: new Favorite({
|
||||
target: {
|
||||
file: {
|
||||
title: 'some-title',
|
||||
description: 'some-description'
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
})));
|
||||
]
|
||||
})
|
||||
})
|
||||
)
|
||||
);
|
||||
const pagination: PaginationModel = {
|
||||
maxItems: 100,
|
||||
skipCount: 0
|
||||
@@ -73,25 +77,29 @@ describe('CustomResourcesService', () => {
|
||||
});
|
||||
|
||||
it('should return a list of items with merged properties when target properties exist', (done) => {
|
||||
spyOn(customResourcesService.favoritesApi, 'listFavorites').and.returnValue(Promise.resolve(new FavoritePaging({
|
||||
list: {
|
||||
entries: [
|
||||
{
|
||||
entry: {
|
||||
properties: {
|
||||
'cm:property': 'some-property'
|
||||
},
|
||||
target: {
|
||||
file: {
|
||||
title: 'some-title',
|
||||
description: 'some-description'
|
||||
}
|
||||
spyOn(customResourcesService.favoritesApi, 'listFavorites').and.returnValue(
|
||||
Promise.resolve(
|
||||
new FavoritePaging({
|
||||
list: new FavoritePagingList({
|
||||
entries: [
|
||||
{
|
||||
entry: new Favorite({
|
||||
properties: {
|
||||
'cm:property': 'some-property'
|
||||
},
|
||||
target: {
|
||||
file: {
|
||||
title: 'some-title',
|
||||
description: 'some-description'
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
})));
|
||||
]
|
||||
})
|
||||
})
|
||||
)
|
||||
);
|
||||
const pagination: PaginationModel = {
|
||||
maxItems: 100,
|
||||
skipCount: 0
|
||||
|
@@ -15,10 +15,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { PathInfoEntity } from '@alfresco/js-api';
|
||||
import { PathInfo } from '@alfresco/js-api';
|
||||
|
||||
export class RestoreMessageModel {
|
||||
message: string;
|
||||
path: PathInfoEntity;
|
||||
path: PathInfo;
|
||||
action: string;
|
||||
}
|
||||
|
@@ -20,10 +20,10 @@ import { Node, NodePaging, NodeEntry } from '@alfresco/js-api';
|
||||
export const fakeNodeWithCreatePermission = new Node({
|
||||
isFile: false,
|
||||
createdByUser: { id: 'admin', displayName: 'Administrator' },
|
||||
modifiedAt: '2017-06-08T13:53:46.495Z',
|
||||
modifiedAt: new Date('2017-06-08T13:53:46.495Z'),
|
||||
nodeType: 'cm:folder',
|
||||
parentId: '55052317-7e59-4058-8e07-769f41e615e1',
|
||||
createdAt: '2017-05-22T11:36:11.270Z',
|
||||
createdAt: new Date('2017-05-22T11:36:11.270Z'),
|
||||
path: {
|
||||
name: '/Company Home/User Homes',
|
||||
isComplete: true,
|
||||
@@ -43,11 +43,11 @@ export const fakeNodeWithCreatePermission = new Node({
|
||||
export const fakeNodeWithNoPermission = new Node({
|
||||
isFile: false,
|
||||
createdByUser: { id: 'admin', displayName: 'Administrator' },
|
||||
modifiedAt: '2017-06-08T13:53:46.495Z',
|
||||
modifiedAt: new Date('2017-06-08T13:53:46.495Z'),
|
||||
nodeType: 'cm:folder',
|
||||
parentId: '55052317-7e59-4058-8e07-769f41e615e1',
|
||||
aspectNames: ['cm:ownable', 'cm:auditable'],
|
||||
createdAt: '2017-05-22T11:36:11.270Z',
|
||||
createdAt: new Date('2017-05-22T11:36:11.270Z'),
|
||||
path: {
|
||||
name: '/Company Home/User Homes',
|
||||
isComplete: true,
|
||||
@@ -219,7 +219,7 @@ export const fakeNodePaging: NodePaging = {
|
||||
export const mockNode1 = new Node({
|
||||
isFile: true,
|
||||
createdByUser: { id: 'admin', displayName: 'Administrator' },
|
||||
modifiedAt: '2017-05-24T15:08:55.640Z',
|
||||
modifiedAt: new Date('2017-05-24T15:08:55.640Z'),
|
||||
nodeType: 'cm:content',
|
||||
content: {
|
||||
mimeType: 'application/rtf',
|
||||
@@ -228,7 +228,7 @@ export const mockNode1 = new Node({
|
||||
encoding: 'UTF-8'
|
||||
},
|
||||
parentId: 'd124de26-6ba0-4f40-8d98-4907da2d337a',
|
||||
createdAt: '2017-05-24T15:08:55.640Z',
|
||||
createdAt: new Date('2017-05-24T15:08:55.640Z'),
|
||||
path: {
|
||||
name: '/Company Home/Guest Home',
|
||||
isComplete: true,
|
||||
@@ -248,7 +248,7 @@ export const mockNode1 = new Node({
|
||||
export const mockNode2 = new Node({
|
||||
isFile: true,
|
||||
createdByUser: { id: 'admin', displayName: 'Administrator' },
|
||||
modifiedAt: '2017-05-24T15:08:55.640Z',
|
||||
modifiedAt: new Date('2017-05-24T15:08:55.640Z'),
|
||||
nodeType: 'cm:content',
|
||||
content: {
|
||||
mimeType: 'application/rtf',
|
||||
@@ -257,7 +257,7 @@ export const mockNode2 = new Node({
|
||||
encoding: 'UTF-8'
|
||||
},
|
||||
parentId: 'd124de26-6ba0-4f40-8d98-4907da2d337a',
|
||||
createdAt: '2017-05-24T15:08:55.640Z',
|
||||
createdAt: new Date('2017-05-24T15:08:55.640Z'),
|
||||
path: {
|
||||
name: '/Company Home/Guest Home',
|
||||
isComplete: true,
|
||||
@@ -277,7 +277,7 @@ export const mockNode2 = new Node({
|
||||
export const mockNode3 = new Node({
|
||||
isFile: true,
|
||||
createdByUser: { id: 'admin', displayName: 'Administrator' },
|
||||
modifiedAt: '2017-05-24T15:08:55.640Z',
|
||||
modifiedAt: new Date('2017-05-24T15:08:55.640Z'),
|
||||
nodeType: 'cm:content',
|
||||
content: {
|
||||
mimeType: 'application/rtf',
|
||||
@@ -286,7 +286,7 @@ export const mockNode3 = new Node({
|
||||
encoding: 'UTF-8'
|
||||
},
|
||||
parentId: 'd124de26-6ba0-4f40-8d98-4907da2d337a',
|
||||
createdAt: '2017-05-24T15:08:55.640Z',
|
||||
createdAt: new Date('2017-05-24T15:08:55.640Z'),
|
||||
path: {
|
||||
name: '/Company Home/Guest Home',
|
||||
isComplete: true,
|
||||
|
@@ -17,41 +17,41 @@
|
||||
|
||||
import { Component, ViewChild } from '@angular/core';
|
||||
import { SearchComponent } from '../search/components/search.component';
|
||||
import { SearchRequest, ResultSetPaging } from '@alfresco/js-api';
|
||||
import { SearchRequest, ResultSetPaging, ResultSetRowEntry, ContentInfo, UserInfo, ResultNode } from '@alfresco/js-api';
|
||||
|
||||
const entryItem = {
|
||||
entry: {
|
||||
const entryItem = new ResultSetRowEntry({
|
||||
entry: new ResultNode({
|
||||
id: '123',
|
||||
name: 'MyDoc',
|
||||
isFile: true,
|
||||
content: {
|
||||
content: new ContentInfo({
|
||||
mimeType: 'text/plain'
|
||||
},
|
||||
createdByUser: {
|
||||
}),
|
||||
createdByUser: new UserInfo({
|
||||
displayName: 'John Doe'
|
||||
},
|
||||
modifiedByUser: {
|
||||
}),
|
||||
modifiedByUser: new UserInfo({
|
||||
displayName: 'John Doe'
|
||||
}
|
||||
}
|
||||
};
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
const entryDifferentItem = {
|
||||
entry: {
|
||||
const entryDifferentItem = new ResultSetRowEntry({
|
||||
entry: new ResultNode({
|
||||
id: '999',
|
||||
name: 'TEST_DOC',
|
||||
isFile: true,
|
||||
content: {
|
||||
content: new ContentInfo({
|
||||
mimeType: 'text/plain'
|
||||
},
|
||||
createdByUser: {
|
||||
}),
|
||||
createdByUser: new UserInfo({
|
||||
displayName: 'John TEST'
|
||||
},
|
||||
modifiedByUser: {
|
||||
}),
|
||||
modifiedByUser: new UserInfo({
|
||||
displayName: 'John TEST'
|
||||
}
|
||||
}
|
||||
};
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
export const result = new ResultSetPaging({
|
||||
list: {
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { SitePaging } from '@alfresco/js-api';
|
||||
import { SitePaging, SitePagingList } from '@alfresco/js-api';
|
||||
|
||||
/* We are using functions instead of constants here to pass a new instance of the object each time */
|
||||
export const getFakeSitePaging = (): SitePaging => ({
|
||||
@@ -162,122 +162,126 @@ export const getFakeSitePagingLastPage = (): SitePaging => ({
|
||||
}
|
||||
});
|
||||
|
||||
export const getFakeSitePagingWithMembers = () => new SitePaging({
|
||||
list: {
|
||||
entries: [{
|
||||
entry: {
|
||||
visibility: 'MODERATED',
|
||||
guid: 'b4cff62a-664d-4d45-9302-98723eac1319',
|
||||
description: 'This is a Sample Alfresco Team site.',
|
||||
id: 'MODERATED-SITE',
|
||||
preset: 'site-dashboard',
|
||||
title: 'FAKE-MODERATED-SITE'
|
||||
},
|
||||
relations: {
|
||||
members: {
|
||||
list: {
|
||||
pagination: {
|
||||
count: 3,
|
||||
hasMoreItems: false,
|
||||
skipCount: 0,
|
||||
maxItems: 100
|
||||
},
|
||||
entries: [
|
||||
{
|
||||
entry: {
|
||||
role: 'SiteManager',
|
||||
person: {
|
||||
firstName: 'Administrator',
|
||||
emailNotificationsEnabled: true,
|
||||
company: {},
|
||||
id: 'admin',
|
||||
enabled: true,
|
||||
email: 'admin@alfresco.com'
|
||||
export const getFakeSitePagingWithMembers = () =>
|
||||
new SitePaging({
|
||||
list: new SitePagingList({
|
||||
entries: [
|
||||
{
|
||||
entry: {
|
||||
visibility: 'MODERATED',
|
||||
guid: 'b4cff62a-664d-4d45-9302-98723eac1319',
|
||||
description: 'This is a Sample Alfresco Team site.',
|
||||
id: 'MODERATED-SITE',
|
||||
preset: 'site-dashboard',
|
||||
title: 'FAKE-MODERATED-SITE'
|
||||
},
|
||||
relations: {
|
||||
members: {
|
||||
list: {
|
||||
pagination: {
|
||||
count: 3,
|
||||
hasMoreItems: false,
|
||||
skipCount: 0,
|
||||
maxItems: 100
|
||||
},
|
||||
entries: [
|
||||
{
|
||||
entry: {
|
||||
role: 'SiteManager',
|
||||
person: {
|
||||
firstName: 'Administrator',
|
||||
emailNotificationsEnabled: true,
|
||||
company: {},
|
||||
id: 'admin',
|
||||
enabled: true,
|
||||
email: 'admin@alfresco.com'
|
||||
},
|
||||
id: 'admin'
|
||||
}
|
||||
},
|
||||
id: 'admin'
|
||||
}
|
||||
},
|
||||
{
|
||||
entry: {
|
||||
role: 'SiteCollaborator',
|
||||
person: {
|
||||
lastName: 'Beecher',
|
||||
userStatus: 'Helping to design the look and feel of the new web site',
|
||||
jobTitle: 'Graphic Designer',
|
||||
statusUpdatedAt: '2011-02-15T20:20:13.432+0000',
|
||||
mobile: '0112211001100',
|
||||
emailNotificationsEnabled: true,
|
||||
description: 'Alice is a demo user for the sample Alfresco Team site.',
|
||||
telephone: '0112211001100',
|
||||
enabled: false,
|
||||
firstName: 'Alice',
|
||||
skypeId: 'abeecher',
|
||||
avatarId: '198500fc-1e99-4f5f-8926-248cea433366',
|
||||
location: 'Tilbury, UK',
|
||||
company: {
|
||||
organization: 'Moresby, Garland and Wedge',
|
||||
address1: '200 Butterwick Street',
|
||||
address2: 'Tilbury',
|
||||
address3: 'UK',
|
||||
postcode: 'ALF1 SAM1'
|
||||
},
|
||||
id: 'abeecher',
|
||||
email: 'abeecher@example.com'
|
||||
},
|
||||
id: 'abeecher'
|
||||
}
|
||||
{
|
||||
entry: {
|
||||
role: 'SiteCollaborator',
|
||||
person: {
|
||||
lastName: 'Beecher',
|
||||
userStatus: 'Helping to design the look and feel of the new web site',
|
||||
jobTitle: 'Graphic Designer',
|
||||
statusUpdatedAt: new Date('2011-02-15T20:20:13.432+0000'),
|
||||
mobile: '0112211001100',
|
||||
emailNotificationsEnabled: true,
|
||||
description: 'Alice is a demo user for the sample Alfresco Team site.',
|
||||
telephone: '0112211001100',
|
||||
enabled: false,
|
||||
firstName: 'Alice',
|
||||
skypeId: 'abeecher',
|
||||
avatarId: '198500fc-1e99-4f5f-8926-248cea433366',
|
||||
location: 'Tilbury, UK',
|
||||
company: {
|
||||
organization: 'Moresby, Garland and Wedge',
|
||||
address1: '200 Butterwick Street',
|
||||
address2: 'Tilbury',
|
||||
address3: 'UK',
|
||||
postcode: 'ALF1 SAM1'
|
||||
},
|
||||
id: 'abeecher',
|
||||
email: 'abeecher@example.com'
|
||||
},
|
||||
id: 'abeecher'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
entry: {
|
||||
visibility: 'PUBLIC',
|
||||
guid: 'b4cff62a-664d-4d45-9302-98723eac1319',
|
||||
description: 'This is a Sample Alfresco Team site.',
|
||||
id: 'PUBLIC-SITE',
|
||||
preset: 'site-dashboard',
|
||||
title: 'FAKE-SITE-PUBLIC'
|
||||
}
|
||||
},
|
||||
{
|
||||
entry: {
|
||||
visibility: 'PRIVATE',
|
||||
guid: 'b4cff62a-664d-4d45-9302-98723eac1319',
|
||||
description: 'This is a Sample Alfresco Team site.',
|
||||
id: 'MEMBER-SITE',
|
||||
preset: 'site-dashboard',
|
||||
title: 'FAKE-PRIVATE-SITE-MEMBER'
|
||||
},
|
||||
relations: {
|
||||
members: {
|
||||
list: {
|
||||
pagination: {
|
||||
count: 3,
|
||||
hasMoreItems: false,
|
||||
skipCount: 0,
|
||||
maxItems: 100
|
||||
},
|
||||
entries: [
|
||||
{
|
||||
entry: {
|
||||
role: 'SiteManager',
|
||||
person: {
|
||||
firstName: 'Administrator',
|
||||
emailNotificationsEnabled: true,
|
||||
company: {},
|
||||
id: 'admin',
|
||||
enabled: true,
|
||||
email: 'admin@alfresco.com'
|
||||
},
|
||||
id: 'test'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
entry: {
|
||||
visibility: 'PUBLIC',
|
||||
guid: 'b4cff62a-664d-4d45-9302-98723eac1319',
|
||||
description: 'This is a Sample Alfresco Team site.',
|
||||
id: 'PUBLIC-SITE',
|
||||
preset: 'site-dashboard',
|
||||
title: 'FAKE-SITE-PUBLIC'
|
||||
}
|
||||
}, {
|
||||
entry: {
|
||||
visibility: 'PRIVATE',
|
||||
guid: 'b4cff62a-664d-4d45-9302-98723eac1319',
|
||||
description: 'This is a Sample Alfresco Team site.',
|
||||
id: 'MEMBER-SITE',
|
||||
preset: 'site-dashboard',
|
||||
title: 'FAKE-PRIVATE-SITE-MEMBER'
|
||||
},
|
||||
relations: {
|
||||
members: {
|
||||
list: {
|
||||
pagination: {
|
||||
count: 3,
|
||||
hasMoreItems: false,
|
||||
skipCount: 0,
|
||||
maxItems: 100
|
||||
},
|
||||
entries: [
|
||||
{
|
||||
entry: {
|
||||
role: 'SiteManager',
|
||||
person: {
|
||||
firstName: 'Administrator',
|
||||
emailNotificationsEnabled: true,
|
||||
company: {},
|
||||
id: 'admin',
|
||||
enabled: true,
|
||||
email: 'admin@alfresco.com'
|
||||
},
|
||||
id: 'test'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
]
|
||||
})
|
||||
});
|
||||
|
@@ -15,31 +15,27 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { CommentModel } from '@alfresco/adf-core';
|
||||
import { CommentModel, User } from '@alfresco/adf-core';
|
||||
import { EcmCompanyModel } from '../../common/models/ecm-company.model';
|
||||
import { EcmUserModel } from '../../common/models/ecm-user.model';
|
||||
|
||||
export const fakeUser1 = {
|
||||
export const fakeUser1 = new User({
|
||||
enabled: true,
|
||||
firstName: 'firstName',
|
||||
lastName: 'lastName',
|
||||
email: 'fake-email@dom.com',
|
||||
emailNotificationsEnabled: true,
|
||||
company: {},
|
||||
id: 'fake-email@dom.com',
|
||||
avatarId: '123-123-123'
|
||||
};
|
||||
});
|
||||
|
||||
export const fakeUser2 = {
|
||||
export const fakeUser2 = new User({
|
||||
enabled: true,
|
||||
firstName: 'some',
|
||||
lastName: 'one',
|
||||
email: 'some-one@somegroup.com',
|
||||
emailNotificationsEnabled: true,
|
||||
company: {},
|
||||
id: 'fake-email@dom.com',
|
||||
avatarId: '001-001-001'
|
||||
};
|
||||
});
|
||||
|
||||
export const fakeContentComments = {
|
||||
list: {
|
||||
@@ -153,28 +149,28 @@ export const commentsNodeData: CommentModel[] = [
|
||||
id: 1,
|
||||
message: `I've done this component, is it cool?`,
|
||||
created: getDateXMinutesAgo(30),
|
||||
createdBy: johnDoe,
|
||||
createdBy: new User(johnDoe),
|
||||
isSelected: false
|
||||
}),
|
||||
new CommentModel({
|
||||
id: 2,
|
||||
message: 'Yeah',
|
||||
created: getDateXMinutesAgo(15),
|
||||
createdBy: janeEod,
|
||||
createdBy: new User(janeEod),
|
||||
isSelected: false
|
||||
}),
|
||||
new CommentModel({
|
||||
id: 3,
|
||||
message: '+1',
|
||||
created: getDateXMinutesAgo(12),
|
||||
createdBy: robertSmith,
|
||||
createdBy: new User(robertSmith),
|
||||
isSelected: false
|
||||
}),
|
||||
new CommentModel({
|
||||
id: 4,
|
||||
message: 'ty',
|
||||
created: new Date(),
|
||||
createdBy: johnDoe,
|
||||
createdBy: new User(johnDoe),
|
||||
isSelected: false
|
||||
})
|
||||
];
|
||||
@@ -184,28 +180,28 @@ export const commentsTaskData: CommentModel[] = [
|
||||
id: 1,
|
||||
message: `I've done this task, what's next?`,
|
||||
created: getDateXMinutesAgo(30),
|
||||
createdBy: johnDoe,
|
||||
createdBy: new User(johnDoe),
|
||||
isSelected: false
|
||||
}),
|
||||
new CommentModel({
|
||||
id: 2,
|
||||
message: `I've assigned you another one 🤠`,
|
||||
created: getDateXMinutesAgo(15),
|
||||
createdBy: janeEod,
|
||||
createdBy: new User(janeEod),
|
||||
isSelected: false
|
||||
}),
|
||||
new CommentModel({
|
||||
id: 3,
|
||||
message: '+1',
|
||||
created: getDateXMinutesAgo(12),
|
||||
createdBy: robertSmith,
|
||||
createdBy: new User(robertSmith),
|
||||
isSelected: false
|
||||
}),
|
||||
new CommentModel({
|
||||
id: 4,
|
||||
message: 'Cheers',
|
||||
created: new Date(),
|
||||
createdBy: johnDoe,
|
||||
createdBy: new User(johnDoe),
|
||||
isSelected: false
|
||||
})
|
||||
];
|
||||
|
@@ -19,7 +19,8 @@ import {
|
||||
AlfrescoApiService,
|
||||
LogService,
|
||||
CommentModel,
|
||||
CommentsService
|
||||
CommentsService,
|
||||
User
|
||||
} from '@alfresco/adf-core';
|
||||
import { CommentEntry, CommentsApi, Comment } from '@alfresco/js-api';
|
||||
import { Injectable } from '@angular/core';
|
||||
@@ -98,7 +99,7 @@ export class NodeCommentsService implements CommentsService {
|
||||
id: comment.id,
|
||||
message: comment.content,
|
||||
created: comment.createdAt,
|
||||
createdBy: comment.createdBy
|
||||
createdBy: new User(comment.createdBy)
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
import { SearchConfigurationService } from '../../../search/services/search-configuration.service';
|
||||
import { SearchService } from '../../../search/services/search.service';
|
||||
import { NodeEntry } from '@alfresco/js-api';
|
||||
import { Node, NodeEntry } from '@alfresco/js-api';
|
||||
import { Component, EventEmitter, Output, ViewChild, ViewEncapsulation } from '@angular/core';
|
||||
import { UntypedFormControl } from '@angular/forms';
|
||||
import { debounceTime } from 'rxjs/operators';
|
||||
@@ -30,13 +30,9 @@ import { MatSelectionList } from '@angular/material/list';
|
||||
templateUrl: './add-permission-panel.component.html',
|
||||
styleUrls: ['./add-permission-panel.component.scss'],
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
providers: [
|
||||
{ provide: SearchConfigurationService, useClass: SearchPermissionConfigurationService },
|
||||
SearchService
|
||||
]
|
||||
providers: [{ provide: SearchConfigurationService, useClass: SearchPermissionConfigurationService }, SearchService]
|
||||
})
|
||||
export class AddPermissionPanelComponent {
|
||||
|
||||
@ViewChild('search', { static: true })
|
||||
search: SearchComponent;
|
||||
|
||||
@@ -54,15 +50,13 @@ export class AddPermissionPanelComponent {
|
||||
selectedItems: NodeEntry[] = [];
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
EVERYONE: NodeEntry = new NodeEntry({ entry: { nodeType: 'cm:authorityContainer', properties: {'cm:authorityName': 'GROUP_EVERYONE'}}});
|
||||
EVERYONE: NodeEntry = new NodeEntry({
|
||||
entry: new Node({ nodeType: 'cm:authorityContainer', properties: { 'cm:authorityName': 'GROUP_EVERYONE' } })
|
||||
});
|
||||
|
||||
constructor() {
|
||||
this.searchInput.valueChanges
|
||||
.pipe(
|
||||
debounceTime(this.debounceSearch)
|
||||
)
|
||||
.subscribe((searchValue) => {
|
||||
const selectionOptions = this.matSelectionList.selectedOptions.selected.map(option => option.value);
|
||||
this.searchInput.valueChanges.pipe(debounceTime(this.debounceSearch)).subscribe((searchValue) => {
|
||||
const selectionOptions = this.matSelectionList.selectedOptions.selected.map((option) => option.value);
|
||||
this.selectedItems.push(...selectionOptions);
|
||||
this.matSelectionList.deselectAll();
|
||||
this.searchedWord = searchValue;
|
||||
@@ -73,15 +67,14 @@ export class AddPermissionPanelComponent {
|
||||
}
|
||||
|
||||
onSelectionChange() {
|
||||
const currentSelection = this.matSelectionList.selectedOptions.selected.map(option => option.value);
|
||||
const uniqueSelection = [ ...currentSelection, ...this.selectedItems ]
|
||||
.reduce((uniquesElements, currentElement) => {
|
||||
const isExist = uniquesElements.find(uniqueElement => uniqueElement.entry.id === currentElement.entry.id);
|
||||
const currentSelection = this.matSelectionList.selectedOptions.selected.map((option) => option.value);
|
||||
const uniqueSelection = [...currentSelection, ...this.selectedItems].reduce((uniquesElements, currentElement) => {
|
||||
const isExist = uniquesElements.find((uniqueElement) => uniqueElement.entry.id === currentElement.entry.id);
|
||||
if (!isExist) {
|
||||
uniquesElements.push(currentElement);
|
||||
}
|
||||
return uniquesElements;
|
||||
}, []);
|
||||
}, []);
|
||||
this.select.emit(uniqueSelection);
|
||||
}
|
||||
|
||||
@@ -90,5 +83,4 @@ export class AddPermissionPanelComponent {
|
||||
this.selectedItems.splice(0, this.selectedItems.length);
|
||||
this.search.resetResults();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { User } from '@alfresco/adf-core';
|
||||
import { NodeEntry } from '@alfresco/js-api';
|
||||
import { Group, NodeEntry } from '@alfresco/js-api';
|
||||
import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { NodePermissionService } from '../../services/node-permission.service';
|
||||
@@ -48,7 +48,7 @@ export class UserIconColumnComponent implements OnInit {
|
||||
@Input()
|
||||
selected: boolean = false;
|
||||
|
||||
displayText$ = new BehaviorSubject<User>(null);
|
||||
displayText$ = new BehaviorSubject<User | Group>(null);
|
||||
group = false;
|
||||
|
||||
get isSelected(): boolean {
|
||||
@@ -61,13 +61,15 @@ export class UserIconColumnComponent implements OnInit {
|
||||
if (this.context) {
|
||||
const { person, group, authorityId } = this.context.row.obj?.entry ?? this.context.row.obj;
|
||||
this.group = this.isGroup(group, authorityId);
|
||||
this.displayText$.next(person || group || { displayName: authorityId });
|
||||
const user = person ? new User(person) : undefined;
|
||||
this.displayText$.next(user || group || { displayName: authorityId });
|
||||
}
|
||||
|
||||
if (this.node) {
|
||||
const { person, group } = this.nodePermissionService.transformNodeToUserPerson(this.node.entry);
|
||||
this.group = this.isGroup(group, null);
|
||||
this.displayText$.next(person || group);
|
||||
const user = person ? new User(person) : undefined;
|
||||
this.displayText$.next(user || group);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -15,8 +15,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ContentInfo, Node, NodePagingList, UserInfo } from '@alfresco/js-api';
|
||||
|
||||
export const fakeSearch = {
|
||||
list: {
|
||||
list: new NodePagingList({
|
||||
pagination: {
|
||||
count: 1,
|
||||
hasMoreItems: false,
|
||||
@@ -26,22 +28,20 @@ export const fakeSearch = {
|
||||
},
|
||||
entries: [
|
||||
{
|
||||
entry: {
|
||||
entry: new Node({
|
||||
id: '123',
|
||||
name: 'MyDoc',
|
||||
content: {
|
||||
mimetype: 'text/plain'
|
||||
},
|
||||
createdByUser: {
|
||||
content: new ContentInfo({ mimeType: 'text/plain' }),
|
||||
createdByUser: new UserInfo({
|
||||
displayName: 'John Doe'
|
||||
},
|
||||
modifiedByUser: {
|
||||
}),
|
||||
modifiedByUser: new UserInfo({
|
||||
displayName: 'John Doe'
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export const mockError = {
|
||||
@@ -55,7 +55,5 @@ export const mockError = {
|
||||
};
|
||||
|
||||
export const searchMockApi: any = {
|
||||
|
||||
findNodes: () => Promise.resolve(fakeSearch)
|
||||
|
||||
};
|
||||
|
@@ -124,13 +124,13 @@ export interface SearchOptions {
|
||||
include?: string[];
|
||||
|
||||
/**
|
||||
* String to control the order of the entities returned in a list. You can use this
|
||||
* String array to control the order of the entities returned in a list. You can use this
|
||||
* parameter to sort the list by one or more fields. Each field has a default sort order,
|
||||
* which is normally ascending order (but see the JS-API docs to check if any fields used
|
||||
* in a method have a descending default search order). To sort the entities in a specific
|
||||
* order, you can use the "ASC" and "DESC" keywords for any field.
|
||||
*/
|
||||
orderBy?: string;
|
||||
orderBy?: string[];
|
||||
|
||||
/**
|
||||
* List of field names. You can use this parameter to restrict the fields returned within
|
||||
|
@@ -19,20 +19,9 @@ import { TestBed } from '@angular/core/testing';
|
||||
import { CoreTestingModule } from '@alfresco/adf-core';
|
||||
import { SecurityControlsService } from './security-controls-groups-marks-security.service';
|
||||
import { fakeAuthorityClearanceApiResponse } from './mock/security-authorities.mock';
|
||||
import {
|
||||
fakeGroupsApiResponse,
|
||||
createNewSecurityGroupMock
|
||||
} from './mock/security-groups.mock';
|
||||
import {
|
||||
fakeMarksApiResponse,
|
||||
createNewSecurityMarkMock
|
||||
} from './mock/security-marks.mock';
|
||||
import {
|
||||
SecurityGroupBody,
|
||||
SecurityGroupEntry,
|
||||
SecurityMarkBody,
|
||||
SecurityMarkEntry
|
||||
} from '@alfresco/js-api';
|
||||
import { fakeGroupsApiResponse, createNewSecurityGroupMock } from './mock/security-groups.mock';
|
||||
import { fakeMarksApiResponse, createNewSecurityMarkMock } from './mock/security-marks.mock';
|
||||
import { SecurityGroup, SecurityGroupBody, SecurityGroupEntry, SecurityMarkBody, SecurityMarkEntry } from '@alfresco/js-api';
|
||||
|
||||
describe('SecurityControlsService', () => {
|
||||
let service: SecurityControlsService;
|
||||
@@ -55,11 +44,8 @@ describe('SecurityControlsService', () => {
|
||||
});
|
||||
|
||||
it('should be able to get the list of Security groups', async () => {
|
||||
const getGroupSpy = spyOn(
|
||||
service.groupsApi,
|
||||
'getSecurityGroups'
|
||||
).and.returnValue(Promise.resolve(fakeGroupsApiResponse));
|
||||
const groupPromise = service.getSecurityGroup( 0, 5, 'inUse');
|
||||
const getGroupSpy = spyOn(service.groupsApi, 'getSecurityGroups').and.returnValue(Promise.resolve(fakeGroupsApiResponse));
|
||||
const groupPromise = service.getSecurityGroup(0, 5, 'inUse');
|
||||
const group = await groupPromise;
|
||||
expect(getGroupSpy).toHaveBeenCalledWith({
|
||||
skipCount: 0,
|
||||
@@ -73,21 +59,15 @@ describe('SecurityControlsService', () => {
|
||||
expect(group.entries[0].groupName).toBe('Classification');
|
||||
expect(group.entries[0].groupType).toBe('HIERARCHICAL');
|
||||
|
||||
expect(group.entries[1].id).toBe(
|
||||
'd2b11d9f-2707-439f-a7c6-e7872f395553'
|
||||
);
|
||||
expect(group.entries[1].id).toBe('d2b11d9f-2707-439f-a7c6-e7872f395553');
|
||||
expect(group.entries[1].groupName).toBe('SG1');
|
||||
expect(group.entries[1].groupType).toBe('USER_REQUIRES_ALL');
|
||||
|
||||
expect(group.entries[2].id).toBe(
|
||||
'1b77a32d-6b8b-4a37-b195-7f2ff2fe4ed3'
|
||||
);
|
||||
expect(group.entries[2].id).toBe('1b77a32d-6b8b-4a37-b195-7f2ff2fe4ed3');
|
||||
expect(group.entries[2].groupName).toBe('SG2');
|
||||
expect(group.entries[2].groupType).toBe('USER_REQUIRES_ALL');
|
||||
|
||||
expect(group.entries[3].id).toBe(
|
||||
'709791f8-22dc-428a-82dd-daf3e1aa8a60'
|
||||
);
|
||||
expect(group.entries[3].id).toBe('709791f8-22dc-428a-82dd-daf3e1aa8a60');
|
||||
expect(group.entries[3].groupName).toBe('SG3');
|
||||
expect(group.entries[3].groupType).toBe('USER_REQUIRES_ALL');
|
||||
});
|
||||
@@ -96,48 +76,34 @@ describe('SecurityControlsService', () => {
|
||||
spyOn(service.groupsApi, 'createSecurityGroup').and.returnValue(
|
||||
Promise.resolve(
|
||||
new SecurityGroupEntry({
|
||||
entry: {
|
||||
entry: new SecurityGroup({
|
||||
groupName: 'TestGroup',
|
||||
groupType: 'HIERARCHICAL',
|
||||
id: 'eddf6269-ceba-42c6-b979-9ac445d29a94'
|
||||
}
|
||||
})
|
||||
})
|
||||
)
|
||||
);
|
||||
const response = await service
|
||||
.createSecurityGroup(createNewSecurityGroupMock)
|
||||
.toPromise();
|
||||
const response = await service.createSecurityGroup(createNewSecurityGroupMock).toPromise();
|
||||
|
||||
securityGroupId = response.entry.id;
|
||||
expect(response.entry.groupName).toEqual('TestGroup');
|
||||
expect(response.entry.groupType).toEqual('HIERARCHICAL');
|
||||
expect(response.entry.id).toEqual(
|
||||
'eddf6269-ceba-42c6-b979-9ac445d29a94'
|
||||
);
|
||||
expect(response.entry.id).toEqual('eddf6269-ceba-42c6-b979-9ac445d29a94');
|
||||
});
|
||||
|
||||
it('should be able to get the list of Security Marks', async () => {
|
||||
const getMarkSpy = spyOn(
|
||||
service.marksApi,
|
||||
'getSecurityMarks'
|
||||
).and.returnValue(Promise.resolve(fakeMarksApiResponse));
|
||||
const markPromise = service.getSecurityMark(
|
||||
securityGroupId,
|
||||
0,
|
||||
'inUse'
|
||||
);
|
||||
const getMarkSpy = spyOn(service.marksApi, 'getSecurityMarks').and.returnValue(Promise.resolve(fakeMarksApiResponse));
|
||||
const markPromise = service.getSecurityMark(securityGroupId, 0);
|
||||
const mark = await markPromise;
|
||||
|
||||
expect(getMarkSpy).toHaveBeenCalledWith(securityGroupId, {
|
||||
skipCount: 0,
|
||||
include: 'inUse'
|
||||
skipCount: 0
|
||||
});
|
||||
|
||||
expect(mark.pagination.skipCount).toBe(0);
|
||||
expect(mark.pagination.maxItems).toBe(10);
|
||||
expect(mark.entries[0].groupId).toBe(
|
||||
'eddf6269-ceba-42c6-b979-9ac445d29a94'
|
||||
);
|
||||
expect(mark.entries[0].groupId).toBe('eddf6269-ceba-42c6-b979-9ac445d29a94');
|
||||
expect(mark.entries[0].name).toBe('securityMark1');
|
||||
expect(mark.entries[0].id).toBe('ffBOeOJJ');
|
||||
});
|
||||
@@ -176,12 +142,7 @@ describe('SecurityControlsService', () => {
|
||||
})
|
||||
)
|
||||
);
|
||||
const response = await service
|
||||
.updateSecurityMark(
|
||||
securityGroupId,
|
||||
securityMarkId,
|
||||
securityMarkBody
|
||||
);
|
||||
const response = await service.updateSecurityMark(securityGroupId, securityMarkId, securityMarkBody);
|
||||
|
||||
securityGroupId = response.entry.groupId;
|
||||
securityMarkId = response.entry.id;
|
||||
@@ -194,11 +155,11 @@ describe('SecurityControlsService', () => {
|
||||
spyOn(service.groupsApi, 'updateSecurityGroup').and.returnValue(
|
||||
Promise.resolve(
|
||||
new SecurityGroupEntry({
|
||||
entry: {
|
||||
entry: new SecurityGroup({
|
||||
groupName: 'TestGroup',
|
||||
groupType: 'HIERARCHICAL',
|
||||
id: 'eddf6269-ceba-42c6-b979-9ac445d29a94'
|
||||
}
|
||||
})
|
||||
})
|
||||
)
|
||||
);
|
||||
@@ -230,31 +191,15 @@ describe('SecurityControlsService', () => {
|
||||
});
|
||||
|
||||
it('should delete a security group', async () => {
|
||||
spyOn(service.groupsApi, 'deleteSecurityGroup').and.returnValue(
|
||||
Promise.resolve(
|
||||
new SecurityGroupEntry({
|
||||
entry: {
|
||||
groupName: 'TestGroup',
|
||||
groupType: 'HIERARCHICAL',
|
||||
id: 'eddf6269-ceba-42c6-b979-9ac445d29a94'
|
||||
}
|
||||
})
|
||||
)
|
||||
);
|
||||
const response = await service
|
||||
.deleteSecurityGroup(securityGroupId)
|
||||
.toPromise();
|
||||
|
||||
expect(response.entry.groupName).toEqual('TestGroup');
|
||||
expect(response.entry.groupType).toEqual('HIERARCHICAL');
|
||||
expect(response.entry.id).toEqual('eddf6269-ceba-42c6-b979-9ac445d29a94');
|
||||
spyOn(service.groupsApi, 'deleteSecurityGroup').and.returnValue(Promise.resolve());
|
||||
await service.deleteSecurityGroup(securityGroupId).toPromise();
|
||||
expect(service.groupsApi.deleteSecurityGroup).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should be able to get clearances for authority', async () => {
|
||||
const getClearancesForAuthoritySpy = spyOn(
|
||||
service.authorityClearanceApi,
|
||||
'getAuthorityClearanceForAuthority'
|
||||
).and.returnValue(Promise.resolve(fakeAuthorityClearanceApiResponse));
|
||||
const getClearancesForAuthoritySpy = spyOn(service.authorityClearanceApi, 'getAuthorityClearanceForAuthority').and.returnValue(
|
||||
Promise.resolve(fakeAuthorityClearanceApiResponse)
|
||||
);
|
||||
const clearancePromise = service.getClearancesForAuthority('test-id', 0, 10);
|
||||
const clearance = await clearancePromise.toPromise();
|
||||
|
||||
@@ -283,11 +228,15 @@ describe('SecurityControlsService', () => {
|
||||
})
|
||||
)
|
||||
);
|
||||
const response = await service.updateClearancesForAuthority('test-id', [{
|
||||
groupId: 'test-group-id',
|
||||
op: 'test-op',
|
||||
id: 'test-id'
|
||||
}]).toPromise();
|
||||
const response = await service
|
||||
.updateClearancesForAuthority('test-id', [
|
||||
{
|
||||
groupId: 'test-group-id',
|
||||
op: 'test-op',
|
||||
id: 'test-id'
|
||||
}
|
||||
])
|
||||
.toPromise();
|
||||
|
||||
if (response instanceof SecurityMarkEntry) {
|
||||
expect(response.entry.id).toEqual('test-id');
|
||||
@@ -296,8 +245,8 @@ describe('SecurityControlsService', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('should reload security groups', doneCallback => {
|
||||
service.reloadSecurityControls$.subscribe(res => {
|
||||
it('should reload security groups', (doneCallback) => {
|
||||
service.reloadSecurityControls$.subscribe((res) => {
|
||||
expect(res).toBeUndefined();
|
||||
doneCallback();
|
||||
});
|
||||
|
@@ -30,7 +30,8 @@ import {
|
||||
SecurityGroupPaging,
|
||||
AuthorityClearanceApi,
|
||||
AuthorityClearanceGroupPaging,
|
||||
NodeSecurityMarkBody
|
||||
NodeSecurityMarkBody,
|
||||
GsGroupInclude
|
||||
} from '@alfresco/js-api';
|
||||
import { AlfrescoApiService, UserPreferencesService } from '@alfresco/adf-core';
|
||||
import { finalize } from 'rxjs/operators';
|
||||
@@ -125,8 +126,8 @@ export class SecurityControlsService {
|
||||
const payload: SecurityGroupBody = {
|
||||
...input
|
||||
};
|
||||
const opts = {
|
||||
DEFAULT_INCLUDE
|
||||
const opts: GsGroupInclude = {
|
||||
include: DEFAULT_INCLUDE
|
||||
};
|
||||
const promise = this.groupsApi.createSecurityGroup(payload, opts);
|
||||
|
||||
@@ -169,19 +170,16 @@ export class SecurityControlsService {
|
||||
*
|
||||
* @param securityGroupId The key for the security group id.
|
||||
* @param skipCount The number of entities that exist in the collection before those included in this list.
|
||||
* @param include The key for the security mark is in use or not
|
||||
* @return Promise<SecurityControlsMarkResponse>
|
||||
*/
|
||||
getSecurityMark(
|
||||
securityGroupId: string,
|
||||
skipCount = DEFAULT_SKIP_COUNT,
|
||||
include = DEFAULT_INCLUDE
|
||||
skipCount = DEFAULT_SKIP_COUNT
|
||||
): Promise<SecurityControlsMarkResponse> {
|
||||
let securityControlsMarkResponse: SecurityControlsMarkResponse;
|
||||
return new Promise((resolve, reject) => {
|
||||
this.marksApi
|
||||
.getSecurityMarks(securityGroupId, {
|
||||
include,
|
||||
skipCount
|
||||
})
|
||||
.then((response: SecurityMarkPaging) => {
|
||||
@@ -276,11 +274,11 @@ export class SecurityControlsService {
|
||||
* Delete security group
|
||||
*
|
||||
* @param securityGroupId The key for the security group id.
|
||||
* @return Observable<SecurityGroupEntry>
|
||||
* @return Observable<void>
|
||||
*/
|
||||
deleteSecurityGroup(
|
||||
securityGroupId: string
|
||||
): Observable<SecurityGroupEntry> {
|
||||
): Observable<void> {
|
||||
this.loadingSource.next(true);
|
||||
const promise = this.groupsApi.deleteSecurityGroup(securityGroupId);
|
||||
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
import { Component, EventEmitter, Input, OnInit, Output, ViewEncapsulation } from '@angular/core';
|
||||
import { LogService, InfiniteSelectScrollDirective, AuthenticationService } from '@alfresco/adf-core';
|
||||
import { SitePaging, SiteEntry } from '@alfresco/js-api';
|
||||
import { SitePaging, SiteEntry, Site } from '@alfresco/js-api';
|
||||
import { MatSelectChange } from '@angular/material/select';
|
||||
import {LiveAnnouncer} from '@angular/cdk/a11y';
|
||||
import {TranslateService} from '@ngx-translate/core';
|
||||
@@ -128,11 +128,7 @@ export class DropdownSitesComponent implements OnInit {
|
||||
|
||||
if (!this.hideMyFiles) {
|
||||
const siteEntry = new SiteEntry({
|
||||
entry: {
|
||||
id: this.MY_FILES_VALUE,
|
||||
guid: this.MY_FILES_VALUE,
|
||||
title: 'DROPDOWN.MY_FILES_OPTION'
|
||||
}
|
||||
entry: new Site({ id: this.MY_FILES_VALUE, guid: this.MY_FILES_VALUE, title: 'DROPDOWN.MY_FILES_OPTION' })
|
||||
});
|
||||
|
||||
this.siteList.list.entries.unshift(siteEntry);
|
||||
@@ -180,7 +176,7 @@ export class DropdownSitesComponent implements OnInit {
|
||||
return sites;
|
||||
}
|
||||
|
||||
private isCurrentUserMember(site, loggedUserName): boolean {
|
||||
private isCurrentUserMember(site: SiteEntry, loggedUserName: string): boolean {
|
||||
return site.entry.visibility === 'PUBLIC' ||
|
||||
!!site.relations.members.list.entries.find((member) => member.entry.id.toLowerCase() === loggedUserName.toLowerCase());
|
||||
}
|
||||
|
@@ -24,7 +24,6 @@ import { throwError } from 'rxjs';
|
||||
import { Pagination, Tag, TagBody, TagEntry, TagPaging, TagPagingList } from '@alfresco/js-api';
|
||||
|
||||
describe('TagService', () => {
|
||||
|
||||
let service: TagService;
|
||||
let logService: LogService;
|
||||
let userPreferencesService: UserPreferencesService;
|
||||
@@ -43,37 +42,32 @@ describe('TagService', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
ContentTestingModule
|
||||
]
|
||||
imports: [TranslateModule.forRoot(), ContentTestingModule]
|
||||
});
|
||||
service = TestBed.inject(TagService);
|
||||
logService = TestBed.inject(LogService);
|
||||
userPreferencesService = TestBed.inject(UserPreferencesService);
|
||||
|
||||
spyOn(service.tagsApi, 'deleteTagFromNode').and.returnValue(
|
||||
Promise.resolve({})
|
||||
);
|
||||
spyOn(service.tagsApi, 'createTagForNode').and.returnValue(
|
||||
Promise.resolve(new TagEntry({}))
|
||||
);
|
||||
spyOn(service.tagsApi, 'deleteTagFromNode').and.returnValue(Promise.resolve());
|
||||
spyOn(service.tagsApi, 'createTagForNode').and.returnValue(Promise.resolve(new TagEntry({})));
|
||||
});
|
||||
|
||||
describe('Content tests', () => {
|
||||
|
||||
it('should catch errors on getTagsByNodeId 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');
|
||||
});
|
||||
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('should trigger a refresh event on removeTag() call', async () => {
|
||||
await service.refresh.subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
await service.refresh.subscribe(() => {
|
||||
expect(service.tagsApi.deleteTagFromNode).toHaveBeenCalledWith('fake-node-id', 'fake-tag');
|
||||
});
|
||||
|
||||
service.removeTag('fake-node-id', 'fake-tag');
|
||||
@@ -108,12 +102,14 @@ describe('TagService', () => {
|
||||
});
|
||||
|
||||
it('should emit refresh when tags creation is success', fakeAsync(() => {
|
||||
const tags: TagEntry[] = [{
|
||||
entry: {
|
||||
id: 'Some id 1',
|
||||
tag: 'Some tag 1'
|
||||
const tags: TagEntry[] = [
|
||||
{
|
||||
entry: {
|
||||
id: 'Some id 1',
|
||||
tag: 'Some tag 1'
|
||||
}
|
||||
}
|
||||
}];
|
||||
];
|
||||
spyOn(service.refresh, 'emit');
|
||||
spyOn(service.tagsApi, 'createTags').and.returnValue(Promise.resolve(tags));
|
||||
service.createTags([]);
|
||||
@@ -140,11 +136,14 @@ describe('TagService', () => {
|
||||
|
||||
it('should call listTags on TagsApi with correct parameters when includedCounts is true', () => {
|
||||
spyOn(service.tagsApi, 'listTags').and.returnValue(Promise.resolve(result));
|
||||
const skipCount = 10;
|
||||
const skipCount = 10;
|
||||
|
||||
service.getAllTheTags({
|
||||
skipCount
|
||||
}, true);
|
||||
service.getAllTheTags(
|
||||
{
|
||||
skipCount
|
||||
},
|
||||
true
|
||||
);
|
||||
expect(service.tagsApi.listTags).toHaveBeenCalledWith({
|
||||
include: ['count'],
|
||||
skipCount
|
||||
@@ -153,11 +152,14 @@ describe('TagService', () => {
|
||||
|
||||
it('should call listTags on TagsApi with correct parameters when includedCounts is false', () => {
|
||||
spyOn(service.tagsApi, 'listTags').and.returnValue(Promise.resolve(result));
|
||||
const skipCount = 10;
|
||||
const skipCount = 10;
|
||||
|
||||
service.getAllTheTags({
|
||||
skipCount
|
||||
}, false);
|
||||
service.getAllTheTags(
|
||||
{
|
||||
skipCount
|
||||
},
|
||||
false
|
||||
);
|
||||
expect(service.tagsApi.listTags).toHaveBeenCalledWith({
|
||||
include: undefined,
|
||||
skipCount
|
||||
@@ -264,7 +266,7 @@ describe('TagService', () => {
|
||||
id: 'fake-node-id'
|
||||
}
|
||||
};
|
||||
const tagBody: TagBody = {tag: 'updated-tag'};
|
||||
const tagBody: TagBody = { tag: 'updated-tag' };
|
||||
const updatedTag: TagEntry = {
|
||||
entry: {
|
||||
...tagBody,
|
||||
@@ -361,7 +363,9 @@ describe('TagService', () => {
|
||||
});
|
||||
|
||||
it('should call assignTagsToNode on TagsApi with correct parameters', () => {
|
||||
spyOn(service.tagsApi, 'assignTagsToNode').and.returnValue(Promise.resolve(singleResult));
|
||||
spyOn(service.tagsApi, 'assignTagsToNode').and.returnValue(
|
||||
Promise.resolve(new TagPaging({ list: new TagPagingList({ entries: [singleResult] }) }))
|
||||
);
|
||||
|
||||
service.assignTagsToNode(nodeId, tags);
|
||||
expect(service.tagsApi.assignTagsToNode).toHaveBeenCalledWith(nodeId, tags);
|
||||
@@ -381,10 +385,12 @@ describe('TagService', () => {
|
||||
}));
|
||||
|
||||
it('should return observable which emits single tag', fakeAsync(() => {
|
||||
spyOn(service.tagsApi, 'assignTagsToNode').and.returnValue(Promise.resolve(singleResult));
|
||||
spyOn(service.tagsApi, 'assignTagsToNode').and.returnValue(
|
||||
Promise.resolve(new TagPaging({ list: new TagPagingList({ entries: [singleResult] }) }))
|
||||
);
|
||||
|
||||
service.assignTagsToNode(nodeId, tags).subscribe((tagsResult) => {
|
||||
expect(tagsResult).toEqual(singleResult);
|
||||
expect(tagsResult).toEqual(new TagPaging({ list: new TagPagingList({ entries: [singleResult] }) }));
|
||||
});
|
||||
tick();
|
||||
}));
|
||||
|
@@ -99,8 +99,8 @@ export class TagService {
|
||||
removeTag(nodeId: string, tag: string): Observable<void> {
|
||||
const observableRemove = from(this.tagsApi.deleteTagFromNode(nodeId, tag));
|
||||
|
||||
observableRemove.subscribe((data) => {
|
||||
this.refresh.emit(data);
|
||||
observableRemove.subscribe(() => {
|
||||
this.refresh.emit();
|
||||
}, (err) => {
|
||||
this.handleError(err);
|
||||
});
|
||||
|
@@ -22,28 +22,39 @@ import { ContentTestingModule } from '../../testing/content.testing.module';
|
||||
import { of } from 'rxjs';
|
||||
import { TreeBaseNode } from '../models/tree-view.model';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { NodePaging } from '@alfresco/js-api';
|
||||
import { Node, NodePaging } from '@alfresco/js-api';
|
||||
|
||||
describe('TreeViewService', () => {
|
||||
|
||||
let service: TreeViewService;
|
||||
let nodeService: NodesApiService;
|
||||
|
||||
const fakeNodeList = new NodePaging({ list: { entries: [
|
||||
{ entry: { id: 'fake-node-id', name: 'fake-node-name', isFolder: true } }
|
||||
] } });
|
||||
const fakeNodeList = new NodePaging({
|
||||
list: {
|
||||
entries: [
|
||||
{
|
||||
entry: new Node({
|
||||
id: 'fake-node-id',
|
||||
name: 'fake-node-name',
|
||||
isFolder: true,
|
||||
isFile: false,
|
||||
nodeType: 'cm:folder',
|
||||
createdByUser: null,
|
||||
modifiedByUser: null,
|
||||
createdAt: new Date(),
|
||||
modifiedAt: new Date()
|
||||
})
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
const fakeMixedNodeList = new NodePaging({ list: { entries: [
|
||||
{ entry: { id: 'fake-node-id', name: 'fake-node-name', isFolder: true } },
|
||||
{ entry: { id: 'fake-file-id', name: 'fake-file-name', isFolder: false } }
|
||||
] } });
|
||||
const fakeMixedNodeList = new NodePaging({
|
||||
list: { entries: [fakeNodeList.list.entries[0], { entry: new Node({ id: 'fake-file-id', name: 'fake-file-name', isFolder: false }) }] }
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
ContentTestingModule
|
||||
]
|
||||
imports: [TranslateModule.forRoot(), ContentTestingModule]
|
||||
});
|
||||
service = TestBed.inject(TreeViewService);
|
||||
nodeService = TestBed.inject(NodesApiService);
|
||||
|
@@ -19,7 +19,7 @@ import { SimpleChange } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { of, throwError } from 'rxjs';
|
||||
import { UploadButtonComponent } from './upload-button.component';
|
||||
import { NodeEntry } from '@alfresco/js-api';
|
||||
import { Node, NodeEntry } from '@alfresco/js-api';
|
||||
import { ContentTestingModule } from '../../testing/content.testing.module';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { mockUploadErrorPromise } from '../../mock/upload.service.mock';
|
||||
@@ -28,7 +28,6 @@ import { NodesApiService } from '../../common/services/nodes-api.service';
|
||||
import { FileUploadErrorEvent } from '../../common/events/file.event';
|
||||
|
||||
describe('UploadButtonComponent', () => {
|
||||
|
||||
const file = { name: 'fake-name-1', size: 10, webkitRelativePath: 'fake-folder1/fake-name-1.json' };
|
||||
const fakeEvent = {
|
||||
currentTarget: {
|
||||
@@ -38,15 +37,7 @@ describe('UploadButtonComponent', () => {
|
||||
};
|
||||
|
||||
const fakeFolderNodeWithPermission = new NodeEntry({
|
||||
entry: {
|
||||
allowableOperations: [
|
||||
'create',
|
||||
'update'
|
||||
],
|
||||
isFolder: true,
|
||||
name: 'Folder Fake Name',
|
||||
nodeType: 'cm:folder'
|
||||
}
|
||||
entry: new Node({ name: 'Folder Fake Name', nodeType: 'cm:folder', isFolder: true, allowableOperations: ['create', 'update'] })
|
||||
});
|
||||
|
||||
let component: UploadButtonComponent;
|
||||
@@ -56,10 +47,7 @@ describe('UploadButtonComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
ContentTestingModule
|
||||
]
|
||||
imports: [TranslateModule.forRoot(), ContentTestingModule]
|
||||
});
|
||||
fixture = TestBed.createComponent(UploadButtonComponent);
|
||||
uploadService = TestBed.inject(UploadService);
|
||||
@@ -214,11 +202,7 @@ describe('UploadButtonComponent', () => {
|
||||
});
|
||||
|
||||
describe('fileSize', () => {
|
||||
|
||||
const files: File[] = [
|
||||
{ name: 'bigFile.png', size: 1000 } as File,
|
||||
{ name: 'smallFile.png', size: 10 } as File
|
||||
];
|
||||
const files: File[] = [{ name: 'bigFile.png', size: 1000 } as File, { name: 'smallFile.png', size: 10 } as File];
|
||||
|
||||
let addToQueueSpy;
|
||||
|
||||
@@ -245,9 +229,7 @@ describe('UploadButtonComponent', () => {
|
||||
});
|
||||
|
||||
it('should allow file of 0 size when the max file size is set to 0', () => {
|
||||
const zeroFiles: File[] = [
|
||||
{ name: 'zeroFile.png', size: 0 } as File
|
||||
];
|
||||
const zeroFiles: File[] = [{ name: 'zeroFile.png', size: 0 } as File];
|
||||
component.maxFilesSize = 0;
|
||||
|
||||
component.uploadFiles(zeroFiles);
|
||||
@@ -284,12 +266,7 @@ describe('UploadButtonComponent', () => {
|
||||
});
|
||||
|
||||
describe('uploadFiles', () => {
|
||||
|
||||
const files: File[] = [
|
||||
{ name: 'phobos.jpg' } as File,
|
||||
{ name: 'deimos.png' } as File,
|
||||
{ name: 'ganymede.bmp' } as File
|
||||
];
|
||||
const files: File[] = [{ name: 'phobos.jpg' } as File, { name: 'deimos.png' } as File, { name: 'ganymede.bmp' } as File];
|
||||
|
||||
let addToQueueSpy;
|
||||
|
||||
@@ -344,8 +321,7 @@ describe('UploadButtonComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(uploadService, 'uploadFilesInTheQueue').and.stub();
|
||||
fakeNodeWithNoPermission = {
|
||||
};
|
||||
fakeNodeWithNoPermission = {};
|
||||
});
|
||||
|
||||
it('should not call uploadFiles for node without permission', () => {
|
||||
|
@@ -21,7 +21,7 @@ import { By } from '@angular/platform-browser';
|
||||
import { VersionListComponent } from './version-list.component';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { of } from 'rxjs';
|
||||
import { Node, VersionPaging, VersionEntry, NodeEntry } from '@alfresco/js-api';
|
||||
import { Node, VersionPaging, NodeEntry, VersionEntry, Version } from '@alfresco/js-api';
|
||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { ContentVersionService } from './content-version.service';
|
||||
@@ -36,8 +36,8 @@ describe('VersionListComponent', () => {
|
||||
const versionId = '1.0';
|
||||
|
||||
const versionTest = [
|
||||
{ entry: { name: 'test-file-name', id: '1.0', versionComment: 'test-version-comment' } } as VersionEntry,
|
||||
{ entry: { name: 'test-file-name-two', id: '1.0', versionComment: 'test-version-comment' } } as VersionEntry
|
||||
new VersionEntry({ entry: new Version({ name: 'test-file-name', id: '1.0', versionComment: 'test-version-comment' }) }),
|
||||
new VersionEntry({ entry: new Version({ name: 'test-file-name-two', id: '1.0', versionComment: 'test-version-comment' }) })
|
||||
];
|
||||
|
||||
afterEach(() => {
|
||||
@@ -47,10 +47,7 @@ describe('VersionListComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
ContentTestingModule
|
||||
],
|
||||
imports: [TranslateModule.forRoot(), ContentTestingModule],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||
});
|
||||
fixture = TestBed.createComponent(VersionListComponent);
|
||||
@@ -61,7 +58,7 @@ describe('VersionListComponent', () => {
|
||||
component.node = { id: nodeId, allowableOperations: ['update'] } as Node;
|
||||
|
||||
spyOn(component, 'downloadContent').and.stub();
|
||||
spyOn(component.nodesApi, 'getNode').and.returnValue(Promise.resolve(new NodeEntry({ entry: { id: 'nodeInfoId' } })));
|
||||
spyOn(component.nodesApi, 'getNode').and.returnValue(Promise.resolve(new NodeEntry({ entry: new Node({ id: 'nodeInfoId' }) })));
|
||||
});
|
||||
|
||||
it('should raise confirmation dialog on delete', () => {
|
||||
@@ -84,7 +81,7 @@ describe('VersionListComponent', () => {
|
||||
afterClosed: () => of(true)
|
||||
} as any);
|
||||
|
||||
spyOn(component.versionsApi, 'deleteVersion').and.returnValue(Promise.resolve(true));
|
||||
spyOn(component.versionsApi, 'deleteVersion').and.returnValue(Promise.resolve());
|
||||
|
||||
component.deleteVersion(versionId);
|
||||
|
||||
@@ -99,7 +96,7 @@ describe('VersionListComponent', () => {
|
||||
afterClosed: () => of(false)
|
||||
} as any);
|
||||
|
||||
spyOn(component.versionsApi, 'deleteVersion').and.returnValue(Promise.resolve(true));
|
||||
spyOn(component.versionsApi, 'deleteVersion').and.returnValue(Promise.resolve());
|
||||
|
||||
component.deleteVersion(versionId);
|
||||
|
||||
@@ -118,10 +115,8 @@ describe('VersionListComponent', () => {
|
||||
});
|
||||
|
||||
describe('Version history fetching', () => {
|
||||
|
||||
it('should use loading bar', () => {
|
||||
spyOn(component.versionsApi, 'listVersionHistory').and
|
||||
.callFake(() => Promise.resolve({ list: { entries: versionTest } }));
|
||||
spyOn(component.versionsApi, 'listVersionHistory').and.callFake(() => Promise.resolve({ list: { entries: versionTest } }));
|
||||
|
||||
let loadingProgressBar = fixture.debugElement.query(By.css('[data-automation-id="version-history-loading-bar"]'));
|
||||
expect(loadingProgressBar).toBeNull();
|
||||
@@ -134,8 +129,7 @@ describe('VersionListComponent', () => {
|
||||
});
|
||||
|
||||
it('should load the versions for a given id', () => {
|
||||
spyOn(component.versionsApi, 'listVersionHistory').and
|
||||
.callFake(() => Promise.resolve({ list: { entries: versionTest } }));
|
||||
spyOn(component.versionsApi, 'listVersionHistory').and.callFake(() => Promise.resolve({ list: { entries: versionTest } }));
|
||||
|
||||
component.ngOnChanges();
|
||||
fixture.detectChanges();
|
||||
@@ -145,15 +139,15 @@ describe('VersionListComponent', () => {
|
||||
|
||||
it('should show the versions after loading', (done) => {
|
||||
fixture.detectChanges();
|
||||
spyOn(component.versionsApi, 'listVersionHistory').and.callFake(() => Promise.resolve(new VersionPaging({
|
||||
list: {
|
||||
entries: [
|
||||
{
|
||||
entry: { name: 'test-file-name', id: '1.0', versionComment: 'test-version-comment' }
|
||||
spyOn(component.versionsApi, 'listVersionHistory').and.callFake(() =>
|
||||
Promise.resolve(
|
||||
new VersionPaging({
|
||||
list: {
|
||||
entries: [versionTest[0]]
|
||||
}
|
||||
]
|
||||
}
|
||||
})));
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
component.ngOnChanges();
|
||||
|
||||
@@ -171,18 +165,15 @@ describe('VersionListComponent', () => {
|
||||
});
|
||||
|
||||
it('should NOT show the versions comments if input property is set not to show them', (done) => {
|
||||
spyOn(component.versionsApi, 'listVersionHistory').and
|
||||
.callFake(() => Promise.resolve(
|
||||
spyOn(component.versionsApi, 'listVersionHistory').and.callFake(() =>
|
||||
Promise.resolve(
|
||||
new VersionPaging({
|
||||
list: {
|
||||
entries: [
|
||||
{
|
||||
entry: { name: 'test-file-name', id: '1.0', versionComment: 'test-version-comment' }
|
||||
}
|
||||
]
|
||||
entries: [versionTest[0]]
|
||||
}
|
||||
})
|
||||
));
|
||||
)
|
||||
);
|
||||
|
||||
component.showComments = false;
|
||||
fixture.detectChanges();
|
||||
@@ -199,14 +190,9 @@ describe('VersionListComponent', () => {
|
||||
});
|
||||
|
||||
it('should be able to download a version', () => {
|
||||
const versionEntry = {
|
||||
entry: {
|
||||
name: 'test-file-name',
|
||||
id: '1.0',
|
||||
versionComment: 'test-version-comment'
|
||||
}
|
||||
};
|
||||
spyOn(component.versionsApi, 'listVersionHistory').and.returnValue(Promise.resolve(new VersionPaging({ list: { entries: [versionEntry] } })));
|
||||
spyOn(component.versionsApi, 'listVersionHistory').and.returnValue(
|
||||
Promise.resolve(new VersionPaging({ list: { entries: [versionTest[0]] } }))
|
||||
);
|
||||
spyOn(contentVersionService.contentApi, 'getContentUrl').and.returnValue('the/download/url');
|
||||
|
||||
fixture.detectChanges();
|
||||
@@ -223,15 +209,9 @@ describe('VersionListComponent', () => {
|
||||
});
|
||||
|
||||
it('should NOT be able to download a version if configured so', () => {
|
||||
const versionEntry = {
|
||||
entry: {
|
||||
name: 'test-file-name',
|
||||
id: '1.0',
|
||||
versionComment: 'test-version-comment'
|
||||
}
|
||||
};
|
||||
spyOn(component.versionsApi, 'listVersionHistory').and
|
||||
.callFake(() => Promise.resolve(new VersionPaging({ list: { entries: [versionEntry] } })));
|
||||
spyOn(component.versionsApi, 'listVersionHistory').and.callFake(() =>
|
||||
Promise.resolve(new VersionPaging({ list: { entries: [versionTest[0]] } }))
|
||||
);
|
||||
const spyOnDownload = spyOn(component.contentApi, 'getContentUrl').and.stub();
|
||||
|
||||
component.allowDownload = false;
|
||||
@@ -243,7 +223,6 @@ describe('VersionListComponent', () => {
|
||||
});
|
||||
|
||||
describe('Version restoring', () => {
|
||||
|
||||
it('should restore version only when restore allowed', () => {
|
||||
component.node.allowableOperations = [];
|
||||
spyOn(component.versionsApi, 'revertVersion').and.stub();
|
||||
@@ -255,9 +234,7 @@ describe('VersionListComponent', () => {
|
||||
fixture.detectChanges();
|
||||
component.versions = versionTest;
|
||||
|
||||
const spyOnRevertVersion = spyOn(component.versionsApi, 'revertVersion').and
|
||||
.callFake(() => Promise.resolve(new VersionEntry(
|
||||
{ entry: { name: 'test-file-name', id: '1.0', versionComment: 'test-version-comment' } })));
|
||||
const spyOnRevertVersion = spyOn(component.versionsApi, 'revertVersion').and.callFake(() => Promise.resolve(versionTest[0]));
|
||||
|
||||
component.restore(versionId);
|
||||
|
||||
@@ -267,12 +244,9 @@ describe('VersionListComponent', () => {
|
||||
it('should get node info after restoring the node', fakeAsync(() => {
|
||||
fixture.detectChanges();
|
||||
component.versions = versionTest;
|
||||
spyOn(component.versionsApi, 'listVersionHistory')
|
||||
.and.callFake(() => Promise.resolve({ list: { entries: versionTest } }));
|
||||
spyOn(component.versionsApi, 'listVersionHistory').and.callFake(() => Promise.resolve({ list: { entries: versionTest } }));
|
||||
|
||||
spyOn(component.versionsApi, 'revertVersion')
|
||||
.and.callFake(() => Promise.resolve(new VersionEntry(
|
||||
{ entry: { name: 'test-file-name', id: '1.0', versionComment: 'test-version-comment' } })));
|
||||
spyOn(component.versionsApi, 'revertVersion').and.callFake(() => Promise.resolve(versionTest[0]));
|
||||
|
||||
component.restore(versionId);
|
||||
fixture.detectChanges();
|
||||
@@ -284,12 +258,9 @@ describe('VersionListComponent', () => {
|
||||
it('should emit with node info data', fakeAsync(() => {
|
||||
fixture.detectChanges();
|
||||
component.versions = versionTest;
|
||||
spyOn(component.versionsApi, 'listVersionHistory')
|
||||
.and.callFake(() => Promise.resolve({ list: { entries: versionTest } }));
|
||||
spyOn(component.versionsApi, 'listVersionHistory').and.callFake(() => Promise.resolve({ list: { entries: versionTest } }));
|
||||
|
||||
spyOn(component.versionsApi, 'revertVersion')
|
||||
.and.callFake(() => Promise.resolve(new VersionEntry(
|
||||
{ entry: { name: 'test-file-name', id: '1.0', versionComment: 'test-version-comment' } })));
|
||||
spyOn(component.versionsApi, 'revertVersion').and.callFake(() => Promise.resolve(versionTest[0]));
|
||||
|
||||
spyOn(component.restored, 'emit');
|
||||
|
||||
@@ -304,8 +275,9 @@ describe('VersionListComponent', () => {
|
||||
fixture.detectChanges();
|
||||
component.versions = versionTest;
|
||||
|
||||
const spyOnListVersionHistory = spyOn(component.versionsApi, 'listVersionHistory').and
|
||||
.callFake(() => Promise.resolve({ list: { entries: versionTest } }));
|
||||
const spyOnListVersionHistory = spyOn(component.versionsApi, 'listVersionHistory').and.callFake(() =>
|
||||
Promise.resolve({ list: { entries: versionTest } })
|
||||
);
|
||||
spyOn(component.versionsApi, 'revertVersion').and.callFake(() => Promise.resolve(null));
|
||||
|
||||
component.restore(versionId);
|
||||
@@ -329,18 +301,16 @@ describe('VersionListComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
fixture.detectChanges();
|
||||
spyOn(component.versionsApi, 'listVersionHistory').and.callFake(() => Promise.resolve(new VersionPaging({
|
||||
list: {
|
||||
entries: [
|
||||
{
|
||||
entry: { name: 'test-file-two', id: '1.1', versionComment: 'test-version-comment' }
|
||||
},
|
||||
{
|
||||
entry: { name: 'test-file-name', id: '1.0', versionComment: 'test-version-comment' }
|
||||
versionTest[1].entry.id = '1.1';
|
||||
spyOn(component.versionsApi, 'listVersionHistory').and.callFake(() =>
|
||||
Promise.resolve(
|
||||
new VersionPaging({
|
||||
list: {
|
||||
entries: versionTest
|
||||
}
|
||||
]
|
||||
}
|
||||
})));
|
||||
})
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
describe('showActions', () => {
|
||||
@@ -373,7 +343,6 @@ describe('VersionListComponent', () => {
|
||||
});
|
||||
|
||||
describe('disabled', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
component.node = { id: nodeId } as Node;
|
||||
component.ngOnChanges();
|
||||
@@ -406,7 +375,6 @@ describe('VersionListComponent', () => {
|
||||
});
|
||||
|
||||
describe('enabled', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
component.node = { id: nodeId, allowableOperations: ['update', 'delete'] } as Node;
|
||||
component.ngOnChanges();
|
||||
@@ -425,7 +393,7 @@ describe('VersionListComponent', () => {
|
||||
|
||||
it('should enable restore action if is allowed', (done) => {
|
||||
fixture.whenStable().then(() => {
|
||||
expect(getRestoreButton().disabled).toBeFalse();
|
||||
expect(getRestoreButton('1.1').disabled).toBeFalse();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@@ -18,7 +18,7 @@
|
||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { Node, VersionPaging } from '@alfresco/js-api';
|
||||
import { Node, Version, VersionEntry, VersionPaging } from '@alfresco/js-api';
|
||||
import { VersionManagerComponent } from './version-manager.component';
|
||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
@@ -31,25 +31,16 @@ describe('VersionManagerComponent', () => {
|
||||
let nodesApiService: NodesApiService;
|
||||
|
||||
const expectedComment = 'test-version-comment';
|
||||
const node: Node = new Node({
|
||||
const node: Node = new Node({
|
||||
id: '1234',
|
||||
name: 'TEST-NODE',
|
||||
isFile: true
|
||||
});
|
||||
const versionEntry = {
|
||||
entry: {
|
||||
id: '1.0',
|
||||
name: node.name,
|
||||
versionComment: expectedComment
|
||||
}
|
||||
};
|
||||
const versionEntry = new VersionEntry({ entry: new Version({ id: '1.0', name: node.name, versionComment: expectedComment }) });
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
ContentTestingModule
|
||||
],
|
||||
imports: [TranslateModule.forRoot(), ContentTestingModule],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||
});
|
||||
fixture = TestBed.createComponent(VersionManagerComponent);
|
||||
@@ -57,8 +48,9 @@ describe('VersionManagerComponent', () => {
|
||||
component.node = node;
|
||||
|
||||
nodesApiService = TestBed.inject(NodesApiService);
|
||||
spyOnListVersionHistory = spyOn(component.versionListComponent['versionsApi'], 'listVersionHistory').and
|
||||
.callFake(() => Promise.resolve(new VersionPaging({ list: { entries: [ versionEntry ] }})));
|
||||
spyOnListVersionHistory = spyOn(component.versionListComponent['versionsApi'], 'listVersionHistory').and.callFake(() =>
|
||||
Promise.resolve(new VersionPaging({ list: { entries: [versionEntry] } }))
|
||||
);
|
||||
});
|
||||
|
||||
it('should load the versions for a given node', () => {
|
||||
@@ -92,7 +84,7 @@ describe('VersionManagerComponent', () => {
|
||||
it('should emit success event upon successful upload of a new version', async () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
const emittedData = { value: { entry: node }};
|
||||
const emittedData = { value: { entry: node } };
|
||||
await component.uploadSuccess.subscribe((event) => {
|
||||
expect(event).toBe(node);
|
||||
});
|
||||
@@ -105,12 +97,11 @@ describe('VersionManagerComponent', () => {
|
||||
expect(res).toEqual(node);
|
||||
});
|
||||
|
||||
const emittedData = { value: { entry: node }};
|
||||
const emittedData = { value: { entry: node } };
|
||||
component.onUploadSuccess(emittedData);
|
||||
});
|
||||
|
||||
describe('Animation', () => {
|
||||
|
||||
it('should upload button be hide by default', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
@@ -126,5 +117,5 @@ describe('VersionManagerComponent', () => {
|
||||
|
||||
expect(component.uploadState).toEqual('open');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -24,7 +24,7 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { AppExtensionService, ViewerExtensionRef } from '@alfresco/adf-extensions';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { NodeEntry, VersionEntry } from '@alfresco/js-api';
|
||||
import { ContentInfo, Node, NodeEntry, VersionEntry } from '@alfresco/js-api';
|
||||
import { AlfrescoViewerComponent, NodeActionsService, RenditionService } from '@alfresco/adf-content-services';
|
||||
import { CoreTestingModule, EventMock, ViewUtilService, ViewerComponent } from '@alfresco/adf-core';
|
||||
import { NodesApiService } from '../../common/services/nodes-api.service';
|
||||
@@ -45,8 +45,7 @@ import { By } from '@angular/platform-browser';
|
||||
</adf-alfresco-viewer>
|
||||
`
|
||||
})
|
||||
class ViewerWithCustomToolbarComponent {
|
||||
}
|
||||
class ViewerWithCustomToolbarComponent {}
|
||||
|
||||
@Component({
|
||||
selector: 'adf-viewer-container-toolbar-actions',
|
||||
@@ -60,8 +59,7 @@ class ViewerWithCustomToolbarComponent {
|
||||
</adf-alfresco-viewer>
|
||||
`
|
||||
})
|
||||
class ViewerWithCustomToolbarActionsComponent {
|
||||
}
|
||||
class ViewerWithCustomToolbarActionsComponent {}
|
||||
|
||||
@Component({
|
||||
selector: 'adf-viewer-container-sidebar',
|
||||
@@ -73,15 +71,13 @@ class ViewerWithCustomToolbarActionsComponent {
|
||||
</adf-alfresco-viewer>
|
||||
`
|
||||
})
|
||||
class ViewerWithCustomSidebarComponent {
|
||||
}
|
||||
class ViewerWithCustomSidebarComponent {}
|
||||
|
||||
@Component({
|
||||
selector: 'adf-dialog-dummy',
|
||||
template: ``
|
||||
})
|
||||
class DummyDialogComponent {
|
||||
}
|
||||
class DummyDialogComponent {}
|
||||
|
||||
@Component({
|
||||
selector: 'adf-viewer-container-open-with',
|
||||
@@ -104,8 +100,7 @@ class DummyDialogComponent {
|
||||
</adf-alfresco-viewer>
|
||||
`
|
||||
})
|
||||
class ViewerWithCustomOpenWithComponent {
|
||||
}
|
||||
class ViewerWithCustomOpenWithComponent {}
|
||||
|
||||
@Component({
|
||||
selector: 'adf-viewer-container-more-actions',
|
||||
@@ -128,12 +123,9 @@ class ViewerWithCustomOpenWithComponent {
|
||||
</adf-alfresco-viewer>
|
||||
`
|
||||
})
|
||||
class ViewerWithCustomMoreActionsComponent {
|
||||
}
|
||||
|
||||
class ViewerWithCustomMoreActionsComponent {}
|
||||
|
||||
describe('AlfrescoViewerComponent', () => {
|
||||
|
||||
let component: AlfrescoViewerComponent;
|
||||
let fixture: ComponentFixture<AlfrescoViewerComponent>;
|
||||
let element: HTMLElement;
|
||||
@@ -148,13 +140,7 @@ describe('AlfrescoViewerComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
NoopAnimationsModule,
|
||||
TranslateModule.forRoot(),
|
||||
CoreTestingModule,
|
||||
MatButtonModule,
|
||||
MatIconModule
|
||||
],
|
||||
imports: [NoopAnimationsModule, TranslateModule.forRoot(), CoreTestingModule, MatButtonModule, MatIconModule],
|
||||
declarations: [
|
||||
ViewerWithCustomToolbarComponent,
|
||||
ViewerWithCustomSidebarComponent,
|
||||
@@ -164,12 +150,13 @@ describe('AlfrescoViewerComponent', () => {
|
||||
],
|
||||
providers: [
|
||||
{
|
||||
provide: RenditionService, useValue: {
|
||||
provide: RenditionService,
|
||||
useValue: {
|
||||
getNodeRendition: () => throwError('thrown'),
|
||||
generateMediaTracksRendition: () => {}
|
||||
}
|
||||
},
|
||||
{provide: Location, useClass: SpyLocation},
|
||||
{ provide: Location, useClass: SpyLocation },
|
||||
MatDialog
|
||||
],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||
@@ -191,11 +178,8 @@ describe('AlfrescoViewerComponent', () => {
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
|
||||
describe('Extension Type Test', () => {
|
||||
|
||||
|
||||
it('should use external viewer to display node by id', fakeAsync(() => {
|
||||
it('should use external viewer to display node by id', fakeAsync(() => {
|
||||
const extension: ViewerExtensionRef = {
|
||||
component: 'custom.component',
|
||||
id: 'custom.component.id',
|
||||
@@ -210,7 +194,7 @@ describe('AlfrescoViewerComponent', () => {
|
||||
element = fixture.nativeElement;
|
||||
component = fixture.componentInstance;
|
||||
|
||||
spyOn(component.nodesApi, 'getNode').and.callFake(() => Promise.resolve(new NodeEntry({entry: {}})));
|
||||
spyOn(component.nodesApi, 'getNode').and.callFake(() => Promise.resolve(new NodeEntry({ entry: new Node() })));
|
||||
|
||||
component.nodeId = '37f7f34d-4e64-4db6-bb3f-5c89f7844251';
|
||||
component.ngOnChanges();
|
||||
@@ -223,20 +207,17 @@ describe('AlfrescoViewerComponent', () => {
|
||||
expect(renditionService.generateMediaTracksRendition).not.toHaveBeenCalled();
|
||||
expect(element.querySelector('[data-automation-id="custom.component"]')).not.toBeNull();
|
||||
}));
|
||||
|
||||
|
||||
});
|
||||
|
||||
describe('MimeType handling', () => {
|
||||
|
||||
it('should node without content show unkonwn', (done) => {
|
||||
const displayName = 'the-name';
|
||||
const contentUrl = '/content/url/path';
|
||||
|
||||
component.nodeId = '12';
|
||||
spyOn(component['nodesApi'], 'getNode').and.returnValue(Promise.resolve(new NodeEntry({
|
||||
entry: {content: {name: displayName, id: '12'}}
|
||||
})));
|
||||
spyOn(component['nodesApi'], 'getNode').and.returnValue(
|
||||
Promise.resolve(new NodeEntry({ entry: new Node({ name: displayName, id: '12', content: new ContentInfo() }) }))
|
||||
);
|
||||
|
||||
spyOn(component['contentApi'], 'getContentUrl').and.returnValue(contentUrl);
|
||||
|
||||
@@ -251,8 +232,8 @@ describe('AlfrescoViewerComponent', () => {
|
||||
|
||||
it('should change display name every time node changes', fakeAsync(() => {
|
||||
spyOn(component['nodesApi'], 'getNode').and.returnValues(
|
||||
Promise.resolve(new NodeEntry({entry: {name: 'file1', content: {}}})),
|
||||
Promise.resolve(new NodeEntry({entry: {name: 'file2', content: {}}}))
|
||||
Promise.resolve(new NodeEntry({ entry: new Node({ name: 'file1', content: new ContentInfo() }) })),
|
||||
Promise.resolve(new NodeEntry({ entry: new Node({ name: 'file2', content: new ContentInfo() }) }))
|
||||
);
|
||||
|
||||
component.showViewer = true;
|
||||
@@ -272,13 +253,15 @@ describe('AlfrescoViewerComponent', () => {
|
||||
|
||||
it('should append version of the file to the file content URL', fakeAsync(() => {
|
||||
spyOn(component['nodesApi'], 'getNode').and.returnValue(
|
||||
Promise.resolve(new NodeEntry({
|
||||
entry: {
|
||||
name: 'file1.pdf',
|
||||
content: {},
|
||||
properties: {'cm:versionLabel': '10'}
|
||||
}
|
||||
}))
|
||||
Promise.resolve(
|
||||
new NodeEntry({
|
||||
entry: new Node({
|
||||
name: 'file1.pdf',
|
||||
content: new ContentInfo(),
|
||||
properties: { 'cm:versionLabel': '10' }
|
||||
})
|
||||
})
|
||||
)
|
||||
);
|
||||
spyOn(component['versionsApi'], 'getVersion').and.returnValue(Promise.resolve(undefined));
|
||||
|
||||
@@ -293,14 +276,14 @@ describe('AlfrescoViewerComponent', () => {
|
||||
expect(component.urlFileContent).toContain('/public/alfresco/versions/1/nodes/id1/content?attachment=false&10');
|
||||
}));
|
||||
|
||||
it('should change display name every time node\`s version changes', fakeAsync(() => {
|
||||
it('should change display name every time node`s version changes', fakeAsync(() => {
|
||||
spyOn(component['nodesApi'], 'getNode').and.returnValue(
|
||||
Promise.resolve(new NodeEntry({entry: {name: 'node1', content: {}}}))
|
||||
Promise.resolve(new NodeEntry({ entry: new Node({ name: 'node1', content: new ContentInfo() }) }))
|
||||
);
|
||||
|
||||
spyOn(component['versionsApi'], 'getVersion').and.returnValues(
|
||||
Promise.resolve(new VersionEntry({entry: {name: 'file1', content: {}}})),
|
||||
Promise.resolve(new VersionEntry({entry: {name: 'file2', content: {}}}))
|
||||
Promise.resolve(new VersionEntry({ entry: new Node({ name: 'file1', content: new ContentInfo() }) })),
|
||||
Promise.resolve(new VersionEntry({ entry: new Node({ name: 'file2', content: new ContentInfo() }) }))
|
||||
);
|
||||
|
||||
component.nodeId = 'id1';
|
||||
@@ -321,7 +304,7 @@ describe('AlfrescoViewerComponent', () => {
|
||||
|
||||
it('should update node only if node name changed', fakeAsync(() => {
|
||||
spyOn(component['nodesApi'], 'getNode').and.returnValues(
|
||||
Promise.resolve(new NodeEntry({entry: {name: 'file1', content: {}}}))
|
||||
Promise.resolve(new NodeEntry({ entry: new Node({ name: 'file1', content: new ContentInfo() }) }))
|
||||
);
|
||||
|
||||
component.showViewer = true;
|
||||
@@ -333,15 +316,15 @@ describe('AlfrescoViewerComponent', () => {
|
||||
|
||||
expect(component.fileName).toBe('file1');
|
||||
|
||||
nodesApiService.nodeUpdated.next({id: 'id1', name: 'file2'} as any);
|
||||
nodesApiService.nodeUpdated.next({ id: 'id1', name: 'file2' } as any);
|
||||
fixture.detectChanges();
|
||||
expect(component.fileName).toBe('file2');
|
||||
|
||||
nodesApiService.nodeUpdated.next({id: 'id1', name: 'file3'} as any);
|
||||
nodesApiService.nodeUpdated.next({ id: 'id1', name: 'file3' } as any);
|
||||
fixture.detectChanges();
|
||||
expect(component.fileName).toBe('file3');
|
||||
|
||||
nodesApiService.nodeUpdated.next({id: 'id2', name: 'file4'} as any);
|
||||
nodesApiService.nodeUpdated.next({ id: 'id2', name: 'file4' } as any);
|
||||
fixture.detectChanges();
|
||||
expect(component.fileName).toBe('file3');
|
||||
expect(component.nodeId).toBe('id1');
|
||||
@@ -357,7 +340,6 @@ describe('AlfrescoViewerComponent', () => {
|
||||
});
|
||||
|
||||
describe('Viewer Example Component Rendering', () => {
|
||||
|
||||
it('should use custom toolbar', (done) => {
|
||||
const customFixture = TestBed.createComponent(ViewerWithCustomToolbarComponent);
|
||||
const customElement: HTMLElement = customFixture.nativeElement;
|
||||
@@ -414,7 +396,6 @@ describe('AlfrescoViewerComponent', () => {
|
||||
expect(customElement.querySelector('.adf-viewer-container-more-actions')).toBeDefined();
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('should stop propagation on sidebar keydown event [keydown]', fakeAsync(() => {
|
||||
@@ -447,10 +428,8 @@ describe('AlfrescoViewerComponent', () => {
|
||||
});
|
||||
|
||||
describe('error handling', () => {
|
||||
|
||||
it('should show unknown view when node file not found', (done) => {
|
||||
spyOn(component['nodesApi'], 'getNode')
|
||||
.and.returnValue(Promise.reject({}));
|
||||
spyOn(component['nodesApi'], 'getNode').and.returnValue(Promise.reject(new Error('error')));
|
||||
|
||||
component.nodeId = 'the-node-id-of-the-file-to-preview';
|
||||
component.mimeType = null;
|
||||
@@ -464,8 +443,7 @@ describe('AlfrescoViewerComponent', () => {
|
||||
});
|
||||
|
||||
it('should show unknown view when sharedLink file not found', (done) => {
|
||||
spyOn(component['sharedLinksApi'], 'getSharedLink')
|
||||
.and.returnValue(Promise.reject({}));
|
||||
spyOn(component['sharedLinksApi'], 'getSharedLink').and.returnValue(Promise.reject(new Error('error')));
|
||||
|
||||
component.sharedLinkId = 'the-Shared-Link-id';
|
||||
component.mimeType = null;
|
||||
@@ -477,12 +455,10 @@ describe('AlfrescoViewerComponent', () => {
|
||||
expect(element.querySelector('adf-viewer-unknown-format')).not.toBeNull();
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('should raise an event when the shared link is invalid', fakeAsync(() => {
|
||||
spyOn(component['sharedLinksApi'], 'getSharedLink')
|
||||
.and.returnValue(Promise.reject({}));
|
||||
spyOn(component['sharedLinksApi'], 'getSharedLink').and.returnValue(Promise.reject(new Error('error')));
|
||||
|
||||
component.sharedLinkId = 'the-Shared-Link-id';
|
||||
component.mimeType = null;
|
||||
@@ -494,11 +470,10 @@ describe('AlfrescoViewerComponent', () => {
|
||||
|
||||
component.ngOnChanges();
|
||||
}));
|
||||
//
|
||||
//
|
||||
});
|
||||
|
||||
describe('Toolbar', () => {
|
||||
|
||||
it('should show only next file button', async () => {
|
||||
component.allowNavigate = true;
|
||||
component.canNavigateBefore = false;
|
||||
@@ -658,7 +633,7 @@ describe('AlfrescoViewerComponent', () => {
|
||||
component.nodeId = '12';
|
||||
const displayName = 'the-name';
|
||||
const nodeDetails = {
|
||||
entry: {name: displayName, id: '12', content: {mimeType: 'txt'}}
|
||||
entry: new Node({ name: displayName, id: '12', content: new ContentInfo({ mimeType: 'txt' }) })
|
||||
};
|
||||
|
||||
const contentUrl = '/content/url/path';
|
||||
@@ -687,8 +662,7 @@ describe('AlfrescoViewerComponent', () => {
|
||||
});
|
||||
|
||||
it('should not render close viewer button if it is a shared link', (done) => {
|
||||
spyOn(component['sharedLinksApi'], 'getSharedLink')
|
||||
.and.returnValue(Promise.reject({}));
|
||||
spyOn(component['sharedLinksApi'], 'getSharedLink').and.returnValue(Promise.reject(new Error('error')));
|
||||
|
||||
component.sharedLinkId = 'the-Shared-Link-id';
|
||||
component.mimeType = null;
|
||||
@@ -700,11 +674,9 @@ describe('AlfrescoViewerComponent', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Base component', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
component.mimeType = 'application/pdf';
|
||||
component.nodeId = 'id1';
|
||||
@@ -713,7 +685,6 @@ describe('AlfrescoViewerComponent', () => {
|
||||
});
|
||||
|
||||
describe('SideBar Test', () => {
|
||||
|
||||
it('should NOT display sidebar if is not allowed', (done) => {
|
||||
component.showRightSidebar = true;
|
||||
component.allowRightSidebar = false;
|
||||
@@ -748,7 +719,6 @@ describe('AlfrescoViewerComponent', () => {
|
||||
expect(sidebar).toBeNull();
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('should display sidebar on the left side', (done) => {
|
||||
@@ -765,9 +735,7 @@ describe('AlfrescoViewerComponent', () => {
|
||||
});
|
||||
|
||||
describe('View', () => {
|
||||
|
||||
describe('Overlay mode true', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
component.overlayMode = true;
|
||||
component.fileName = 'fake-test-file.pdf';
|
||||
@@ -843,7 +811,6 @@ describe('AlfrescoViewerComponent', () => {
|
||||
});
|
||||
|
||||
describe('Overlay mode false', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
component.overlayMode = false;
|
||||
fixture.detectChanges();
|
||||
@@ -863,7 +830,6 @@ describe('AlfrescoViewerComponent', () => {
|
||||
});
|
||||
|
||||
describe('Attribute', () => {
|
||||
|
||||
it('should FileNodeId present not thrown any error ', () => {
|
||||
component.showViewer = true;
|
||||
component.nodeId = 'file-node-id';
|
||||
@@ -873,7 +839,6 @@ describe('AlfrescoViewerComponent', () => {
|
||||
}).not.toThrow();
|
||||
});
|
||||
|
||||
|
||||
it('should showViewer default value be true', () => {
|
||||
expect(component.showViewer).toBe(true);
|
||||
});
|
||||
@@ -887,22 +852,18 @@ describe('AlfrescoViewerComponent', () => {
|
||||
});
|
||||
|
||||
describe('Events', () => {
|
||||
|
||||
it('should update version when emitted by image-viewer and user has update permissions', () => {
|
||||
spyOn(uploadService, 'uploadFilesInTheQueue').and.callFake(() => {
|
||||
});
|
||||
spyOn(uploadService, 'uploadFilesInTheQueue').and.callFake(() => {});
|
||||
spyOn(uploadService, 'addToQueue');
|
||||
component.readOnly = false;
|
||||
component.nodeEntry = new NodeEntry({
|
||||
entry: {
|
||||
name: 'fakeImage.png',
|
||||
id: '12',
|
||||
content: {mimeType: 'img/png'}
|
||||
}
|
||||
entry: new Node({ name: 'fakeImage.png', id: '12', content: new ContentInfo({ mimeType: 'img/png' }) })
|
||||
});
|
||||
const data = atob('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==');
|
||||
const fakeBlob = new Blob([data], {type: 'image/png'});
|
||||
const newImageFile: File = new File([fakeBlob], component?.nodeEntry?.entry?.name, {type: component?.nodeEntry?.entry?.content?.mimeType});
|
||||
const fakeBlob = new Blob([data], { type: 'image/png' });
|
||||
const newImageFile: File = new File([fakeBlob], component?.nodeEntry?.entry?.name, {
|
||||
type: component?.nodeEntry?.entry?.content?.mimeType
|
||||
});
|
||||
const newFile = new FileModel(
|
||||
newImageFile,
|
||||
{
|
||||
@@ -921,24 +882,18 @@ describe('AlfrescoViewerComponent', () => {
|
||||
});
|
||||
|
||||
it('should not update version when emitted by image-viewer and user doesn`t have update permissions', () => {
|
||||
spyOn(uploadService, 'uploadFilesInTheQueue').and.callFake(() => {
|
||||
});
|
||||
spyOn(uploadService, 'uploadFilesInTheQueue').and.callFake(() => {});
|
||||
component.readOnly = true;
|
||||
component.nodeEntry = new NodeEntry({
|
||||
entry: {
|
||||
name: 'fakeImage.png',
|
||||
id: '12',
|
||||
content: {mimeType: 'img/png'}
|
||||
}
|
||||
entry: new Node({ name: 'fakeImage.png', id: '12', content: new ContentInfo({ mimeType: 'img/png' }) })
|
||||
});
|
||||
const data = atob('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==');
|
||||
const fakeBlob = new Blob([data], {type: 'image/png'});
|
||||
const fakeBlob = new Blob([data], { type: 'image/png' });
|
||||
component.onSubmitFile(fakeBlob);
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(uploadService.uploadFilesInTheQueue).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user