mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[AAE-4966] Extensible app config (#6914)
* merge app config from the extensions * improved service injection in unit tests * extra unit test * fix content tests * update code as per review * fix lint * fix lint * update code and tests * update schema
This commit is contained in:
@@ -142,16 +142,25 @@ describe('AspectListService', () => {
|
|||||||
describe('should fetch the list of the aspects', () => {
|
describe('should fetch the list of the aspects', () => {
|
||||||
|
|
||||||
let service: AspectListService;
|
let service: AspectListService;
|
||||||
const appConfigService: AppConfigService = new AppConfigService(null);
|
let appConfigService: AppConfigService;
|
||||||
|
let apiService: AlfrescoApiService;
|
||||||
const aspectTypesApi = jasmine.createSpyObj('AspectsApi', ['listAspects']);
|
let logService: LogService;
|
||||||
const apiService: AlfrescoApiService = new AlfrescoApiService(null, null);
|
let aspectTypesApi: any;
|
||||||
const logService: LogService = new LogService(appConfigService);
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [ContentTestingModule]
|
||||||
|
});
|
||||||
|
|
||||||
|
aspectTypesApi = jasmine.createSpyObj('AspectsApi', ['listAspects']);
|
||||||
|
appConfigService = TestBed.inject(AppConfigService);
|
||||||
|
apiService = TestBed.inject(AlfrescoApiService);
|
||||||
|
logService = TestBed.inject(LogService);
|
||||||
|
|
||||||
spyOn(appConfigService, 'get').and.returnValue({ 'default': ['frs:AspectOne'] });
|
spyOn(appConfigService, 'get').and.returnValue({ 'default': ['frs:AspectOne'] });
|
||||||
spyOnProperty(apiService, 'aspectsApi').and.returnValue(aspectTypesApi);
|
spyOnProperty(apiService, 'aspectsApi').and.returnValue(aspectTypesApi);
|
||||||
service = new AspectListService(apiService, appConfigService, null, logService);
|
|
||||||
|
service = TestBed.inject(AspectListService);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get the list of only available aspects', async(() => {
|
it('should get the list of only available aspects', async(() => {
|
||||||
|
|||||||
+7
-4
@@ -16,16 +16,19 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { CustomResourcesService } from './custom-resources.service';
|
import { CustomResourcesService } from './custom-resources.service';
|
||||||
import { PaginationModel, AlfrescoApiServiceMock, AppConfigService, LogService, AppConfigServiceMock, StorageService } from '@alfresco/adf-core';
|
import { PaginationModel } from '@alfresco/adf-core';
|
||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
import { ContentTestingModule } from '../../testing/content.testing.module';
|
||||||
|
|
||||||
describe('CustomResourcesService', () => {
|
describe('CustomResourcesService', () => {
|
||||||
let customResourcesService: CustomResourcesService;
|
let customResourcesService: CustomResourcesService;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
const logService = new LogService(new AppConfigServiceMock(null));
|
TestBed.configureTestingModule({
|
||||||
const alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
|
imports: [ContentTestingModule]
|
||||||
|
});
|
||||||
|
|
||||||
customResourcesService = new CustomResourcesService(alfrescoApiService, logService);
|
customResourcesService = TestBed.inject(CustomResourcesService);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('loadFavorites', () => {
|
describe('loadFavorites', () => {
|
||||||
|
|||||||
+3
-14
@@ -15,9 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { AlfrescoApiServiceMock, AppConfigService, ContentService,
|
import { setupTestBed } from '@alfresco/adf-core';
|
||||||
setupTestBed, TranslationMock, AlfrescoApiService, StorageService
|
|
||||||
} from '@alfresco/adf-core';
|
|
||||||
import { FileNode, FolderNode } from '../../mock';
|
import { FileNode, FolderNode } from '../../mock';
|
||||||
import { ContentActionHandler } from '../models/content-action.model';
|
import { ContentActionHandler } from '../models/content-action.model';
|
||||||
import { DocumentActionsService } from './document-actions.service';
|
import { DocumentActionsService } from './document-actions.service';
|
||||||
@@ -36,21 +34,12 @@ describe('DocumentActionsService', () => {
|
|||||||
imports: [
|
imports: [
|
||||||
TranslateModule.forRoot(),
|
TranslateModule.forRoot(),
|
||||||
ContentTestingModule
|
ContentTestingModule
|
||||||
],
|
|
||||||
providers: [
|
|
||||||
{
|
|
||||||
provide: AlfrescoApiService,
|
|
||||||
useValue: new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService())
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
const alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
|
documentListService = TestBed.inject(DocumentListService);
|
||||||
const contentService = TestBed.inject(ContentService);
|
service = TestBed.inject(DocumentActionsService);
|
||||||
|
|
||||||
documentListService = new DocumentListService(contentService, alfrescoApiService, null, null);
|
|
||||||
service = new DocumentActionsService(null, null, new TranslationMock(), documentListService, contentService);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should register default download action', () => {
|
it('should register default download action', () => {
|
||||||
|
|||||||
@@ -15,10 +15,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { AlfrescoApiServiceMock, AlfrescoApiService,
|
import { AlfrescoApiService, setupTestBed } from '@alfresco/adf-core';
|
||||||
AppConfigService, ContentService, setupTestBed, LogService, AppConfigServiceMock, StorageService } from '@alfresco/adf-core';
|
|
||||||
import { DocumentListService } from './document-list.service';
|
import { DocumentListService } from './document-list.service';
|
||||||
import { CustomResourcesService } from './custom-resources.service';
|
|
||||||
import { TestBed } from '@angular/core/testing';
|
import { TestBed } from '@angular/core/testing';
|
||||||
import { ContentTestingModule } from '../../testing/content.testing.module';
|
import { ContentTestingModule } from '../../testing/content.testing.module';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
@@ -72,11 +70,8 @@ describe('DocumentListService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
const logService = new LogService(new AppConfigServiceMock(null));
|
alfrescoApiService = TestBed.inject(AlfrescoApiService);
|
||||||
const contentService = TestBed.inject(ContentService);
|
service = TestBed.inject(DocumentListService);
|
||||||
alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
|
|
||||||
const customActionService = new CustomResourcesService(alfrescoApiService, logService);
|
|
||||||
service = new DocumentListService(contentService, alfrescoApiService, logService, customActionService);
|
|
||||||
jasmine.Ajax.install();
|
jasmine.Ajax.install();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { TestBed } from '@angular/core/testing';
|
import { TestBed } from '@angular/core/testing';
|
||||||
import { AlfrescoApiServiceMock, AppConfigService, ContentService, setupTestBed, TranslationMock, StorageService } from '@alfresco/adf-core';
|
import { AppConfigService, setupTestBed } from '@alfresco/adf-core';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { FileNode, FolderNode } from '../../mock';
|
import { FileNode, FolderNode } from '../../mock';
|
||||||
import { ContentActionHandler } from '../models/content-action.model';
|
import { ContentActionHandler } from '../models/content-action.model';
|
||||||
@@ -41,10 +41,8 @@ describe('FolderActionsService', () => {
|
|||||||
const appConfig: AppConfigService = TestBed.inject(AppConfigService);
|
const appConfig: AppConfigService = TestBed.inject(AppConfigService);
|
||||||
appConfig.config.ecmHost = 'http://localhost:9876/ecm';
|
appConfig.config.ecmHost = 'http://localhost:9876/ecm';
|
||||||
|
|
||||||
const contentService = TestBed.inject(ContentService);
|
documentListService = TestBed.inject(DocumentListService);
|
||||||
const alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
|
service = TestBed.inject(FolderActionsService);
|
||||||
documentListService = new DocumentListService(contentService, alfrescoApiService, null, null);
|
|
||||||
service = new FolderActionsService(null, documentListService, contentService, new TranslationMock());
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should register custom action handler', () => {
|
it('should register custom action handler', () => {
|
||||||
|
|||||||
+7
-1
@@ -19,6 +19,8 @@ import { SearchSortingPickerComponent } from './search-sorting-picker.component'
|
|||||||
import { SearchQueryBuilderService } from '../../search-query-builder.service';
|
import { SearchQueryBuilderService } from '../../search-query-builder.service';
|
||||||
import { AppConfigService } from '@alfresco/adf-core';
|
import { AppConfigService } from '@alfresco/adf-core';
|
||||||
import { SearchConfiguration } from '../../search-configuration.interface';
|
import { SearchConfiguration } from '../../search-configuration.interface';
|
||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
import { ContentTestingModule } from '../../../testing/content.testing.module';
|
||||||
|
|
||||||
describe('SearchSortingPickerComponent', () => {
|
describe('SearchSortingPickerComponent', () => {
|
||||||
|
|
||||||
@@ -26,12 +28,16 @@ describe('SearchSortingPickerComponent', () => {
|
|||||||
let component: SearchSortingPickerComponent;
|
let component: SearchSortingPickerComponent;
|
||||||
|
|
||||||
const buildConfig = (searchSettings): AppConfigService => {
|
const buildConfig = (searchSettings): AppConfigService => {
|
||||||
const config = new AppConfigService(null);
|
const config = TestBed.inject(AppConfigService);
|
||||||
config.config.search = searchSettings;
|
config.config.search = searchSettings;
|
||||||
return config;
|
return config;
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [ContentTestingModule]
|
||||||
|
});
|
||||||
|
|
||||||
const config: SearchConfiguration = {
|
const config: SearchConfiguration = {
|
||||||
sorting: {
|
sorting: {
|
||||||
options: [
|
options: [
|
||||||
|
|||||||
@@ -18,11 +18,19 @@
|
|||||||
import { SearchConfiguration } from './search-configuration.interface';
|
import { SearchConfiguration } from './search-configuration.interface';
|
||||||
import { AppConfigService } from '@alfresco/adf-core';
|
import { AppConfigService } from '@alfresco/adf-core';
|
||||||
import { SearchHeaderQueryBuilderService } from './search-header-query-builder.service';
|
import { SearchHeaderQueryBuilderService } from './search-header-query-builder.service';
|
||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||||
|
|
||||||
describe('SearchHeaderQueryBuilderService', () => {
|
describe('SearchHeaderQueryBuilderService', () => {
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [ContentTestingModule]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
const buildConfig = (searchSettings): AppConfigService => {
|
const buildConfig = (searchSettings): AppConfigService => {
|
||||||
const config = new AppConfigService(null);
|
const config = TestBed.inject(AppConfigService);
|
||||||
config.config['search-headers'] = searchSettings;
|
config.config['search-headers'] = searchSettings;
|
||||||
return config;
|
return config;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -19,11 +19,19 @@ import { SearchQueryBuilderService } from './search-query-builder.service';
|
|||||||
import { SearchConfiguration } from './search-configuration.interface';
|
import { SearchConfiguration } from './search-configuration.interface';
|
||||||
import { AppConfigService } from '@alfresco/adf-core';
|
import { AppConfigService } from '@alfresco/adf-core';
|
||||||
import { FacetField } from './facet-field.interface';
|
import { FacetField } from './facet-field.interface';
|
||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||||
|
|
||||||
describe('SearchQueryBuilder', () => {
|
describe('SearchQueryBuilder', () => {
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [ContentTestingModule]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
const buildConfig = (searchSettings): AppConfigService => {
|
const buildConfig = (searchSettings): AppConfigService => {
|
||||||
const config = new AppConfigService(null);
|
const config = TestBed.inject(AppConfigService);
|
||||||
config.config.search = searchSettings;
|
config.config.search = searchSettings;
|
||||||
return config;
|
return config;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,16 +15,25 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { HttpClientModule } from '@angular/common/http';
|
import { HttpClient, HttpClientModule } from '@angular/common/http';
|
||||||
import { async, inject, TestBed } from '@angular/core/testing';
|
import { async, TestBed } from '@angular/core/testing';
|
||||||
import { AppConfigService } from './app-config.service';
|
import { AppConfigService } from './app-config.service';
|
||||||
import { AppConfigModule } from './app-config.module';
|
import { AppConfigModule } from './app-config.module';
|
||||||
|
import { ExtensionConfig, ExtensionService } from '@alfresco/adf-extensions';
|
||||||
|
import { of } from 'rxjs';
|
||||||
|
|
||||||
declare let jasmine: any;
|
class TestExtensionService extends ExtensionService {
|
||||||
|
|
||||||
|
onSetup(config: ExtensionConfig) {
|
||||||
|
this.onSetup$.next(config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
describe('AppConfigService', () => {
|
describe('AppConfigService', () => {
|
||||||
|
|
||||||
let appConfigService: AppConfigService;
|
let appConfigService: AppConfigService;
|
||||||
|
let extensionService: ExtensionService;
|
||||||
|
let httpClient: HttpClient;
|
||||||
|
|
||||||
const mockResponse = {
|
const mockResponse = {
|
||||||
ecmHost: 'http://localhost:4000/ecm',
|
ecmHost: 'http://localhost:4000/ecm',
|
||||||
@@ -46,32 +55,60 @@ describe('AppConfigService', () => {
|
|||||||
AppConfigModule
|
AppConfigModule
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: AppConfigService, useClass: AppConfigService }
|
{ provide: ExtensionService, useClass: TestExtensionService }
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
jasmine.Ajax.install();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(
|
beforeEach(() => {
|
||||||
inject([AppConfigService], (appConfig: AppConfigService) => {
|
httpClient = TestBed.inject(HttpClient);
|
||||||
appConfigService = appConfig;
|
spyOn(httpClient, 'get').and.returnValue(of(mockResponse));
|
||||||
appConfigService.load();
|
|
||||||
|
|
||||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
extensionService = TestBed.inject(ExtensionService);
|
||||||
'status': 200,
|
|
||||||
contentType: 'application/json',
|
|
||||||
responseText: JSON.stringify(mockResponse)
|
|
||||||
});
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
afterEach(() => {
|
appConfigService = TestBed.inject(AppConfigService);
|
||||||
jasmine.Ajax.uninstall();
|
appConfigService.load();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export service in the module', () => {
|
it('should merge the configs from extensions', () => {
|
||||||
expect(appConfigService).toBeDefined();
|
appConfigService.config = {
|
||||||
|
application: {
|
||||||
|
name: 'application name'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
(extensionService as TestExtensionService).onSetup({
|
||||||
|
appConfig: {
|
||||||
|
application: {
|
||||||
|
name: 'custom name'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} as any);
|
||||||
|
|
||||||
|
expect(appConfigService.get('application.name')).toEqual('custom name');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should merge the configs upon new data loaded', async (done) => {
|
||||||
|
appConfigService.config = {
|
||||||
|
application: {
|
||||||
|
name: 'application name'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
(extensionService as TestExtensionService).onSetup({
|
||||||
|
appConfig: {
|
||||||
|
application: {
|
||||||
|
name: 'custom name'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} as any);
|
||||||
|
|
||||||
|
expect(appConfigService.get('application.name')).toEqual('custom name');
|
||||||
|
|
||||||
|
await appConfigService.load();
|
||||||
|
|
||||||
|
expect(appConfigService.get('application.name')).toEqual('custom name');
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should stream only the selected attribute changes when using select', async(() => {
|
it('should stream only the selected attribute changes when using select', async(() => {
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ import { HttpClient } from '@angular/common/http';
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { ObjectUtils } from '../utils/object-utils';
|
import { ObjectUtils } from '../utils/object-utils';
|
||||||
import { Observable, Subject } from 'rxjs';
|
import { Observable, Subject } from 'rxjs';
|
||||||
import { map, distinctUntilChanged } from 'rxjs/operators';
|
import { map, distinctUntilChanged, take } from 'rxjs/operators';
|
||||||
|
import { ExtensionConfig, ExtensionService, mergeObjects } from '@alfresco/adf-extensions';
|
||||||
|
|
||||||
/* spellchecker: disable */
|
/* spellchecker: disable */
|
||||||
export enum AppConfigValues {
|
export enum AppConfigValues {
|
||||||
@@ -69,9 +70,13 @@ export class AppConfigService {
|
|||||||
protected onLoadSubject: Subject<any>;
|
protected onLoadSubject: Subject<any>;
|
||||||
onLoad: Observable<any>;
|
onLoad: Observable<any>;
|
||||||
|
|
||||||
constructor(private http: HttpClient) {
|
constructor(protected http: HttpClient, protected extensionService: ExtensionService) {
|
||||||
this.onLoadSubject = new Subject();
|
this.onLoadSubject = new Subject();
|
||||||
this.onLoad = this.onLoadSubject.asObservable();
|
this.onLoad = this.onLoadSubject.asObservable();
|
||||||
|
|
||||||
|
extensionService.setup$.subscribe((config) => {
|
||||||
|
this.onExtensionsLoaded(config);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -142,6 +147,29 @@ export class AppConfigService {
|
|||||||
return location.port ? prefix + location.port : '';
|
return location.port ? prefix + location.port : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected onLoaded() {
|
||||||
|
this.onLoadSubject.next(this.config);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected onDataLoaded(data: any) {
|
||||||
|
this.config = Object.assign({}, this.config, data || {});
|
||||||
|
this.onLoadSubject.next(this.config);
|
||||||
|
|
||||||
|
this.extensionService.setup$
|
||||||
|
.pipe(take(1))
|
||||||
|
.subscribe((config) => this.onExtensionsLoaded(config));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected onExtensionsLoaded(config: ExtensionConfig) {
|
||||||
|
if (config) {
|
||||||
|
const customConfig = config.appConfig;
|
||||||
|
|
||||||
|
if (customConfig) {
|
||||||
|
this.config = mergeObjects(this.config, customConfig);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the config file.
|
* Loads the config file.
|
||||||
* @returns Notification when loading is complete
|
* @returns Notification when loading is complete
|
||||||
@@ -152,11 +180,10 @@ export class AppConfigService {
|
|||||||
|
|
||||||
if (this.status === Status.INIT) {
|
if (this.status === Status.INIT) {
|
||||||
this.status = Status.LOADING;
|
this.status = Status.LOADING;
|
||||||
await this.http.get(configUrl).subscribe(
|
this.http.get(configUrl).subscribe(
|
||||||
(data: any) => {
|
(data: any) => {
|
||||||
this.status = Status.LOADED;
|
this.status = Status.LOADED;
|
||||||
this.config = Object.assign({}, this.config, data || {});
|
this.onDataLoaded(data);
|
||||||
this.onLoadSubject.next(this.config);
|
|
||||||
resolve(this.config);
|
resolve(this.config);
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
|
|||||||
@@ -19,11 +19,12 @@ import { Injectable } from '@angular/core';
|
|||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { StorageService } from '../services/storage.service';
|
import { StorageService } from '../services/storage.service';
|
||||||
import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
|
import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
|
||||||
|
import { ExtensionService } from '@alfresco/adf-extensions';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class DebugAppConfigService extends AppConfigService {
|
export class DebugAppConfigService extends AppConfigService {
|
||||||
constructor(private storage: StorageService, http: HttpClient) {
|
constructor(private storage: StorageService, http: HttpClient, extensionService: ExtensionService) {
|
||||||
super(http);
|
super(http, extensionService);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @override */
|
/** @override */
|
||||||
|
|||||||
@@ -17,25 +17,39 @@
|
|||||||
|
|
||||||
import { DateCellComponent } from '../date-cell/date-cell.component';
|
import { DateCellComponent } from '../date-cell/date-cell.component';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { AlfrescoApiServiceMock, AppConfigService, StorageService } from '@alfresco/adf-core';
|
import { AppConfigService } from '@alfresco/adf-core';
|
||||||
import { Node } from '@alfresco/js-api';
|
import { Node } from '@alfresco/js-api';
|
||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
import { CoreTestingModule } from '../../../testing';
|
||||||
|
import { AlfrescoApiService } from '../../../services/alfresco-api.service';
|
||||||
|
import { CoreModule } from '../../../core.module';
|
||||||
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
|
||||||
describe('DataTableCellComponent', () => {
|
describe('DataTableCellComponent', () => {
|
||||||
let alfrescoApiService: AlfrescoApiServiceMock;
|
let alfrescoApiService: AlfrescoApiService;
|
||||||
|
let appConfigService: AppConfigService;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
|
TestBed.configureTestingModule({
|
||||||
|
imports: [
|
||||||
|
CoreModule.forRoot(),
|
||||||
|
TranslateModule.forRoot(),
|
||||||
|
CoreTestingModule
|
||||||
|
]
|
||||||
|
});
|
||||||
|
alfrescoApiService = TestBed.inject(AlfrescoApiService);
|
||||||
|
appConfigService = TestBed.inject(AppConfigService);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should use medium format by default', () => {
|
it('should use medium format by default', () => {
|
||||||
const component = new DateCellComponent(null, null, new AppConfigService(null));
|
const component = new DateCellComponent(null, null, appConfigService);
|
||||||
expect(component.format).toBe('medium');
|
expect(component.format).toBe('medium');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should use column format', () => {
|
it('should use column format', () => {
|
||||||
const component = new DateCellComponent(null, <any> {
|
const component = new DateCellComponent(null, <any> {
|
||||||
nodeUpdated: new Subject<any>()
|
nodeUpdated: new Subject<any>()
|
||||||
}, new AppConfigService(null));
|
}, appConfigService);
|
||||||
component.column = {
|
component.column = {
|
||||||
key: 'created',
|
key: 'created',
|
||||||
type: 'date',
|
type: 'date',
|
||||||
@@ -50,7 +64,7 @@ describe('DataTableCellComponent', () => {
|
|||||||
const component = new DateCellComponent(
|
const component = new DateCellComponent(
|
||||||
null,
|
null,
|
||||||
alfrescoApiService,
|
alfrescoApiService,
|
||||||
new AppConfigService(null)
|
appConfigService
|
||||||
);
|
);
|
||||||
|
|
||||||
component.column = {
|
component.column = {
|
||||||
@@ -85,7 +99,7 @@ describe('DataTableCellComponent', () => {
|
|||||||
const component = new DateCellComponent(
|
const component = new DateCellComponent(
|
||||||
null,
|
null,
|
||||||
alfrescoApiService,
|
alfrescoApiService,
|
||||||
new AppConfigService(null)
|
appConfigService
|
||||||
);
|
);
|
||||||
|
|
||||||
component.column = {
|
component.column = {
|
||||||
@@ -120,7 +134,7 @@ describe('DataTableCellComponent', () => {
|
|||||||
const component = new DateCellComponent(
|
const component = new DateCellComponent(
|
||||||
null,
|
null,
|
||||||
alfrescoApiService,
|
alfrescoApiService,
|
||||||
new AppConfigService(null)
|
appConfigService
|
||||||
);
|
);
|
||||||
|
|
||||||
component.column = {
|
component.column = {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import { of, throwError, Subject } from 'rxjs';
|
|||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { DirectiveModule } from './directive.module';
|
import { DirectiveModule } from './directive.module';
|
||||||
import { CoreModule } from '../core.module';
|
import { CoreModule } from '../core.module';
|
||||||
import { AlfrescoApiServiceMock } from '../mock/alfresco-api.service.mock';
|
import { CoreTestingModule } from '../testing/core.testing.module';
|
||||||
|
|
||||||
describe('LibraryMembershipDirective', () => {
|
describe('LibraryMembershipDirective', () => {
|
||||||
let alfrescoApiService: AlfrescoApiService;
|
let alfrescoApiService: AlfrescoApiService;
|
||||||
@@ -40,9 +40,11 @@ describe('LibraryMembershipDirective', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [TranslateModule.forRoot(), DirectiveModule, CoreModule.forRoot()],
|
imports: [
|
||||||
providers: [
|
TranslateModule.forRoot(),
|
||||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }
|
DirectiveModule,
|
||||||
|
CoreModule.forRoot(),
|
||||||
|
CoreTestingModule
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -16,19 +16,17 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { SimpleChange } from '@angular/core';
|
import { SimpleChange } from '@angular/core';
|
||||||
import { fakeAsync, tick } from '@angular/core/testing';
|
import { fakeAsync, TestBed, tick } from '@angular/core/testing';
|
||||||
import { NodeFavoriteDirective } from './node-favorite.directive';
|
import { NodeFavoriteDirective } from './node-favorite.directive';
|
||||||
import { AlfrescoApiServiceMock } from '../mock/alfresco-api.service.mock';
|
|
||||||
import { AppConfigService } from '../app-config/app-config.service';
|
|
||||||
import { setupTestBed } from '../testing/setup-test-bed';
|
import { setupTestBed } from '../testing/setup-test-bed';
|
||||||
import { CoreTestingModule } from '../testing/core.testing.module';
|
import { CoreTestingModule } from '../testing/core.testing.module';
|
||||||
import { StorageService } from '../services/storage.service';
|
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { AlfrescoApiService } from '../services/alfresco-api.service';
|
||||||
|
|
||||||
describe('NodeFavoriteDirective', () => {
|
describe('NodeFavoriteDirective', () => {
|
||||||
|
|
||||||
let directive;
|
let directive: NodeFavoriteDirective;
|
||||||
let alfrescoApiService;
|
let alfrescoApiService: AlfrescoApiService;
|
||||||
|
|
||||||
setupTestBed({
|
setupTestBed({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -38,7 +36,7 @@ describe('NodeFavoriteDirective', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
|
alfrescoApiService = TestBed.inject(AlfrescoApiService);
|
||||||
directive = new NodeFavoriteDirective( alfrescoApiService);
|
directive = new NodeFavoriteDirective( alfrescoApiService);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ export class AlfrescoApiServiceMock extends AlfrescoApiService {
|
|||||||
initialize(): Promise<any> {
|
initialize(): Promise<any> {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
this.alfrescoApiInitialized.next(true);
|
this.alfrescoApiInitialized.next(true);
|
||||||
resolve();
|
resolve({});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,8 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { AppConfigService } from '../app-config/app-config.service';
|
import { AppConfigService, Status } from '../app-config/app-config.service';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
import { ExtensionService } from '@alfresco/adf-extensions';
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AppConfigServiceMock extends AppConfigService {
|
export class AppConfigServiceMock extends AppConfigService {
|
||||||
|
|
||||||
@@ -30,13 +31,14 @@ export class AppConfigServiceMock extends AppConfigService {
|
|||||||
logLevel: 'silent'
|
logLevel: 'silent'
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(http: HttpClient) {
|
constructor(http: HttpClient, extensionService: ExtensionService) {
|
||||||
super(http);
|
super(http, extensionService);
|
||||||
}
|
}
|
||||||
|
|
||||||
load(): Promise<any> {
|
load(): Promise<any> {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
this.onLoadSubject.next(this.config);
|
this.status = Status.LOADED;
|
||||||
|
this.onDataLoaded(this.config);
|
||||||
resolve(this.config);
|
resolve(this.config);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,5 +59,8 @@ export let searchMockApi = {
|
|||||||
queriesApi: {
|
queriesApi: {
|
||||||
findNodes: () => Promise.resolve(fakeSearch)
|
findNodes: () => Promise.resolve(fakeSearch)
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
isEcmLoggedIn() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ describe('DecimalNumberPipe', () => {
|
|||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
userPreferences = TestBed.inject(UserPreferencesService);
|
userPreferences = TestBed.inject(UserPreferencesService);
|
||||||
spyOn(userPreferences, 'select').and.returnValue(of(''));
|
spyOn(userPreferences, 'select').and.returnValue(of(''));
|
||||||
pipe = new DecimalNumberPipe(userPreferences, new AppConfigService(null));
|
pipe = new DecimalNumberPipe(userPreferences, TestBed.inject(AppConfigService));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should return number localized and rounded following the default config', () => {
|
it('should return number localized and rounded following the default config', () => {
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ describe('LocalizedDatePipe', () => {
|
|||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
userPreferences = TestBed.inject(UserPreferencesService);
|
userPreferences = TestBed.inject(UserPreferencesService);
|
||||||
spyOn(userPreferences, 'select').and.returnValue(of(''));
|
spyOn(userPreferences, 'select').and.returnValue(of(''));
|
||||||
pipe = new LocalizedDatePipe(userPreferences, new AppConfigService(null));
|
pipe = new LocalizedDatePipe(userPreferences, TestBed.inject(AppConfigService));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should return time with locale en-US', () => {
|
it('should return time with locale en-US', () => {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ describe('TimeAgoPipe', () => {
|
|||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
userPreferences = TestBed.inject(UserPreferencesService);
|
userPreferences = TestBed.inject(UserPreferencesService);
|
||||||
spyOn(userPreferences, 'select').and.returnValue(of(''));
|
spyOn(userPreferences, 'select').and.returnValue(of(''));
|
||||||
pipe = new TimeAgoPipe(userPreferences, new AppConfigService(null));
|
pipe = new TimeAgoPipe(userPreferences, TestBed.inject(AppConfigService));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should return time difference for a given date', () => {
|
it('should return time difference for a given date', () => {
|
||||||
|
|||||||
@@ -45,6 +45,9 @@ describe('NodesApiService', () => {
|
|||||||
getNodeChildren: jasmine.createSpy('getNodeChildren'),
|
getNodeChildren: jasmine.createSpy('getNodeChildren'),
|
||||||
addNode: jasmine.createSpy('addNode')
|
addNode: jasmine.createSpy('addNode')
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
isEcmLoggedIn() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ import { UserPreferencesService, UserPreferenceValues } from './user-preferences
|
|||||||
import { setupTestBed } from '../testing/setup-test-bed';
|
import { setupTestBed } from '../testing/setup-test-bed';
|
||||||
import { CoreTestingModule } from '../testing/core.testing.module';
|
import { CoreTestingModule } from '../testing/core.testing.module';
|
||||||
import { AppConfigServiceMock } from '../mock/app-config.service.mock';
|
import { AppConfigServiceMock } from '../mock/app-config.service.mock';
|
||||||
import { AlfrescoApiServiceMock } from '../mock/alfresco-api.service.mock';
|
import { AlfrescoApiService } from './alfresco-api.service';
|
||||||
|
import { AlfrescoApiServiceMock } from '../mock';
|
||||||
|
|
||||||
describe('UserPreferencesService', () => {
|
describe('UserPreferencesService', () => {
|
||||||
|
|
||||||
@@ -53,7 +54,7 @@ describe('UserPreferencesService', () => {
|
|||||||
|
|
||||||
storage = TestBed.inject(StorageService);
|
storage = TestBed.inject(StorageService);
|
||||||
translate = TestBed.inject(TranslateService);
|
translate = TestBed.inject(TranslateService);
|
||||||
alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
|
alfrescoApiService = TestBed.inject(AlfrescoApiService) as AlfrescoApiServiceMock;
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@@ -71,7 +72,7 @@ describe('UserPreferencesService', () => {
|
|||||||
describe(' with pagination config', () => {
|
describe(' with pagination config', () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
preferences = new UserPreferencesService(translate, appConfig, storage, alfrescoApiService);
|
preferences = TestBed.inject(UserPreferencesService);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get default pagination from app config', (done) => {
|
it('should get default pagination from app config', (done) => {
|
||||||
@@ -183,7 +184,6 @@ describe('UserPreferencesService', () => {
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
appConfig.config.locale = 'fake-locale-config';
|
appConfig.config.locale = 'fake-locale-config';
|
||||||
preferences = new UserPreferencesService(translate, appConfig, storage, alfrescoApiService);
|
|
||||||
alfrescoApiService.initialize();
|
alfrescoApiService.initialize();
|
||||||
const textOrientation = preferences.getPropertyKey('textOrientation');
|
const textOrientation = preferences.getPropertyKey('textOrientation');
|
||||||
expect(storage.getItem(textOrientation)).toBe('ltr');
|
expect(storage.getItem(textOrientation)).toBe('ltr');
|
||||||
@@ -197,7 +197,6 @@ describe('UserPreferencesService', () => {
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
appConfig.config.locale = 'fake-locale-config';
|
appConfig.config.locale = 'fake-locale-config';
|
||||||
preferences = new UserPreferencesService(translate, appConfig, storage, alfrescoApiService);
|
|
||||||
alfrescoApiService.initialize();
|
alfrescoApiService.initialize();
|
||||||
const textOrientation = preferences.getPropertyKey('textOrientation');
|
const textOrientation = preferences.getPropertyKey('textOrientation');
|
||||||
expect(storage.getItem(textOrientation)).toBe('rtl');
|
expect(storage.getItem(textOrientation)).toBe('rtl');
|
||||||
@@ -209,7 +208,6 @@ describe('UserPreferencesService', () => {
|
|||||||
key: 'fake-locale-browser'
|
key: 'fake-locale-browser'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
preferences = new UserPreferencesService(translate, appConfig, storage, alfrescoApiService);
|
|
||||||
alfrescoApiService.initialize();
|
alfrescoApiService.initialize();
|
||||||
|
|
||||||
const textOrientation = preferences.getPropertyKey('textOrientation');
|
const textOrientation = preferences.getPropertyKey('textOrientation');
|
||||||
@@ -224,7 +222,6 @@ describe('UserPreferencesService', () => {
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
spyOn(translate, 'getBrowserCultureLang').and.returnValue('fake-locale-browser');
|
spyOn(translate, 'getBrowserCultureLang').and.returnValue('fake-locale-browser');
|
||||||
preferences = new UserPreferencesService(translate, appConfig, storage, alfrescoApiService);
|
|
||||||
alfrescoApiService.initialize();
|
alfrescoApiService.initialize();
|
||||||
|
|
||||||
changeDisposable = preferences.onChange
|
changeDisposable = preferences.onChange
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ import { VersionCompatibilityService } from '../services/version-compatibility.s
|
|||||||
NoopAnimationsModule,
|
NoopAnimationsModule,
|
||||||
RouterTestingModule,
|
RouterTestingModule,
|
||||||
HttpClientModule,
|
HttpClientModule,
|
||||||
TranslateModule,
|
TranslateModule.forRoot(),
|
||||||
CoreModule
|
CoreModule.forRoot()
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
DatePipe,
|
DatePipe,
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import { MediaPlayerComponent } from './media-player.component';
|
|||||||
import { setupTestBed } from '../../testing/setup-test-bed';
|
import { setupTestBed } from '../../testing/setup-test-bed';
|
||||||
import { CoreTestingModule } from '../../testing/core.testing.module';
|
import { CoreTestingModule } from '../../testing/core.testing.module';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { AlfrescoApiServiceMock } from '../../mock/alfresco-api.service.mock';
|
|
||||||
import { AlfrescoApiService } from '../../services';
|
import { AlfrescoApiService } from '../../services';
|
||||||
import { NodeEntry } from '@alfresco/js-api';
|
import { NodeEntry } from '@alfresco/js-api';
|
||||||
|
|
||||||
@@ -36,9 +35,6 @@ describe('Test Media player component ', () => {
|
|||||||
imports: [
|
imports: [
|
||||||
TranslateModule.forRoot(),
|
TranslateModule.forRoot(),
|
||||||
CoreTestingModule
|
CoreTestingModule
|
||||||
],
|
|
||||||
providers: [
|
|
||||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }
|
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import { EventMock } from '../../mock/event.mock';
|
|||||||
import { RenderingQueueServices } from '../services/rendering-queue.services';
|
import { RenderingQueueServices } from '../services/rendering-queue.services';
|
||||||
import { ViewerComponent } from './viewer.component';
|
import { ViewerComponent } from './viewer.component';
|
||||||
import { setupTestBed } from '../../testing/setup-test-bed';
|
import { setupTestBed } from '../../testing/setup-test-bed';
|
||||||
import { AlfrescoApiServiceMock } from '../../mock/alfresco-api.service.mock';
|
|
||||||
import { NodeEntry, VersionEntry } from '@alfresco/js-api';
|
import { NodeEntry, VersionEntry } from '@alfresco/js-api';
|
||||||
import { CoreTestingModule } from '../../testing/core.testing.module';
|
import { CoreTestingModule } from '../../testing/core.testing.module';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
@@ -151,7 +150,6 @@ describe('ViewerComponent', () => {
|
|||||||
ViewerWithCustomToolbarActionsComponent
|
ViewerWithCustomToolbarActionsComponent
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
|
|
||||||
{
|
{
|
||||||
provide: RenditionsService, useValue: {
|
provide: RenditionsService, useValue: {
|
||||||
getRendition: () => {
|
getRendition: () => {
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ export interface ExtensionRef {
|
|||||||
$license: string;
|
$license: string;
|
||||||
$runtime?: string;
|
$runtime?: string;
|
||||||
$description?: string;
|
$description?: string;
|
||||||
|
|
||||||
$dependencies?: Array<string>;
|
$dependencies?: Array<string>;
|
||||||
|
|
||||||
|
appConfig?: any;
|
||||||
rules?: Array<RuleRef>;
|
rules?: Array<RuleRef>;
|
||||||
routes?: Array<RouteRef>;
|
routes?: Array<RouteRef>;
|
||||||
actions?: Array<ActionRef>;
|
actions?: Array<ActionRef>;
|
||||||
|
|||||||
@@ -602,6 +602,10 @@
|
|||||||
"minItems": 0,
|
"minItems": 0,
|
||||||
"uniqueItems": true
|
"uniqueItems": true
|
||||||
},
|
},
|
||||||
|
"appConfig": {
|
||||||
|
"description": "Application configuration parameters to add/override",
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"description": "List of rule definitions",
|
"description": "List of rule definitions",
|
||||||
"type": "array",
|
"type": "array",
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import * as core from '../evaluators/core.evaluators';
|
|||||||
import { ComponentRegisterService } from './component-register.service';
|
import { ComponentRegisterService } from './component-register.service';
|
||||||
import { RuleService } from './rule.service';
|
import { RuleService } from './rule.service';
|
||||||
import { ExtensionElement } from '../config/extension-element';
|
import { ExtensionElement } from '../config/extension-element';
|
||||||
|
import { BehaviorSubject } from 'rxjs';
|
||||||
|
|
||||||
export function extensionJsonsFactory() {
|
export function extensionJsonsFactory() {
|
||||||
return [];
|
return [];
|
||||||
@@ -58,6 +59,9 @@ export class ExtensionService {
|
|||||||
features: Array<any> = [];
|
features: Array<any> = [];
|
||||||
authGuards: { [key: string]: Type<{}> } = {};
|
authGuards: { [key: string]: Type<{}> } = {};
|
||||||
|
|
||||||
|
protected onSetup$ = new BehaviorSubject<ExtensionConfig>(this.config);
|
||||||
|
setup$ = this.onSetup$.asObservable();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected loader: ExtensionLoaderService,
|
protected loader: ExtensionLoaderService,
|
||||||
protected componentRegister: ComponentRegisterService,
|
protected componentRegister: ComponentRegisterService,
|
||||||
@@ -103,6 +107,7 @@ export class ExtensionService {
|
|||||||
this.features = this.loader.getFeatures(config);
|
this.features = this.loader.getFeatures(config);
|
||||||
|
|
||||||
this.ruleService.setup(config);
|
this.ruleService.setup(config);
|
||||||
|
this.onSetup$.next(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -37,6 +37,9 @@ describe('AppListCloudComponent', () => {
|
|||||||
const mock = {
|
const mock = {
|
||||||
oauth2Auth: {
|
oauth2Auth: {
|
||||||
callCustomApi: () => Promise.resolve(fakeApplicationInstance)
|
callCustomApi: () => Promise.resolve(fakeApplicationInstance)
|
||||||
|
},
|
||||||
|
isEcmLoggedIn() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ describe('AppsProcessCloudService', () => {
|
|||||||
const apiMock = {
|
const apiMock = {
|
||||||
oauth2Auth: {
|
oauth2Auth: {
|
||||||
callCustomApi: () => Promise.resolve({list : { entries: [ {entry: fakeApplicationInstance[0]}, {entry: fakeApplicationInstance[1]}] }})
|
callCustomApi: () => Promise.resolve({list : { entries: [ {entry: fakeApplicationInstance[0]}, {entry: fakeApplicationInstance[1]}] }})
|
||||||
|
},
|
||||||
|
isEcmLoggedIn() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -41,14 +44,19 @@ describe('AppsProcessCloudService', () => {
|
|||||||
TranslateModule.forRoot(),
|
TranslateModule.forRoot(),
|
||||||
CoreTestingModule,
|
CoreTestingModule,
|
||||||
ProcessServiceCloudTestingModule
|
ProcessServiceCloudTestingModule
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
AlfrescoApiService,
|
||||||
|
AppConfigService
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
service = TestBed.inject(AppsProcessCloudService);
|
|
||||||
appConfigService = TestBed.inject(AppConfigService);
|
|
||||||
apiService = TestBed.inject(AlfrescoApiService);
|
apiService = TestBed.inject(AlfrescoApiService);
|
||||||
spyOn(apiService, 'getInstance').and.returnValue(apiMock);
|
spyOn(apiService, 'getInstance').and.returnValue(apiMock);
|
||||||
|
|
||||||
|
service = TestBed.inject(AppsProcessCloudService);
|
||||||
|
appConfigService = TestBed.inject(AppConfigService);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get the deployed applications no apps are specified in app.config', (done) => {
|
it('should get the deployed applications no apps are specified in app.config', (done) => {
|
||||||
|
|||||||
@@ -49,7 +49,13 @@ describe('Form Cloud service', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
service = TestBed.inject(FormCloudService);
|
service = TestBed.inject(FormCloudService);
|
||||||
apiService = TestBed.inject(AlfrescoApiService);
|
apiService = TestBed.inject(AlfrescoApiService);
|
||||||
spyOn(apiService, 'getInstance').and.returnValue({ oauth2Auth: oauth2Auth });
|
|
||||||
|
spyOn(apiService, 'getInstance').and.returnValue({
|
||||||
|
oauth2Auth: oauth2Auth,
|
||||||
|
isEcmLoggedIn() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Form tests', () => {
|
describe('Form tests', () => {
|
||||||
|
|||||||
+6
-1
@@ -70,7 +70,12 @@ describe('Form Definition Selector Cloud Service', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
service = TestBed.inject(FormDefinitionSelectorCloudService);
|
service = TestBed.inject(FormDefinitionSelectorCloudService);
|
||||||
apiService = TestBed.inject(AlfrescoApiService);
|
apiService = TestBed.inject(AlfrescoApiService);
|
||||||
spyOn(apiService, 'getInstance').and.returnValue({ oauth2Auth: oauth2Auth });
|
spyOn(apiService, 'getInstance').and.returnValue({
|
||||||
|
oauth2Auth: oauth2Auth,
|
||||||
|
isEcmLoggedIn() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fetch all the forms when getForms is called', (done) => {
|
it('should fetch all the forms when getForms is called', (done) => {
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ describe('GroupCloudComponent', () => {
|
|||||||
const mock = {
|
const mock = {
|
||||||
oauth2Auth: {
|
oauth2Auth: {
|
||||||
callCustomApi: () => Promise.resolve(mockIdentityGroups)
|
callCustomApi: () => Promise.resolve(mockIdentityGroups)
|
||||||
|
},
|
||||||
|
isEcmLoggedIn() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ describe('PeopleCloudComponent', () => {
|
|||||||
const mock = {
|
const mock = {
|
||||||
oauth2Auth: {
|
oauth2Auth: {
|
||||||
callCustomApi: () => Promise.resolve(mockUsers)
|
callCustomApi: () => Promise.resolve(mockUsers)
|
||||||
|
},
|
||||||
|
isEcmLoggedIn() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -67,14 +67,17 @@ describe('EditProcessFilterCloudComponent', () => {
|
|||||||
const mock = {
|
const mock = {
|
||||||
oauth2Auth: {
|
oauth2Auth: {
|
||||||
callCustomApi: () => Promise.resolve(fakeApplicationInstance)
|
callCustomApi: () => Promise.resolve(fakeApplicationInstance)
|
||||||
|
},
|
||||||
|
isEcmLoggedIn() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
setupTestBed({
|
setupTestBed({
|
||||||
imports: [
|
imports: [
|
||||||
TranslateModule.forRoot(),
|
TranslateModule.forRoot(),
|
||||||
ProcessServiceCloudTestingModule,
|
|
||||||
ProcessFiltersCloudModule,
|
ProcessFiltersCloudModule,
|
||||||
|
ProcessServiceCloudTestingModule,
|
||||||
MatIconTestingModule
|
MatIconTestingModule
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
|
|||||||
+17
-12
@@ -14,14 +14,15 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import { async } from '@angular/core/testing';
|
import { async, TestBed } from '@angular/core/testing';
|
||||||
import { setupTestBed, StorageService, AlfrescoApiServiceMock, LogService, AppConfigService, CoreModule } from '@alfresco/adf-core';
|
import { setupTestBed, AlfrescoApiService } from '@alfresco/adf-core';
|
||||||
import { ProcessListCloudService } from './process-list-cloud.service';
|
import { ProcessListCloudService } from './process-list-cloud.service';
|
||||||
import { ProcessQueryCloudRequestModel } from '../models/process-cloud-query-request.model';
|
import { ProcessQueryCloudRequestModel } from '../models/process-cloud-query-request.model';
|
||||||
|
import { ProcessServiceCloudTestingModule } from '../../../testing/process-service-cloud.testing.module';
|
||||||
|
|
||||||
describe('ProcessListCloudService', () => {
|
describe('ProcessListCloudService', () => {
|
||||||
let service: ProcessListCloudService;
|
let service: ProcessListCloudService;
|
||||||
let alfrescoApiMock: AlfrescoApiServiceMock;
|
let alfrescoApiService: AlfrescoApiService;
|
||||||
|
|
||||||
function returnCallQueryParameters() {
|
function returnCallQueryParameters() {
|
||||||
return {
|
return {
|
||||||
@@ -29,6 +30,9 @@ describe('ProcessListCloudService', () => {
|
|||||||
callCustomApi: (_queryUrl, _operation, _context, queryParams) => {
|
callCustomApi: (_queryUrl, _operation, _context, queryParams) => {
|
||||||
return Promise.resolve(queryParams);
|
return Promise.resolve(queryParams);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
isEcmLoggedIn() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -39,26 +43,27 @@ describe('ProcessListCloudService', () => {
|
|||||||
callCustomApi: (queryUrl) => {
|
callCustomApi: (queryUrl) => {
|
||||||
return Promise.resolve(queryUrl);
|
return Promise.resolve(queryUrl);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
isEcmLoggedIn() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
setupTestBed({
|
setupTestBed({
|
||||||
imports: [
|
imports: [
|
||||||
CoreModule.forRoot()
|
ProcessServiceCloudTestingModule
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
alfrescoApiMock = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
|
alfrescoApiService = TestBed.inject(AlfrescoApiService);
|
||||||
service = new ProcessListCloudService(alfrescoApiMock,
|
service = TestBed.inject(ProcessListCloudService);
|
||||||
new AppConfigService(null),
|
|
||||||
new LogService(new AppConfigService(null)));
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should append to the call all the parameters', (done) => {
|
it('should append to the call all the parameters', (done) => {
|
||||||
const processRequest: ProcessQueryCloudRequestModel = <ProcessQueryCloudRequestModel> { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' };
|
const processRequest: ProcessQueryCloudRequestModel = <ProcessQueryCloudRequestModel> { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' };
|
||||||
spyOn(alfrescoApiMock, 'getInstance').and.callFake(returnCallQueryParameters);
|
spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallQueryParameters);
|
||||||
service.getProcessByRequest(processRequest).subscribe((res) => {
|
service.getProcessByRequest(processRequest).subscribe((res) => {
|
||||||
expect(res).toBeDefined();
|
expect(res).toBeDefined();
|
||||||
expect(res).not.toBeNull();
|
expect(res).not.toBeNull();
|
||||||
@@ -71,7 +76,7 @@ describe('ProcessListCloudService', () => {
|
|||||||
|
|
||||||
it('should concat the app name to the request url', (done) => {
|
it('should concat the app name to the request url', (done) => {
|
||||||
const processRequest: ProcessQueryCloudRequestModel = <ProcessQueryCloudRequestModel> { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' };
|
const processRequest: ProcessQueryCloudRequestModel = <ProcessQueryCloudRequestModel> { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' };
|
||||||
spyOn(alfrescoApiMock, 'getInstance').and.callFake(returnCallUrl);
|
spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallUrl);
|
||||||
service.getProcessByRequest(processRequest).subscribe((requestUrl) => {
|
service.getProcessByRequest(processRequest).subscribe((requestUrl) => {
|
||||||
expect(requestUrl).toBeDefined();
|
expect(requestUrl).toBeDefined();
|
||||||
expect(requestUrl).not.toBeNull();
|
expect(requestUrl).not.toBeNull();
|
||||||
@@ -85,7 +90,7 @@ describe('ProcessListCloudService', () => {
|
|||||||
appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service',
|
appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service',
|
||||||
sorting: [{ orderBy: 'NAME', direction: 'DESC' }, { orderBy: 'TITLE', direction: 'ASC' }]
|
sorting: [{ orderBy: 'NAME', direction: 'DESC' }, { orderBy: 'TITLE', direction: 'ASC' }]
|
||||||
};
|
};
|
||||||
spyOn(alfrescoApiMock, 'getInstance').and.callFake(returnCallQueryParameters);
|
spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallQueryParameters);
|
||||||
service.getProcessByRequest(processRequest).subscribe((res) => {
|
service.getProcessByRequest(processRequest).subscribe((res) => {
|
||||||
expect(res).toBeDefined();
|
expect(res).toBeDefined();
|
||||||
expect(res).not.toBeNull();
|
expect(res).not.toBeNull();
|
||||||
@@ -96,7 +101,7 @@ describe('ProcessListCloudService', () => {
|
|||||||
|
|
||||||
it('should return an error when app name is not specified', (done) => {
|
it('should return an error when app name is not specified', (done) => {
|
||||||
const processRequest: ProcessQueryCloudRequestModel = <ProcessQueryCloudRequestModel> { appName: null };
|
const processRequest: ProcessQueryCloudRequestModel = <ProcessQueryCloudRequestModel> { appName: null };
|
||||||
spyOn(alfrescoApiMock, 'getInstance').and.callFake(returnCallUrl);
|
spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallUrl);
|
||||||
service.getProcessByRequest(processRequest).subscribe(
|
service.getProcessByRequest(processRequest).subscribe(
|
||||||
() => { },
|
() => { },
|
||||||
(error) => {
|
(error) => {
|
||||||
|
|||||||
+3
@@ -37,6 +37,9 @@ describe('StartProcessCloudService', () => {
|
|||||||
status: 'RUNNING'
|
status: 'RUNNING'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
isEcmLoggedIn() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,9 @@ describe('NotificationCloudService', () => {
|
|||||||
const apiServiceMock = {
|
const apiServiceMock = {
|
||||||
oauth2Auth: {
|
oauth2Auth: {
|
||||||
token: '1234567'
|
token: '1234567'
|
||||||
|
},
|
||||||
|
isEcmLoggedIn() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ describe('PreferenceService', () => {
|
|||||||
callCustomApi: () => {
|
callCustomApi: () => {
|
||||||
return Promise.resolve(mockResponse);
|
return Promise.resolve(mockResponse);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
isEcmLoggedIn() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -46,6 +49,9 @@ describe('PreferenceService', () => {
|
|||||||
const apiErrorMock = {
|
const apiErrorMock = {
|
||||||
oauth2Auth: {
|
oauth2Auth: {
|
||||||
callCustomApi: () => Promise.reject(errorResponse)
|
callCustomApi: () => Promise.reject(errorResponse)
|
||||||
|
},
|
||||||
|
isEcmLoggedIn() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ describe('Task Cloud Service', () => {
|
|||||||
callCustomApi : () => {
|
callCustomApi : () => {
|
||||||
return Promise.resolve(taskCompleteCloudMock);
|
return Promise.resolve(taskCompleteCloudMock);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
isEcmLoggedIn() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -48,6 +51,9 @@ describe('Task Cloud Service', () => {
|
|||||||
callCustomApi : () => {
|
callCustomApi : () => {
|
||||||
return Promise.reject(taskCompleteCloudMock);
|
return Promise.reject(taskCompleteCloudMock);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
isEcmLoggedIn() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -58,6 +64,9 @@ describe('Task Cloud Service', () => {
|
|||||||
callCustomApi : () => {
|
callCustomApi : () => {
|
||||||
return Promise.resolve(fakeTaskDetailsCloud);
|
return Promise.resolve(fakeTaskDetailsCloud);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
isEcmLoggedIn() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -68,6 +77,9 @@ describe('Task Cloud Service', () => {
|
|||||||
callCustomApi : () => {
|
callCustomApi : () => {
|
||||||
return Promise.resolve(['mockuser1', 'mockuser2', 'mockuser3']);
|
return Promise.resolve(['mockuser1', 'mockuser2', 'mockuser3']);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
isEcmLoggedIn() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -78,6 +90,9 @@ describe('Task Cloud Service', () => {
|
|||||||
callCustomApi : () => {
|
callCustomApi : () => {
|
||||||
return Promise.resolve(['mockgroup1', 'mockgroup2', 'mockgroup3']);
|
return Promise.resolve(['mockgroup1', 'mockgroup2', 'mockgroup3']);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
isEcmLoggedIn() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
+3
@@ -41,6 +41,9 @@ describe('StartTaskCloudComponent', () => {
|
|||||||
const mock = {
|
const mock = {
|
||||||
oauth2Auth: {
|
oauth2Auth: {
|
||||||
callCustomApi: () => Promise.resolve(taskDetailsMock)
|
callCustomApi: () => Promise.resolve(taskDetailsMock)
|
||||||
|
},
|
||||||
|
isEcmLoggedIn() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+3
@@ -54,6 +54,9 @@ describe('EditTaskFilterCloudComponent', () => {
|
|||||||
const mock = {
|
const mock = {
|
||||||
oauth2Auth: {
|
oauth2Auth: {
|
||||||
callCustomApi: () => Promise.resolve(fakeApplicationInstance)
|
callCustomApi: () => Promise.resolve(fakeApplicationInstance)
|
||||||
|
},
|
||||||
|
isEcmLoggedIn() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+5
-12
@@ -16,14 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { TestBed } from '@angular/core/testing';
|
import { TestBed } from '@angular/core/testing';
|
||||||
import {
|
import { IdentityUserService, setupTestBed } from '@alfresco/adf-core';
|
||||||
AlfrescoApiService,
|
|
||||||
AlfrescoApiServiceMock,
|
|
||||||
AppConfigService,
|
|
||||||
AppConfigServiceMock,
|
|
||||||
IdentityUserService,
|
|
||||||
setupTestBed
|
|
||||||
} from '@alfresco/adf-core';
|
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
import { TASK_FILTERS_SERVICE_TOKEN } from '../../../services/cloud-token.service';
|
import { TASK_FILTERS_SERVICE_TOKEN } from '../../../services/cloud-token.service';
|
||||||
import { LocalPreferenceCloudService } from '../../../services/local-preference-cloud.service';
|
import { LocalPreferenceCloudService } from '../../../services/local-preference-cloud.service';
|
||||||
@@ -42,6 +35,7 @@ import { HttpClientTestingModule } from '@angular/common/http/testing';
|
|||||||
import { TaskFilterCloudModel } from '../models/filter-cloud.model';
|
import { TaskFilterCloudModel } from '../models/filter-cloud.model';
|
||||||
import { NotificationCloudService } from '../../../services/notification-cloud.service';
|
import { NotificationCloudService } from '../../../services/notification-cloud.service';
|
||||||
import { TaskCloudEngineEvent } from './../../../models/engine-event-cloud.model';
|
import { TaskCloudEngineEvent } from './../../../models/engine-event-cloud.model';
|
||||||
|
import { ProcessServiceCloudTestingModule } from '../../../testing/process-service-cloud.testing.module';
|
||||||
|
|
||||||
describe('TaskFilterCloudService', () => {
|
describe('TaskFilterCloudService', () => {
|
||||||
let service: TaskFilterCloudService;
|
let service: TaskFilterCloudService;
|
||||||
@@ -57,12 +51,11 @@ describe('TaskFilterCloudService', () => {
|
|||||||
|
|
||||||
setupTestBed({
|
setupTestBed({
|
||||||
imports: [
|
imports: [
|
||||||
HttpClientTestingModule
|
HttpClientTestingModule,
|
||||||
|
ProcessServiceCloudTestingModule
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: TASK_FILTERS_SERVICE_TOKEN, useClass: UserPreferenceCloudService },
|
{ provide: TASK_FILTERS_SERVICE_TOKEN, useClass: UserPreferenceCloudService }
|
||||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
|
|
||||||
{ provide: AppConfigService, useClass: AppConfigServiceMock }
|
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+3
@@ -52,6 +52,9 @@ describe('TaskHeaderCloudComponent', () => {
|
|||||||
const mock = {
|
const mock = {
|
||||||
oauth2Auth: {
|
oauth2Auth: {
|
||||||
callCustomApi: () => Promise.resolve({})
|
callCustomApi: () => Promise.resolve({})
|
||||||
|
},
|
||||||
|
isEcmLoggedIn() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+17
-12
@@ -15,15 +15,16 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { async } from '@angular/core/testing';
|
import { async, TestBed } from '@angular/core/testing';
|
||||||
import { setupTestBed, StorageService, AlfrescoApiServiceMock, LogService, AppConfigService, CoreModule } from '@alfresco/adf-core';
|
import { setupTestBed, AlfrescoApiService } from '@alfresco/adf-core';
|
||||||
import { ServiceTaskListCloudService } from './service-task-list-cloud.service';
|
import { ServiceTaskListCloudService } from './service-task-list-cloud.service';
|
||||||
import { ServiceTaskQueryCloudRequestModel } from '../models/service-task-cloud.model';
|
import { ServiceTaskQueryCloudRequestModel } from '../models/service-task-cloud.model';
|
||||||
|
import { ProcessServiceCloudTestingModule } from '../../../testing/process-service-cloud.testing.module';
|
||||||
|
|
||||||
describe('Activiti ServiceTaskList Cloud Service', () => {
|
describe('Activiti ServiceTaskList Cloud Service', () => {
|
||||||
|
|
||||||
let service: ServiceTaskListCloudService;
|
let service: ServiceTaskListCloudService;
|
||||||
let alfrescoApiMock: AlfrescoApiServiceMock;
|
let alfrescoApiService: AlfrescoApiService;
|
||||||
|
|
||||||
function returnCallQueryParameters() {
|
function returnCallQueryParameters() {
|
||||||
return {
|
return {
|
||||||
@@ -31,6 +32,9 @@ describe('Activiti ServiceTaskList Cloud Service', () => {
|
|||||||
callCustomApi: (_queryUrl, _operation, _context, queryParams) => {
|
callCustomApi: (_queryUrl, _operation, _context, queryParams) => {
|
||||||
return Promise.resolve(queryParams);
|
return Promise.resolve(queryParams);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
isEcmLoggedIn() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -41,26 +45,27 @@ describe('Activiti ServiceTaskList Cloud Service', () => {
|
|||||||
callCustomApi: (queryUrl) => {
|
callCustomApi: (queryUrl) => {
|
||||||
return Promise.resolve(queryUrl);
|
return Promise.resolve(queryUrl);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
isEcmLoggedIn() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
setupTestBed({
|
setupTestBed({
|
||||||
imports: [
|
imports: [
|
||||||
CoreModule.forRoot()
|
ProcessServiceCloudTestingModule
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
alfrescoApiMock = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
|
alfrescoApiService = TestBed.inject(AlfrescoApiService);
|
||||||
service = new ServiceTaskListCloudService(alfrescoApiMock,
|
service = TestBed.inject(ServiceTaskListCloudService);
|
||||||
new AppConfigService(null),
|
|
||||||
new LogService(new AppConfigService(null)));
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should append to the call all the parameters', (done) => {
|
it('should append to the call all the parameters', (done) => {
|
||||||
const taskRequest: ServiceTaskQueryCloudRequestModel = <ServiceTaskQueryCloudRequestModel> { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' };
|
const taskRequest: ServiceTaskQueryCloudRequestModel = <ServiceTaskQueryCloudRequestModel> { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' };
|
||||||
spyOn(alfrescoApiMock, 'getInstance').and.callFake(returnCallQueryParameters);
|
spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallQueryParameters);
|
||||||
service.getServiceTaskByRequest(taskRequest).subscribe((res) => {
|
service.getServiceTaskByRequest(taskRequest).subscribe((res) => {
|
||||||
expect(res).toBeDefined();
|
expect(res).toBeDefined();
|
||||||
expect(res).not.toBeNull();
|
expect(res).not.toBeNull();
|
||||||
@@ -73,7 +78,7 @@ describe('Activiti ServiceTaskList Cloud Service', () => {
|
|||||||
|
|
||||||
it('should concat the app name to the request url', (done) => {
|
it('should concat the app name to the request url', (done) => {
|
||||||
const taskRequest: ServiceTaskQueryCloudRequestModel = <ServiceTaskQueryCloudRequestModel> { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' };
|
const taskRequest: ServiceTaskQueryCloudRequestModel = <ServiceTaskQueryCloudRequestModel> { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' };
|
||||||
spyOn(alfrescoApiMock, 'getInstance').and.callFake(returnCallUrl);
|
spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallUrl);
|
||||||
service.getServiceTaskByRequest(taskRequest).subscribe((requestUrl) => {
|
service.getServiceTaskByRequest(taskRequest).subscribe((requestUrl) => {
|
||||||
expect(requestUrl).toBeDefined();
|
expect(requestUrl).toBeDefined();
|
||||||
expect(requestUrl).not.toBeNull();
|
expect(requestUrl).not.toBeNull();
|
||||||
@@ -87,7 +92,7 @@ describe('Activiti ServiceTaskList Cloud Service', () => {
|
|||||||
appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service',
|
appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service',
|
||||||
sorting: [{ orderBy: 'NAME', direction: 'DESC' }, { orderBy: 'TITLE', direction: 'ASC' }]
|
sorting: [{ orderBy: 'NAME', direction: 'DESC' }, { orderBy: 'TITLE', direction: 'ASC' }]
|
||||||
};
|
};
|
||||||
spyOn(alfrescoApiMock, 'getInstance').and.callFake(returnCallQueryParameters);
|
spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallQueryParameters);
|
||||||
service.getServiceTaskByRequest(taskRequest).subscribe((res) => {
|
service.getServiceTaskByRequest(taskRequest).subscribe((res) => {
|
||||||
expect(res).toBeDefined();
|
expect(res).toBeDefined();
|
||||||
expect(res).not.toBeNull();
|
expect(res).not.toBeNull();
|
||||||
@@ -98,7 +103,7 @@ describe('Activiti ServiceTaskList Cloud Service', () => {
|
|||||||
|
|
||||||
it('should return an error when app name is not specified', (done) => {
|
it('should return an error when app name is not specified', (done) => {
|
||||||
const taskRequest: ServiceTaskQueryCloudRequestModel = <ServiceTaskQueryCloudRequestModel> { appName: null };
|
const taskRequest: ServiceTaskQueryCloudRequestModel = <ServiceTaskQueryCloudRequestModel> { appName: null };
|
||||||
spyOn(alfrescoApiMock, 'getInstance').and.callFake(returnCallUrl);
|
spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallUrl);
|
||||||
service.getServiceTaskByRequest(taskRequest).subscribe(
|
service.getServiceTaskByRequest(taskRequest).subscribe(
|
||||||
() => { },
|
() => { },
|
||||||
(error) => {
|
(error) => {
|
||||||
|
|||||||
+21
-14
@@ -15,15 +15,17 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { async } from '@angular/core/testing';
|
import { TestBed } from '@angular/core/testing';
|
||||||
import { setupTestBed, StorageService, AlfrescoApiServiceMock, LogService, AppConfigService, CoreModule } from '@alfresco/adf-core';
|
import { setupTestBed, AlfrescoApiService } from '@alfresco/adf-core';
|
||||||
import { TaskListCloudService } from './task-list-cloud.service';
|
import { TaskListCloudService } from './task-list-cloud.service';
|
||||||
import { TaskQueryCloudRequestModel } from '../models/filter-cloud-model';
|
import { TaskQueryCloudRequestModel } from '../models/filter-cloud-model';
|
||||||
|
import { ProcessServiceCloudTestingModule } from '../../../testing/process-service-cloud.testing.module';
|
||||||
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
|
||||||
describe('TaskListCloudService', () => {
|
describe('TaskListCloudService', () => {
|
||||||
|
|
||||||
let service: TaskListCloudService;
|
let service: TaskListCloudService;
|
||||||
let alfrescoApiMock: AlfrescoApiServiceMock;
|
let alfrescoApiService: AlfrescoApiService;
|
||||||
|
|
||||||
function returnCallQueryParameters() {
|
function returnCallQueryParameters() {
|
||||||
return {
|
return {
|
||||||
@@ -31,6 +33,9 @@ describe('TaskListCloudService', () => {
|
|||||||
callCustomApi : (_queryUrl, _operation, _context, queryParams) => {
|
callCustomApi : (_queryUrl, _operation, _context, queryParams) => {
|
||||||
return Promise.resolve(queryParams);
|
return Promise.resolve(queryParams);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
isEcmLoggedIn() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -41,26 +46,28 @@ describe('TaskListCloudService', () => {
|
|||||||
callCustomApi : (queryUrl) => {
|
callCustomApi : (queryUrl) => {
|
||||||
return Promise.resolve(queryUrl);
|
return Promise.resolve(queryUrl);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
isEcmLoggedIn() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
setupTestBed({
|
setupTestBed({
|
||||||
imports: [
|
imports: [
|
||||||
CoreModule.forRoot()
|
TranslateModule.forRoot(),
|
||||||
|
ProcessServiceCloudTestingModule
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(() => {
|
||||||
alfrescoApiMock = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
|
alfrescoApiService = TestBed.inject(AlfrescoApiService);
|
||||||
service = new TaskListCloudService(alfrescoApiMock,
|
service = TestBed.inject(TaskListCloudService);
|
||||||
new AppConfigService(null),
|
});
|
||||||
new LogService(new AppConfigService(null)));
|
|
||||||
}));
|
|
||||||
|
|
||||||
it('should append to the call all the parameters', (done) => {
|
it('should append to the call all the parameters', (done) => {
|
||||||
const taskRequest: TaskQueryCloudRequestModel = <TaskQueryCloudRequestModel> { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' };
|
const taskRequest: TaskQueryCloudRequestModel = <TaskQueryCloudRequestModel> { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' };
|
||||||
spyOn(alfrescoApiMock, 'getInstance').and.callFake(returnCallQueryParameters);
|
spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallQueryParameters);
|
||||||
service.getTaskByRequest(taskRequest).subscribe((res) => {
|
service.getTaskByRequest(taskRequest).subscribe((res) => {
|
||||||
expect(res).toBeDefined();
|
expect(res).toBeDefined();
|
||||||
expect(res).not.toBeNull();
|
expect(res).not.toBeNull();
|
||||||
@@ -73,7 +80,7 @@ describe('TaskListCloudService', () => {
|
|||||||
|
|
||||||
it('should concat the app name to the request url', (done) => {
|
it('should concat the app name to the request url', (done) => {
|
||||||
const taskRequest: TaskQueryCloudRequestModel = <TaskQueryCloudRequestModel> { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' };
|
const taskRequest: TaskQueryCloudRequestModel = <TaskQueryCloudRequestModel> { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' };
|
||||||
spyOn(alfrescoApiMock, 'getInstance').and.callFake(returnCallUrl);
|
spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallUrl);
|
||||||
service.getTaskByRequest(taskRequest).subscribe((requestUrl) => {
|
service.getTaskByRequest(taskRequest).subscribe((requestUrl) => {
|
||||||
expect(requestUrl).toBeDefined();
|
expect(requestUrl).toBeDefined();
|
||||||
expect(requestUrl).not.toBeNull();
|
expect(requestUrl).not.toBeNull();
|
||||||
@@ -85,7 +92,7 @@ describe('TaskListCloudService', () => {
|
|||||||
it('should concat the sorting to append as parameters', (done) => {
|
it('should concat the sorting to append as parameters', (done) => {
|
||||||
const taskRequest: TaskQueryCloudRequestModel = <TaskQueryCloudRequestModel> { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service',
|
const taskRequest: TaskQueryCloudRequestModel = <TaskQueryCloudRequestModel> { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service',
|
||||||
sorting: [{ orderBy: 'NAME', direction: 'DESC'}, { orderBy: 'TITLE', direction: 'ASC'}] };
|
sorting: [{ orderBy: 'NAME', direction: 'DESC'}, { orderBy: 'TITLE', direction: 'ASC'}] };
|
||||||
spyOn(alfrescoApiMock, 'getInstance').and.callFake(returnCallQueryParameters);
|
spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallQueryParameters);
|
||||||
service.getTaskByRequest(taskRequest).subscribe((res) => {
|
service.getTaskByRequest(taskRequest).subscribe((res) => {
|
||||||
expect(res).toBeDefined();
|
expect(res).toBeDefined();
|
||||||
expect(res).not.toBeNull();
|
expect(res).not.toBeNull();
|
||||||
@@ -96,7 +103,7 @@ describe('TaskListCloudService', () => {
|
|||||||
|
|
||||||
it('should return an error when app name is not specified', (done) => {
|
it('should return an error when app name is not specified', (done) => {
|
||||||
const taskRequest: TaskQueryCloudRequestModel = <TaskQueryCloudRequestModel> { appName: null };
|
const taskRequest: TaskQueryCloudRequestModel = <TaskQueryCloudRequestModel> { appName: null };
|
||||||
spyOn(alfrescoApiMock, 'getInstance').and.callFake(returnCallUrl);
|
spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallUrl);
|
||||||
service.getTaskByRequest(taskRequest).subscribe(
|
service.getTaskByRequest(taskRequest).subscribe(
|
||||||
() => { },
|
() => { },
|
||||||
(error) => {
|
(error) => {
|
||||||
|
|||||||
@@ -36,9 +36,9 @@ import { RouterTestingModule } from '@angular/router/testing';
|
|||||||
HttpClientModule,
|
HttpClientModule,
|
||||||
NoopAnimationsModule,
|
NoopAnimationsModule,
|
||||||
RouterTestingModule,
|
RouterTestingModule,
|
||||||
TranslateModule,
|
TranslateModule.forRoot(),
|
||||||
CoreModule,
|
CoreModule.forRoot(),
|
||||||
ProcessServicesCloudModule
|
ProcessServicesCloudModule.forRoot()
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
|
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
|
||||||
|
|||||||
+3
-4
@@ -21,7 +21,7 @@ import { ContentModule, ContentNodeSelectorPanelComponent, DocumentListService }
|
|||||||
import { EventEmitter, NO_ERRORS_SCHEMA } from '@angular/core';
|
import { EventEmitter, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
import { ProcessTestingModule } from '../testing/process.testing.module';
|
import { ProcessTestingModule } from '../testing/process.testing.module';
|
||||||
import { AttachFileWidgetDialogComponent } from './attach-file-widget-dialog.component';
|
import { AttachFileWidgetDialogComponent } from './attach-file-widget-dialog.component';
|
||||||
import { setupTestBed, AuthenticationService, SitesService, AlfrescoApiService, AlfrescoApiServiceMock, NodesApiService } from '@alfresco/adf-core';
|
import { setupTestBed, AuthenticationService, SitesService, AlfrescoApiService, NodesApiService } from '@alfresco/adf-core';
|
||||||
import { AttachFileWidgetDialogComponentData } from './attach-file-widget-dialog-component.interface';
|
import { AttachFileWidgetDialogComponentData } from './attach-file-widget-dialog-component.interface';
|
||||||
import { of, throwError } from 'rxjs';
|
import { of, throwError } from 'rxjs';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
@@ -53,12 +53,11 @@ describe('AttachFileWidgetDialogComponent', () => {
|
|||||||
setupTestBed({
|
setupTestBed({
|
||||||
imports: [
|
imports: [
|
||||||
TranslateModule.forRoot(),
|
TranslateModule.forRoot(),
|
||||||
ProcessTestingModule,
|
ContentModule.forRoot(),
|
||||||
ContentModule.forRoot()
|
ProcessTestingModule
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: MAT_DIALOG_DATA, useValue: data },
|
{ provide: MAT_DIALOG_DATA, useValue: data },
|
||||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
|
|
||||||
{ provide: MatDialogRef, useValue: { close: () => of() } }
|
{ provide: MatDialogRef, useValue: { close: () => of() } }
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
|
|||||||
@@ -15,12 +15,11 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { async } from '@angular/core/testing';
|
import { async, TestBed } from '@angular/core/testing';
|
||||||
import { mockError, fakeProcessFiltersResponse } from '../../mock';
|
import { mockError, fakeProcessFiltersResponse } from '../../mock';
|
||||||
import { FilterProcessRepresentationModel } from '../models/filter-process.model';
|
import { FilterProcessRepresentationModel } from '../models/filter-process.model';
|
||||||
import { ProcessFilterService } from './process-filter.service';
|
import { ProcessFilterService } from './process-filter.service';
|
||||||
import { AlfrescoApiServiceMock, AlfrescoApiService, AppConfigService,
|
import { AlfrescoApiService, setupTestBed, CoreTestingModule } from '@alfresco/adf-core';
|
||||||
setupTestBed, CoreModule, StorageService } from '@alfresco/adf-core';
|
|
||||||
|
|
||||||
declare let jasmine: any;
|
declare let jasmine: any;
|
||||||
|
|
||||||
@@ -32,13 +31,13 @@ describe('Process filter', () => {
|
|||||||
|
|
||||||
setupTestBed({
|
setupTestBed({
|
||||||
imports: [
|
imports: [
|
||||||
CoreModule.forRoot()
|
CoreTestingModule
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
apiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
|
apiService = TestBed.inject(AlfrescoApiService);
|
||||||
service = new ProcessFilterService(apiService);
|
service = TestBed.inject(ProcessFilterService);
|
||||||
alfrescoApi = apiService.getInstance();
|
alfrescoApi = apiService.getInstance();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -38,9 +38,9 @@ export class ProcessFilterService {
|
|||||||
getProcessFilters(appId: number): Observable<FilterProcessRepresentationModel[]> {
|
getProcessFilters(appId: number): Observable<FilterProcessRepresentationModel[]> {
|
||||||
return from(this.callApiProcessFilters(appId))
|
return from(this.callApiProcessFilters(appId))
|
||||||
.pipe(
|
.pipe(
|
||||||
map((response: any) => {
|
map((response) => {
|
||||||
const filters: FilterProcessRepresentationModel[] = [];
|
const filters: FilterProcessRepresentationModel[] = [];
|
||||||
response.data.forEach((filter: FilterProcessRepresentationModel) => {
|
response.data.forEach((filter) => {
|
||||||
const filterModel = new FilterProcessRepresentationModel(filter);
|
const filterModel = new FilterProcessRepresentationModel(filter);
|
||||||
filters.push(filterModel);
|
filters.push(filterModel);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -15,13 +15,13 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { async } from '@angular/core/testing';
|
import { async, TestBed } from '@angular/core/testing';
|
||||||
import { exampleProcess, fakeProcessInstances, mockError, fakeProcessDef, fakeTasksList } from '../../mock';
|
import { exampleProcess, fakeProcessInstances, mockError, fakeProcessDef, fakeTasksList } from '../../mock';
|
||||||
import { ProcessFilterParamRepresentationModel } from '../models/filter-process.model';
|
import { ProcessFilterParamRepresentationModel } from '../models/filter-process.model';
|
||||||
import { ProcessInstanceVariable } from '../models/process-instance-variable.model';
|
import { ProcessInstanceVariable } from '../models/process-instance-variable.model';
|
||||||
import { ProcessService } from './process.service';
|
import { ProcessService } from './process.service';
|
||||||
import { AlfrescoApiService, AlfrescoApiServiceMock, AppConfigService,
|
import { AlfrescoApiService, setupTestBed, CoreModule } from '@alfresco/adf-core';
|
||||||
setupTestBed, CoreModule, StorageService } from '@alfresco/adf-core';
|
import { ProcessTestingModule } from '../../testing/process.testing.module';
|
||||||
|
|
||||||
declare let moment: any;
|
declare let moment: any;
|
||||||
|
|
||||||
@@ -33,12 +33,13 @@ describe('ProcessService', () => {
|
|||||||
|
|
||||||
setupTestBed({
|
setupTestBed({
|
||||||
imports: [
|
imports: [
|
||||||
CoreModule.forRoot()
|
CoreModule.forRoot(),
|
||||||
|
ProcessTestingModule
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
apiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
|
apiService = TestBed.inject(AlfrescoApiService);
|
||||||
service = new ProcessService(apiService);
|
service = new ProcessService(apiService);
|
||||||
alfrescoApi = apiService.getInstance();
|
alfrescoApi = apiService.getInstance();
|
||||||
});
|
});
|
||||||
@@ -47,7 +48,7 @@ describe('ProcessService', () => {
|
|||||||
|
|
||||||
let getProcessInstances: jasmine.Spy;
|
let getProcessInstances: jasmine.Spy;
|
||||||
|
|
||||||
const filter: ProcessFilterParamRepresentationModel = new ProcessFilterParamRepresentationModel({
|
const filter = new ProcessFilterParamRepresentationModel({
|
||||||
processDefinitionId: '1',
|
processDefinitionId: '1',
|
||||||
appDefinitionId: '1',
|
appDefinitionId: '1',
|
||||||
page: 1,
|
page: 1,
|
||||||
|
|||||||
@@ -15,12 +15,13 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { async } from '@angular/core/testing';
|
import { async, TestBed } from '@angular/core/testing';
|
||||||
import { fakeAppPromise } from '../../mock';
|
import { fakeAppPromise } from '../../mock';
|
||||||
import { fakeFiltersResponse, fakeAppFilter } from '../../mock/task/task-filters.mock';
|
import { fakeFiltersResponse, fakeAppFilter } from '../../mock/task/task-filters.mock';
|
||||||
import { FilterRepresentationModel } from '../models/filter.model';
|
import { FilterRepresentationModel } from '../models/filter.model';
|
||||||
import { TaskFilterService } from './task-filter.service';
|
import { TaskFilterService } from './task-filter.service';
|
||||||
import { AlfrescoApiServiceMock, LogService, AppConfigService, setupTestBed, CoreModule, StorageService } from '@alfresco/adf-core';
|
import { setupTestBed, CoreModule } from '@alfresco/adf-core';
|
||||||
|
import { ProcessTestingModule } from '../../testing/process.testing.module';
|
||||||
|
|
||||||
declare let jasmine: any;
|
declare let jasmine: any;
|
||||||
|
|
||||||
@@ -30,14 +31,13 @@ describe('Activiti Task filter Service', () => {
|
|||||||
|
|
||||||
setupTestBed({
|
setupTestBed({
|
||||||
imports: [
|
imports: [
|
||||||
CoreModule.forRoot()
|
CoreModule.forRoot(),
|
||||||
|
ProcessTestingModule
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
service = new TaskFilterService(
|
service = TestBed.inject(TaskFilterService);
|
||||||
new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService()),
|
|
||||||
new LogService(new AppConfigService(null)));
|
|
||||||
jasmine.Ajax.install();
|
jasmine.Ajax.install();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ describe('Activiti Task filter Service', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return the default filters', (done) => {
|
it('should return the default filters', (done) => {
|
||||||
service.createDefaultFilters(1234).subscribe((res: FilterRepresentationModel []) => {
|
service.createDefaultFilters(1234).subscribe((res) => {
|
||||||
expect(res).toBeDefined();
|
expect(res).toBeDefined();
|
||||||
expect(res.length).toEqual(4);
|
expect(res.length).toEqual(4);
|
||||||
expect(res[0].name).toEqual('My Tasks');
|
expect(res[0].name).toEqual('My Tasks');
|
||||||
@@ -175,7 +175,7 @@ describe('Activiti Task filter Service', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able create filters and add sorting information to the response', (done) => {
|
it('should be able create filters and add sorting information to the response', (done) => {
|
||||||
service.createDefaultFilters(1234).subscribe((res: FilterRepresentationModel []) => {
|
service.createDefaultFilters(1234).subscribe((res) => {
|
||||||
expect(res).toBeDefined();
|
expect(res).toBeDefined();
|
||||||
expect(res.length).toEqual(4);
|
expect(res.length).toEqual(4);
|
||||||
expect(res[0].name).toEqual('My Tasks');
|
expect(res[0].name).toEqual('My Tasks');
|
||||||
@@ -235,7 +235,7 @@ describe('Activiti Task filter Service', () => {
|
|||||||
assignment: 'fake-assignment'
|
assignment: 'fake-assignment'
|
||||||
});
|
});
|
||||||
|
|
||||||
service.addFilter(filterFake).subscribe((res: FilterRepresentationModel) => {
|
service.addFilter(filterFake).subscribe((res) => {
|
||||||
expect(res).toBeDefined();
|
expect(res).toBeDefined();
|
||||||
expect(res.id).not.toEqual(null);
|
expect(res.id).not.toEqual(null);
|
||||||
expect(res.name).toEqual('FakeNameFilter');
|
expect(res.name).toEqual('FakeNameFilter');
|
||||||
|
|||||||
@@ -15,8 +15,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { async } from '@angular/core/testing';
|
import { async, TestBed } from '@angular/core/testing';
|
||||||
import { UserProcessModel, setupTestBed, CoreModule, StorageService, AlfrescoApiServiceMock, LogService, AppConfigService } from '@alfresco/adf-core';
|
import { UserProcessModel, setupTestBed, CoreModule } from '@alfresco/adf-core';
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
import {
|
import {
|
||||||
fakeCompletedTaskList,
|
fakeCompletedTaskList,
|
||||||
@@ -34,6 +34,7 @@ import { FilterRepresentationModel, TaskQueryRequestRepresentationModel } from '
|
|||||||
import { TaskDetailsModel } from '../models/task-details.model';
|
import { TaskDetailsModel } from '../models/task-details.model';
|
||||||
import { TaskListService } from './tasklist.service';
|
import { TaskListService } from './tasklist.service';
|
||||||
import { TaskUpdateRepresentation } from '@alfresco/js-api';
|
import { TaskUpdateRepresentation } from '@alfresco/js-api';
|
||||||
|
import { ProcessTestingModule } from '../../testing/process.testing.module';
|
||||||
|
|
||||||
declare let jasmine: any;
|
declare let jasmine: any;
|
||||||
|
|
||||||
@@ -43,14 +44,13 @@ describe('Activiti TaskList Service', () => {
|
|||||||
|
|
||||||
setupTestBed({
|
setupTestBed({
|
||||||
imports: [
|
imports: [
|
||||||
CoreModule.forRoot()
|
CoreModule.forRoot(),
|
||||||
|
ProcessTestingModule
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
service = new TaskListService(
|
service = TestBed.inject(TaskListService);
|
||||||
new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService()),
|
|
||||||
new LogService(new AppConfigService(null)));
|
|
||||||
jasmine.Ajax.install();
|
jasmine.Ajax.install();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ import { RouterTestingModule } from '@angular/router/testing';
|
|||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
NoopAnimationsModule,
|
NoopAnimationsModule,
|
||||||
TranslateModule,
|
TranslateModule.forRoot(),
|
||||||
CoreModule,
|
CoreModule.forRoot(),
|
||||||
ProcessModule,
|
ProcessModule,
|
||||||
RouterTestingModule
|
RouterTestingModule
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user