mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-16 18:13:06 +00:00
Compare commits
21
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
10673e5803 | ||
|
|
946e6d8014 | ||
|
|
035d96c118 | ||
|
|
f63779cb15 | ||
|
|
2fbf916749 | ||
|
|
3bd705b8b4 | ||
|
|
66f5a4081a | ||
|
|
4d8439ffb0 | ||
|
|
2876d09e74 | ||
|
|
88abd309a5 | ||
|
|
6d26c184c8 | ||
|
|
3cd7539c56 | ||
|
|
e6b1d06149 | ||
|
|
c1e8ac3f9a | ||
|
|
97938098df | ||
|
|
3924590537 | ||
|
|
afd0bc6b57 | ||
|
|
57854b41cd | ||
|
|
880c670593 | ||
|
|
4d84f665ce | ||
|
|
c4f7fdf093 |
@@ -15,16 +15,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
import { StorageService, AppConfigService } from '@alfresco/adf-core';
|
||||
import { AlfrescoApi, AlfrescoApiConfig } from '@alfresco/js-api';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AlfrescoApiService } from '../services/alfresco-api.service';
|
||||
|
||||
/** @deprecated use `AlfrescoApiService` instead */
|
||||
@Injectable()
|
||||
export class AlfrescoApiNoAuthService extends AlfrescoApiService {
|
||||
constructor(storage: StorageService, appConfig: AppConfigService, private readonly adfHttpClient: AdfHttpClient) {
|
||||
super(appConfig, storage);
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
override createInstance(config: AlfrescoApiConfig) {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
import { EventEmitter } from '@angular/core';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { AppConfigModule, AppConfigService, AppConfigServiceMock } from '@alfresco/adf-core';
|
||||
import { AppConfigService, AppConfigServiceMock } from '@alfresco/adf-core';
|
||||
import { UploadService } from './upload.service';
|
||||
import { RepositoryInfo } from '@alfresco/js-api';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
@@ -26,6 +26,7 @@ import { FileModel, FileUploadStatus } from '../../common/models/file.model';
|
||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||
import { AlfrescoApiService } from '../../services';
|
||||
import { AlfrescoApiServiceMock } from '../../mock';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
@@ -38,11 +39,13 @@ describe('UploadService', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [AppConfigModule, HttpClientTestingModule],
|
||||
imports: [HttpClientTestingModule],
|
||||
providers: [
|
||||
UploadService,
|
||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
|
||||
{ provide: AppConfigService, useClass: AppConfigServiceMock },
|
||||
// TODO: remove this as soon as unit test not using jasmine.Ajax
|
||||
{ provide: AdfHttpClient, useValue: null },
|
||||
{
|
||||
provide: DiscoveryApiService,
|
||||
useValue: {
|
||||
|
||||
+3
-6
@@ -131,10 +131,9 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
expect(lastValue).toBe('fake-site');
|
||||
});
|
||||
|
||||
it('should trigger siteChange event when a site is selected in sites-dropdown', async () => {
|
||||
it('should trigger siteChange event when a site is selected in sites-dropdown', () => {
|
||||
const fakeSiteEntry = new SiteEntry({ entry: new Site({ title: 'fake-new-site', guid: 'fake-new-site' }) });
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
let lastValue: string;
|
||||
component.siteChange.subscribe((siteTitle: string) => (lastValue = siteTitle));
|
||||
@@ -698,7 +697,7 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
contentNodeSelectorPanelService.customModels = undefined;
|
||||
});
|
||||
|
||||
it('should search panel be collapsed by default and expand when clicking the filter button', async () => {
|
||||
it('should search panel be collapsed by default and expand when clicking the filter button', () => {
|
||||
contentNodeSelectorPanelService.customModels = [mockContentModelTextProperty];
|
||||
fixture.detectChanges();
|
||||
|
||||
@@ -708,7 +707,6 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
toggleFiltersPanelButton.nativeElement.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(component.searchPanelExpanded).toEqual(true);
|
||||
});
|
||||
@@ -758,10 +756,9 @@ describe('ContentNodeSelectorPanelComponent', () => {
|
||||
expect(component.getSelectedCount()).toBe(0);
|
||||
});
|
||||
|
||||
it('should not render component input if `showNodeCounter` is false', async () => {
|
||||
it('should not render component input if `showNodeCounter` is false', () => {
|
||||
component.showNodeCounter = false;
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
expect(fixture.debugElement.nativeElement.querySelector('adf-node-counter')).toBe(null);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -46,8 +46,6 @@ import { AlfrescoViewerComponent } from './viewer';
|
||||
import { ContentTypeDialogComponent } from './content-type';
|
||||
import { MaterialModule } from './material.module';
|
||||
import { AlfrescoIconComponent } from './alfresco-icon/alfresco-icon.component';
|
||||
import { AlfrescoApiService } from './services/alfresco-api.service';
|
||||
import { AlfrescoApiNoAuthService } from './api-factories/alfresco-api-no-auth.service';
|
||||
import { AlfrescoApiLoaderService, createAlfrescoApiInstance } from './api-factories/alfresco-api-v2-loader.service';
|
||||
|
||||
@NgModule({
|
||||
@@ -114,7 +112,6 @@ export class ContentModule {
|
||||
providers: [
|
||||
provideTranslations('adf-content-services', 'assets/adf-content-services'),
|
||||
ContentAuthLoaderService,
|
||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiNoAuthService },
|
||||
{
|
||||
provide: APP_INITIALIZER,
|
||||
useFactory: versionCompatibilityFactory,
|
||||
|
||||
@@ -84,7 +84,7 @@ describe('LibraryFavoriteDirective', () => {
|
||||
});
|
||||
|
||||
it('should call addFavorite() and display snackbar message on click event when selection is not a favorite', async () => {
|
||||
spyOn(component.directive.favoritesApi, 'getFavoriteSite').and.returnValue(Promise.reject(new Error('error')));
|
||||
spyOn(component.directive.favoritesApi, 'getFavoriteSite').and.callFake(() => Promise.reject(new Error('error')));
|
||||
spyOn(component.directive.favoritesApi, 'createFavorite').and.returnValue(Promise.resolve(null));
|
||||
spyOn(notificationService, 'showInfo');
|
||||
|
||||
@@ -99,6 +99,7 @@ describe('LibraryFavoriteDirective', () => {
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(component.directive.favoritesApi.createFavorite).toHaveBeenCalled();
|
||||
expect(component.directive.favoritesApi.getFavoriteSite).not.toHaveBeenCalled();
|
||||
expect(notificationService.showInfo).toHaveBeenCalledWith('NODE_FAVORITE_DIRECTIVE.MESSAGES.NODE_ADDED', null, { name: 'Site' });
|
||||
});
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
import { DocumentListService } from './document-list.service';
|
||||
import { fakeAsync, TestBed } from '@angular/core/testing';
|
||||
import { ContentTestingModule } from '../../testing/content.testing.module';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
@@ -68,7 +69,11 @@ describe('DocumentListService', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ContentTestingModule]
|
||||
imports: [ContentTestingModule],
|
||||
providers: [
|
||||
// TODO: remove this as soon as unit test not using jasmine.Ajax
|
||||
{ provide: AdfHttpClient, useValue: null }
|
||||
]
|
||||
});
|
||||
service = TestBed.inject(DocumentListService);
|
||||
jasmine.Ajax.install();
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable()
|
||||
export class AdfHttpClientMock {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
post(..._args): Promise<unknown> {
|
||||
return Promise.resolve({ success: true, mockData: 'default response' });
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
get(..._args): Promise<unknown> {
|
||||
return Promise.resolve({ success: true, mockData: 'default get response' });
|
||||
}
|
||||
}
|
||||
@@ -17,12 +17,12 @@
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AlfrescoApiService } from '../services/alfresco-api.service';
|
||||
import { AppConfigService, StorageService } from '@alfresco/adf-core';
|
||||
|
||||
@Injectable()
|
||||
export class AlfrescoApiServiceMock extends AlfrescoApiService {
|
||||
constructor(protected appConfig: AppConfigService, protected storageService: StorageService) {
|
||||
super(appConfig, storageService);
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
if (!this.alfrescoApi) {
|
||||
this.initAlfrescoApi();
|
||||
}
|
||||
|
||||
@@ -25,3 +25,4 @@ export * from './search-query.mock';
|
||||
export * from './new-version-uploader.service.mock';
|
||||
export * from './date-range-search-filter.mock';
|
||||
export * from './alfresco-api.service.mock';
|
||||
export * from './adf-http-client.mock';
|
||||
|
||||
@@ -23,6 +23,7 @@ import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||
import { EMPTY, of } from 'rxjs';
|
||||
import { AlfrescoApiService } from '../../services';
|
||||
import { AlfrescoApiServiceMock } from '../../mock';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
@@ -34,7 +35,9 @@ describe('NodeCommentsService', () => {
|
||||
imports: [HttpClientTestingModule],
|
||||
providers: [
|
||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
|
||||
{ provide: RedirectAuthService, useValue: { onLogin: EMPTY, onTokenReceived: of() } }
|
||||
{ provide: RedirectAuthService, useValue: { onLogin: EMPTY, onTokenReceived: of() } },
|
||||
// TODO: remove this as soon as unit test not using jasmine.Ajax
|
||||
{ provide: AdfHttpClient, useValue: null }
|
||||
]
|
||||
});
|
||||
service = TestBed.inject(NodeCommentsService);
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
import { AppConfigService, StorageService } from '@alfresco/adf-core';
|
||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||
|
||||
describe('AlfrescoApiService', () => {
|
||||
let service: AlfrescoApiService;
|
||||
|
||||
beforeEach(() => {
|
||||
const appConfigSpy = jasmine.createSpyObj('AppConfigService', ['get']);
|
||||
const storageSpy = jasmine.createSpyObj('StorageService', ['']);
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [HttpClientTestingModule],
|
||||
providers: [AlfrescoApiService, { provide: AppConfigService, useValue: appConfigSpy }, { provide: StorageService, useValue: storageSpy }]
|
||||
});
|
||||
|
||||
service = TestBed.inject(AlfrescoApiService);
|
||||
|
||||
service['lastConfig'] = {
|
||||
hostBpm: 'http://localhost:8080',
|
||||
contextRootBpm: 'activiti-app'
|
||||
} as any;
|
||||
});
|
||||
|
||||
it('should return true for excluded error URL', () => {
|
||||
const currentFullPath = 'http://localhost:8080/activiti-app/api/enterprise/system/properties';
|
||||
expect(service.isExcludedErrorListener(currentFullPath)).toBeTrue();
|
||||
});
|
||||
|
||||
it('should return false for non-excluded error URL', () => {
|
||||
const currentFullPath = 'http://localhost:8080/activiti-app/api/enterprise/other';
|
||||
expect(service.isExcludedErrorListener(currentFullPath)).toBeFalse();
|
||||
});
|
||||
});
|
||||
@@ -15,11 +15,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Inject, Injectable, InjectionToken, Optional } from '@angular/core';
|
||||
import { inject, Injectable, InjectionToken } from '@angular/core';
|
||||
import { AlfrescoApi, AlfrescoApiConfig } from '@alfresco/js-api';
|
||||
import { ReplaySubject } from 'rxjs';
|
||||
import { AlfrescoApiFactory } from './alfresco-api.interface';
|
||||
import { AppConfigService, AppConfigValues, OauthConfigModel, OpenidConfiguration, StorageService } from '@alfresco/adf-core';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
|
||||
export const ALFRESCO_API_FACTORY = new InjectionToken('ALFRESCO_API_FACTORY');
|
||||
|
||||
@@ -27,7 +28,12 @@ export const ALFRESCO_API_FACTORY = new InjectionToken('ALFRESCO_API_FACTORY');
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class AlfrescoApiService {
|
||||
alfrescoApiInitialized = new ReplaySubject<boolean>(1);
|
||||
protected appConfig = inject(AppConfigService);
|
||||
protected storageService = inject(StorageService);
|
||||
protected alfrescoApiFactory = inject<AlfrescoApiFactory>(ALFRESCO_API_FACTORY, { optional: true });
|
||||
protected adfHttpClient = inject(AdfHttpClient, { optional: true });
|
||||
|
||||
alfrescoApiInitialized: ReplaySubject<boolean> = new ReplaySubject(1);
|
||||
|
||||
protected alfrescoApi: AlfrescoApi;
|
||||
|
||||
@@ -36,20 +42,12 @@ export class AlfrescoApiService {
|
||||
|
||||
idpConfig: OpenidConfiguration;
|
||||
|
||||
private excludedErrorUrl: string[] = ['api/enterprise/system/properties'];
|
||||
private readonly excludedErrorUrl = ['/api/enterprise/system/properties'];
|
||||
|
||||
getInstance(): AlfrescoApi {
|
||||
return this.alfrescoApi;
|
||||
}
|
||||
|
||||
constructor(
|
||||
protected appConfig: AppConfigService,
|
||||
protected storageService: StorageService,
|
||||
@Optional()
|
||||
@Inject(ALFRESCO_API_FACTORY)
|
||||
private alfrescoApiFactory?: AlfrescoApiFactory
|
||||
) {}
|
||||
|
||||
async load(config: AlfrescoApiConfig): Promise<void> {
|
||||
this.currentAppConfig = config;
|
||||
|
||||
@@ -122,15 +120,26 @@ export class AlfrescoApiService {
|
||||
if (this.alfrescoApiFactory) {
|
||||
return this.alfrescoApiFactory.createAlfrescoApi(config);
|
||||
}
|
||||
return new AlfrescoApi(config);
|
||||
|
||||
return new AlfrescoApi(
|
||||
{
|
||||
...config,
|
||||
oauthInit: false
|
||||
},
|
||||
this.adfHttpClient
|
||||
);
|
||||
}
|
||||
|
||||
isDifferentConfig(lastConfig: AlfrescoApiConfig, newConfig: AlfrescoApiConfig) {
|
||||
return JSON.stringify(lastConfig) !== JSON.stringify(newConfig);
|
||||
}
|
||||
|
||||
private formatExcludedPath(path: string): string {
|
||||
return path.replace(this.lastConfig.hostBpm + '/' + this.lastConfig.contextRootBpm, '');
|
||||
}
|
||||
|
||||
isExcludedErrorListener(currentFullPath: string): boolean {
|
||||
const formattedPath = currentFullPath.replace(this.lastConfig.hostBpm + '/' + this.lastConfig.contextRootBpm, '');
|
||||
const formattedPath = this.formatExcludedPath(currentFullPath);
|
||||
return this.excludedErrorUrl.includes(formattedPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,8 @@ import { versionCompatibilityFactory } from '../version-compatibility/version-co
|
||||
import { AlfrescoApiService } from '../services/alfresco-api.service';
|
||||
import { VersionCompatibilityService } from '../version-compatibility/version-compatibility.service';
|
||||
import { MatIconTestingModule } from '@angular/material/icon/testing';
|
||||
import { AlfrescoApiServiceMock } from '../mock';
|
||||
import { AlfrescoApiServiceMock, AdfHttpClientMock } from '../mock';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
|
||||
@NgModule({
|
||||
imports: [NoopAnimationsModule, CoreModule, NoopAuthModule, NoopTranslateModule, ContentModule, MatIconTestingModule],
|
||||
@@ -34,7 +35,8 @@ import { AlfrescoApiServiceMock } from '../mock';
|
||||
useFactory: versionCompatibilityFactory,
|
||||
deps: [VersionCompatibilityService],
|
||||
multi: true
|
||||
}
|
||||
},
|
||||
{ provide: AdfHttpClient, useClass: AdfHttpClientMock }
|
||||
],
|
||||
exports: [NoopAnimationsModule, CoreModule, ContentModule]
|
||||
})
|
||||
|
||||
@@ -208,12 +208,16 @@ describe('VersionListComponent', () => {
|
||||
expect(component.versionsApi.revertVersion).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should load the versions for a given id', () => {
|
||||
it('should load the versions for a given id', async () => {
|
||||
fixture.detectChanges();
|
||||
const spyOnRevertVersion = spyOn(component.versionsApi, 'revertVersion').and.callFake(() => Promise.resolve(versionTest[0]));
|
||||
const spyOnOnVersionRestored = spyOn(component, 'onVersionRestored').and.stub();
|
||||
component.restore(versionId);
|
||||
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(spyOnRevertVersion).toHaveBeenCalledWith(nodeId, versionId, { majorVersion: true, comment: '' });
|
||||
expect(spyOnOnVersionRestored).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should get node info after restoring the node', fakeAsync(() => {
|
||||
|
||||
@@ -18,3 +18,4 @@
|
||||
export * from './lib/types';
|
||||
export * from './lib/adf-http-client.service';
|
||||
export * from './lib/interfaces';
|
||||
export * from './lib/tokens';
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { SHOULD_ADD_AUTH_TOKEN } from '@alfresco/adf-core/auth';
|
||||
import { Emitters as JsApiEmitters, HttpClient as JsApiHttpClient } from '@alfresco/js-api';
|
||||
import { HttpClient, HttpContext, HttpErrorResponse, HttpEvent, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
@@ -35,6 +34,7 @@ import { AlfrescoApiResponseError } from './alfresco-api/alfresco-api.response-e
|
||||
import { Constructor } from './types';
|
||||
import { RequestOptions, SecurityOptions } from './interfaces';
|
||||
import ee, { Emitter } from 'event-emitter';
|
||||
import { SHOULD_ADD_AUTH_TOKEN } from './tokens';
|
||||
|
||||
export interface Emitters {
|
||||
readonly eventEmitter: Emitter;
|
||||
@@ -71,10 +71,21 @@ export class AdfHttpClient implements ee.Emitter, JsApiHttpClient {
|
||||
ee(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the default security options
|
||||
*
|
||||
* @param options security options
|
||||
*/
|
||||
setDefaultSecurityOption(options: any) {
|
||||
this.defaultSecurityOptions = this.merge(this.defaultSecurityOptions, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge objects
|
||||
*
|
||||
* @param objects objects to merge
|
||||
* @returns merged object
|
||||
*/
|
||||
merge(...objects): any {
|
||||
const result = {};
|
||||
|
||||
@@ -94,9 +105,9 @@ export class AdfHttpClient implements ee.Emitter, JsApiHttpClient {
|
||||
}
|
||||
|
||||
request<T = any>(url: string, options?: RequestOptions, sc: SecurityOptions = this.defaultSecurityOptions, emitters?: JsApiEmitters): Promise<T> {
|
||||
const body = AdfHttpClient.getBody(options);
|
||||
const body = this.getBody(options);
|
||||
const params = getQueryParamsWithCustomEncoder(options.queryParams, new AlfrescoApiParamEncoder());
|
||||
const responseType = AdfHttpClient.getResponseType(options);
|
||||
const responseType = this.getResponseType(options);
|
||||
const context = new HttpContext().set(SHOULD_ADD_AUTH_TOKEN, true);
|
||||
const security: SecurityOptions = { ...this.defaultSecurityOptions, ...sc };
|
||||
const headers = this.getHeaders(options);
|
||||
@@ -135,7 +146,7 @@ export class AdfHttpClient implements ee.Emitter, JsApiHttpClient {
|
||||
}
|
||||
|
||||
private addPromiseListeners<T = any>(promise: Promise<T>, eventEmitter: any) {
|
||||
const eventPromise = Object.assign(promise, {
|
||||
return Object.assign(promise, {
|
||||
on() {
|
||||
// eslint-disable-next-line prefer-spread, prefer-rest-params
|
||||
eventEmitter.on.apply(eventEmitter, arguments);
|
||||
@@ -157,8 +168,6 @@ export class AdfHttpClient implements ee.Emitter, JsApiHttpClient {
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
||||
return eventPromise;
|
||||
}
|
||||
|
||||
private getEventEmitters(): Emitters {
|
||||
@@ -189,7 +198,7 @@ export class AdfHttpClient implements ee.Emitter, JsApiHttpClient {
|
||||
|
||||
if (isHttpResponseEvent(res)) {
|
||||
eventEmitter.emit('success', res.body);
|
||||
return AdfHttpClient.deserialize(res, returnType);
|
||||
return this.deserialize(res, returnType);
|
||||
}
|
||||
}),
|
||||
catchError((err: HttpErrorResponse): Observable<AlfrescoApiResponseError> => {
|
||||
@@ -222,12 +231,13 @@ export class AdfHttpClient implements ee.Emitter, JsApiHttpClient {
|
||||
};
|
||||
|
||||
const alfrescoApiError = new AlfrescoApiResponseError(msg, err.status, error);
|
||||
return throwError(alfrescoApiError);
|
||||
return throwError(() => alfrescoApiError);
|
||||
}),
|
||||
takeUntil(abort$)
|
||||
)
|
||||
.toPromise();
|
||||
|
||||
/* eslint-disable @typescript-eslint/space-before-function-paren */
|
||||
(promise as any).abort = function () {
|
||||
eventEmitter.emit('abort');
|
||||
abort$.next();
|
||||
@@ -238,8 +248,8 @@ export class AdfHttpClient implements ee.Emitter, JsApiHttpClient {
|
||||
return this.addPromiseListeners(promise, eventEmitter);
|
||||
}
|
||||
|
||||
private static getBody(options: RequestOptions): any {
|
||||
const contentType = options.contentType ? options.contentType : AdfHttpClient.jsonPreferredMime(options.contentTypes);
|
||||
private getBody(options: RequestOptions): any {
|
||||
const contentType = options.contentType ? options.contentType : this.jsonPreferredMime(options.contentTypes);
|
||||
const isFormData = contentType === 'multipart/form-data';
|
||||
const isFormUrlEncoded = contentType === 'application/x-www-form-urlencoded';
|
||||
const body = options.bodyParam;
|
||||
@@ -256,8 +266,8 @@ export class AdfHttpClient implements ee.Emitter, JsApiHttpClient {
|
||||
}
|
||||
|
||||
private getHeaders(options: RequestOptions): HttpHeaders {
|
||||
const contentType = options.contentType || AdfHttpClient.jsonPreferredMime(options.contentTypes);
|
||||
const accept = options.accept || AdfHttpClient.jsonPreferredMime(options.accepts);
|
||||
const contentType = options.contentType || this.jsonPreferredMime(options.contentTypes);
|
||||
const accept = options.accept || this.jsonPreferredMime(options.accepts);
|
||||
|
||||
const optionsHeaders = {
|
||||
...options.headerParams,
|
||||
@@ -278,13 +288,13 @@ export class AdfHttpClient implements ee.Emitter, JsApiHttpClient {
|
||||
* @param contentTypes a contentType array
|
||||
* @returns The chosen content type, preferring JSON.
|
||||
*/
|
||||
private static jsonPreferredMime(contentTypes: readonly string[]): string {
|
||||
private jsonPreferredMime(contentTypes: readonly string[]): string {
|
||||
if (!contentTypes?.length) {
|
||||
return 'application/json';
|
||||
}
|
||||
|
||||
for (let i = 0; i < contentTypes.length; i++) {
|
||||
if (AdfHttpClient.isJsonMime(contentTypes[i])) {
|
||||
if (this.isJsonMime(contentTypes[i])) {
|
||||
return contentTypes[i];
|
||||
}
|
||||
}
|
||||
@@ -303,7 +313,7 @@ export class AdfHttpClient implements ee.Emitter, JsApiHttpClient {
|
||||
* @param contentType The MIME content type to check.
|
||||
* @returns <code>true</code> if <code>contentType</code> represents JSON, otherwise <code>false</code>.
|
||||
*/
|
||||
private static isJsonMime(contentType: string): boolean {
|
||||
private isJsonMime(contentType: string): boolean {
|
||||
return Boolean(contentType?.match(/^application\/json(;.*)?$/i));
|
||||
}
|
||||
|
||||
@@ -319,16 +329,18 @@ export class AdfHttpClient implements ee.Emitter, JsApiHttpClient {
|
||||
}
|
||||
|
||||
private createCSRFToken(a?: any): string {
|
||||
const randomValue = AdfHttpClient.getSecureRandomValue();
|
||||
return a ? (a ^ ((randomValue * 16) >> (a / 4))).toString(16) : ([1e16] + (1e16).toString()).replace(/[01]/g, this.createCSRFToken);
|
||||
const randomValue = this.getSecureRandomValue();
|
||||
return a
|
||||
? (a ^ ((randomValue * 16) >> (a / 4))).toString(16)
|
||||
: ([1e16] + (1e16).toString()).replace(/[01]/g, this.createCSRFToken.bind(this));
|
||||
}
|
||||
|
||||
private static getSecureRandomValue(): number {
|
||||
private getSecureRandomValue(): number {
|
||||
const max = Math.pow(2, 32);
|
||||
return window.crypto.getRandomValues(new Uint32Array(1))[0] / max;
|
||||
}
|
||||
|
||||
private static getResponseType(options: RequestOptions): 'blob' | 'json' | 'text' {
|
||||
private getResponseType(options: RequestOptions): 'blob' | 'json' | 'text' {
|
||||
const isBlobType = options.returnType?.toString().toLowerCase() === 'blob' || options.responseType?.toString().toLowerCase() === 'blob';
|
||||
|
||||
if (isBlobType) {
|
||||
@@ -349,7 +361,7 @@ export class AdfHttpClient implements ee.Emitter, JsApiHttpClient {
|
||||
* @param returnType return type
|
||||
* @returns deserialized object
|
||||
*/
|
||||
private static deserialize<T>(response: HttpResponse<T>, returnType?: Constructor<unknown> | 'blob'): any {
|
||||
private deserialize<T>(response: HttpResponse<T>, returnType?: Constructor<unknown> | 'blob'): any {
|
||||
if (response === null) {
|
||||
return null;
|
||||
}
|
||||
@@ -366,7 +378,7 @@ export class AdfHttpClient implements ee.Emitter, JsApiHttpClient {
|
||||
}
|
||||
|
||||
if (isBlobResponse(response, returnType)) {
|
||||
return AdfHttpClient.deserializeBlobResponse(response);
|
||||
return this.deserializeBlobResponse(response);
|
||||
}
|
||||
|
||||
if (!isConstructor(returnType)) {
|
||||
@@ -380,7 +392,7 @@ export class AdfHttpClient implements ee.Emitter, JsApiHttpClient {
|
||||
return new returnType(body);
|
||||
}
|
||||
|
||||
private static deserializeBlobResponse(response: HttpResponse<Blob>) {
|
||||
private deserializeBlobResponse(response: HttpResponse<Blob>) {
|
||||
return new Blob([response.body], { type: response.headers.get('Content-Type') });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,5 +15,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export * from './authentication';
|
||||
export * from './authentication-interceptor/authentication.interceptor';
|
||||
import { HttpContextToken } from '@angular/common/http';
|
||||
|
||||
export const SHOULD_ADD_AUTH_TOKEN = new HttpContextToken<boolean>(() => false);
|
||||
@@ -1,3 +0,0 @@
|
||||
# @alfresco/adf-core/auth
|
||||
|
||||
Secondary entry point of `@alfresco/adf-core`. It can be used by importing from `@alfresco/adf-core/auth`.
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"lib": {
|
||||
"entryFile": "src/index.ts"
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
# AuthenticationInterceptor
|
||||
|
||||
This interceptor is responsible for providing authentication to angular HttpClient requests when a context `SHOULD_ADD_AUTH_TOKEN` is set to true.
|
||||
By default, the interceptor won't do anything to the intercepted request.
|
||||
|
||||
## Usage
|
||||
|
||||
```typescript
|
||||
import { SHOULD_ADD_AUTH_TOKEN } from '@alfresco/adf-core/auth';
|
||||
import { HttpClient, HttpContext } from '@angular/common/http';
|
||||
|
||||
getSth() {
|
||||
return this.httpClient.get('http://example.com', { context: new HttpContext().set(SHOULD_ADD_AUTH_TOKEN, true)});
|
||||
}
|
||||
|
||||
// or
|
||||
|
||||
getSth() {
|
||||
const someRequest = this.httpClient.get('GET', 'http://example.com');
|
||||
someRequest.context.set(SHOULD_ADD_AUTH_TOKEN, true);
|
||||
|
||||
return someRequest;
|
||||
}
|
||||
|
||||
```
|
||||
@@ -18,8 +18,9 @@
|
||||
import { HttpHandler, HttpHeaders, HttpRequest } from '@angular/common/http';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { Authentication } from '../authentication';
|
||||
|
||||
import { AuthenticationInterceptor, SHOULD_ADD_AUTH_TOKEN } from './authentication.interceptor';
|
||||
import { Authentication } from '@alfresco/adf-core';
|
||||
|
||||
class MockAuthentication extends Authentication {
|
||||
addTokenToHeader(_: string, httpHeaders: HttpHeaders): Observable<HttpHeaders> {
|
||||
|
||||
@@ -30,13 +30,13 @@ import {
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable, throwError as observableThrowError } from 'rxjs';
|
||||
import { catchError, mergeMap } from 'rxjs/operators';
|
||||
import { Authentication } from '../authentication';
|
||||
import { Authentication } from '@alfresco/adf-core';
|
||||
|
||||
export const SHOULD_ADD_AUTH_TOKEN = new HttpContextToken<boolean>(() => false);
|
||||
|
||||
@Injectable()
|
||||
export class AuthenticationInterceptor implements HttpInterceptor {
|
||||
constructor(private authService: Authentication) {}
|
||||
constructor(private readonly authService: Authentication) {}
|
||||
|
||||
intercept(
|
||||
req: HttpRequest<any>,
|
||||
|
||||
@@ -16,4 +16,3 @@
|
||||
*/
|
||||
|
||||
export * from './src/public-api';
|
||||
export * from './api/src/index';
|
||||
|
||||
@@ -77,17 +77,14 @@ export class AppConfigService {
|
||||
};
|
||||
|
||||
status: Status = Status.INIT;
|
||||
protected onLoadSubject: ReplaySubject<any>;
|
||||
onLoad: Observable<any>;
|
||||
protected readonly onLoadSubject = new ReplaySubject<any>();
|
||||
onLoad = this.onLoadSubject.asObservable();
|
||||
|
||||
get isLoaded() {
|
||||
return this.status === Status.LOADED;
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.onLoadSubject = new ReplaySubject();
|
||||
this.onLoad = this.onLoadSubject.asObservable();
|
||||
|
||||
this.extensionService.setup$.subscribe((config) => {
|
||||
this.onExtensionsLoaded(config);
|
||||
});
|
||||
|
||||
@@ -15,15 +15,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { inject, Injectable } from '@angular/core';
|
||||
import { StorageService } from '../common/services/storage.service';
|
||||
import { AppConfigService, AppConfigValues } from './app-config.service';
|
||||
|
||||
@Injectable()
|
||||
export class DebugAppConfigService extends AppConfigService {
|
||||
constructor(private storage: StorageService) {
|
||||
super();
|
||||
}
|
||||
private readonly storage = inject(StorageService);
|
||||
|
||||
get<T>(key: string, defaultValue?: T): T {
|
||||
if (key === AppConfigValues.OAUTHCONFIG) {
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
|
||||
export * from './app-config.service';
|
||||
export * from './debug-app-config.service';
|
||||
export * from './app-config.pipe';
|
||||
export * from './app-config-storage-prefix.factory';
|
||||
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { HttpHandler, HttpHeaders, HttpRequest } from '@angular/common/http';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { Authentication } from '../authentication';
|
||||
import { AuthenticationInterceptor } from './authentication.interceptor';
|
||||
import { SHOULD_ADD_AUTH_TOKEN } from '@alfresco/adf-core/api';
|
||||
|
||||
class MockAuthentication extends Authentication {
|
||||
addTokenToHeader(_: string, httpHeaders: HttpHeaders): Observable<HttpHeaders> {
|
||||
return of(httpHeaders);
|
||||
}
|
||||
}
|
||||
|
||||
const mockNext: HttpHandler = {
|
||||
handle: () =>
|
||||
new Observable((subscriber) => {
|
||||
subscriber.complete();
|
||||
})
|
||||
};
|
||||
|
||||
const request = new HttpRequest('GET', 'http://localhost:4200');
|
||||
|
||||
describe('AuthenticationInterceptor', () => {
|
||||
let interceptor: AuthenticationInterceptor;
|
||||
let addTokenToHeaderSpy: jasmine.Spy<any>;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [AuthenticationInterceptor, { provide: Authentication, useClass: MockAuthentication }]
|
||||
});
|
||||
interceptor = TestBed.inject(AuthenticationInterceptor);
|
||||
addTokenToHeaderSpy = spyOn(interceptor['authService'], 'addTokenToHeader');
|
||||
});
|
||||
|
||||
it('should call add auth token method when SHOULD_ADD_AUTH_TOKEN context is set to true', () => {
|
||||
addTokenToHeaderSpy.and.callThrough();
|
||||
request.context.set(SHOULD_ADD_AUTH_TOKEN, true);
|
||||
interceptor.intercept(request, mockNext);
|
||||
expect(addTokenToHeaderSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not call add auth token method when SHOULD_ADD_AUTH_TOKEN context is set to false', () => {
|
||||
request.context.set(SHOULD_ADD_AUTH_TOKEN, false);
|
||||
interceptor.intercept(request, mockNext);
|
||||
expect(addTokenToHeaderSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not call add auth token method when SHOULD_ADD_AUTH_TOKEN context is not provided', () => {
|
||||
interceptor.intercept(request, mockNext);
|
||||
expect(addTokenToHeaderSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,70 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {
|
||||
HttpHandler,
|
||||
HttpHeaderResponse,
|
||||
HttpHeaders,
|
||||
HttpInterceptor,
|
||||
HttpProgressEvent,
|
||||
HttpRequest,
|
||||
HttpResponse,
|
||||
HttpSentEvent,
|
||||
HttpUserEvent
|
||||
} from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable, throwError as observableThrowError } from 'rxjs';
|
||||
import { catchError, mergeMap } from 'rxjs/operators';
|
||||
import { Authentication } from '../authentication';
|
||||
import { SHOULD_ADD_AUTH_TOKEN } from '@alfresco/adf-core/api';
|
||||
|
||||
@Injectable()
|
||||
export class AuthenticationInterceptor implements HttpInterceptor {
|
||||
constructor(private readonly authService: Authentication) {}
|
||||
|
||||
intercept(
|
||||
req: HttpRequest<any>,
|
||||
next: HttpHandler
|
||||
): Observable<HttpSentEvent | HttpHeaderResponse | HttpProgressEvent | HttpResponse<any> | HttpUserEvent<any>> {
|
||||
if (req.context.get(SHOULD_ADD_AUTH_TOKEN)) {
|
||||
return this.authService.addTokenToHeader(req.url, req.headers).pipe(
|
||||
mergeMap((headersWithBearer) => {
|
||||
const headerWithContentType = this.appendJsonContentType(headersWithBearer);
|
||||
const kcReq = req.clone({ headers: headerWithContentType });
|
||||
return next.handle(kcReq).pipe(catchError((error) => observableThrowError(error)));
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
return next.handle(req).pipe(catchError((error) => observableThrowError(error)));
|
||||
}
|
||||
|
||||
private appendJsonContentType(headers: HttpHeaders): HttpHeaders {
|
||||
// prevent adding any content type, to properly handle formData with boundary browser generated value,
|
||||
// as adding any Content-Type its going to break the upload functionality
|
||||
|
||||
if (headers.get('Content-Type') === 'multipart/form-data') {
|
||||
return headers.delete('Content-Type');
|
||||
}
|
||||
|
||||
if (!headers.get('Content-Type')) {
|
||||
return headers.set('Content-Type', 'application/json;charset=UTF-8');
|
||||
}
|
||||
|
||||
return headers;
|
||||
}
|
||||
}
|
||||
@@ -15,8 +15,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export * from './authentication';
|
||||
export * from './authentication-interceptor/auth-bearer.interceptor';
|
||||
|
||||
export * from './authentication-interceptor/authentication.interceptor';
|
||||
export * from './guard/auth-guard.service';
|
||||
export * from './guard/auth-guard';
|
||||
export * from './guard/auth-guard-ecm.service';
|
||||
|
||||
@@ -39,8 +39,8 @@ import { CORE_DIRECTIVES } from './directives/directive.module';
|
||||
import { CORE_PIPES } from './pipes/pipe.module';
|
||||
import { TranslateLoaderService } from './translation/translate-loader.service';
|
||||
import { SEARCH_TEXT_INPUT_DIRECTIVES } from './search-text/search-text-input.module';
|
||||
import { AuthenticationInterceptor, Authentication } from '@alfresco/adf-core/auth';
|
||||
import { HTTP_INTERCEPTORS, HttpClient, provideHttpClient, withXsrfConfiguration, withInterceptorsFromDi } from '@angular/common/http';
|
||||
import { AuthenticationInterceptor, Authentication } from './auth';
|
||||
import { AuthenticationService } from './auth/services/authentication.service';
|
||||
import { MAT_SNACK_BAR_DEFAULT_OPTIONS } from '@angular/material/snack-bar';
|
||||
import { AppConfigPipe } from './app-config';
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
"paths": {
|
||||
"@alfresco/adf-extensions": ["../../../dist/libs/extensions"],
|
||||
"@alfresco/adf-extensions/*": ["../../../dist/libs/extensions/*"],
|
||||
"@alfresco/adf-core/auth": ["../auth/src/index.ts"],
|
||||
"@alfresco/adf-core/shell": ["../shell/src/index.ts"],
|
||||
"@alfresco/adf-core/api": ["../api/src/index.ts"],
|
||||
"@alfresco/adf-core/feature-flags": ["../feature-flags/src/index.ts"],
|
||||
|
||||
@@ -17,16 +17,17 @@
|
||||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { AppConfigService, AppConfigServiceMock, AuthModule, JWT_STORAGE_SERVICE, NoopTranslateModule, StorageService } from '@alfresco/adf-core';
|
||||
import { AppConfigService, AppConfigServiceMock, AuthModule, NoopTranslateModule } from '@alfresco/adf-core';
|
||||
import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services';
|
||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
|
||||
@NgModule({
|
||||
imports: [AuthModule.forRoot({ useHash: true }), NoopAnimationsModule, NoopTranslateModule, HttpClientTestingModule],
|
||||
imports: [AuthModule.forRoot({ useHash: true }), NoopAnimationsModule, NoopTranslateModule],
|
||||
providers: [
|
||||
{ provide: JWT_STORAGE_SERVICE, useClass: StorageService },
|
||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
|
||||
{ provide: AppConfigService, useClass: AppConfigServiceMock }
|
||||
{ provide: AppConfigService, useClass: AppConfigServiceMock },
|
||||
// TODO: remove this as soon as unit test not using jasmine.Ajax
|
||||
{ provide: AdfHttpClient, useValue: null }
|
||||
],
|
||||
exports: [NoopAnimationsModule]
|
||||
})
|
||||
|
||||
+6
-1
@@ -19,6 +19,7 @@ import { SimpleChange } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { CreateProcessAttachmentComponent } from './create-process-attachment.component';
|
||||
import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
@@ -48,7 +49,11 @@ describe('CreateProcessAttachmentComponent', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CreateProcessAttachmentComponent],
|
||||
providers: [{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }]
|
||||
providers: [
|
||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
|
||||
// TODO: remove this as soon as unit test not using jasmine.Ajax
|
||||
{ provide: AdfHttpClient, useValue: null }
|
||||
]
|
||||
});
|
||||
fixture = TestBed.createComponent(CreateProcessAttachmentComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
||||
@@ -20,6 +20,7 @@ import { FormModel } from '@alfresco/adf-core';
|
||||
import { EcmModelService } from './ecm-model.service';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
@@ -29,7 +30,11 @@ describe('EcmModelService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [],
|
||||
providers: [{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }]
|
||||
providers: [
|
||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
|
||||
// TODO: remove this as soon as unit test not using jasmine.Ajax
|
||||
{ provide: AdfHttpClient, useValue: null }
|
||||
]
|
||||
});
|
||||
service = TestBed.inject(EcmModelService);
|
||||
jasmine.Ajax.install();
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { ProcessContentService } from './process-content.service';
|
||||
import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
@@ -66,7 +67,11 @@ describe('ProcessContentService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [],
|
||||
providers: [{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }]
|
||||
providers: [
|
||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
|
||||
// TODO: remove this as soon as unit test not using jasmine.Ajax
|
||||
{ provide: AdfHttpClient, useValue: null }
|
||||
]
|
||||
});
|
||||
service = TestBed.inject(ProcessContentService);
|
||||
});
|
||||
|
||||
@@ -23,6 +23,7 @@ import { of } from 'rxjs';
|
||||
import { ContentWidgetComponent } from './content.widget';
|
||||
import { ProcessContentService } from '../../services/process-content.service';
|
||||
import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
@@ -61,7 +62,11 @@ describe('ContentWidgetComponent', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ContentWidgetComponent],
|
||||
providers: [{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }]
|
||||
providers: [
|
||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
|
||||
// TODO: remove this as soon as unit test not using jasmine.Ajax
|
||||
{ provide: AdfHttpClient, useValue: null }
|
||||
]
|
||||
});
|
||||
downloadService = TestBed.inject(DownloadService);
|
||||
processContentService = TestBed.inject(ProcessContentService);
|
||||
|
||||
+6
-1
@@ -19,6 +19,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { of } from 'rxjs';
|
||||
import { PeopleSearchComponent } from './people-search.component';
|
||||
import { LightUserRepresentation } from '@alfresco/js-api';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
|
||||
const fakeUser: LightUserRepresentation = {
|
||||
id: 1,
|
||||
@@ -43,7 +44,11 @@ describe('PeopleSearchComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [PeopleSearchComponent]
|
||||
imports: [PeopleSearchComponent],
|
||||
providers: [
|
||||
// TODO: remove this as soon as unit test not using jasmine.Ajax
|
||||
{ provide: AdfHttpClient, useValue: null }
|
||||
]
|
||||
});
|
||||
fixture = TestBed.createComponent(PeopleSearchComponent);
|
||||
peopleSearchComponent = fixture.componentInstance;
|
||||
|
||||
@@ -18,8 +18,9 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { PeopleComponent } from './people.component';
|
||||
import { LightUserRepresentation } from '@alfresco/js-api';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
import { of, throwError } from 'rxjs';
|
||||
import { PeopleProcessService } from '../../../services/people-process.service';
|
||||
import { PeopleProcessService } from '@alfresco/adf-process-services';
|
||||
|
||||
const fakeUser: LightUserRepresentation = {
|
||||
id: 0,
|
||||
@@ -44,7 +45,11 @@ describe('PeopleComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [PeopleComponent]
|
||||
imports: [PeopleComponent],
|
||||
providers: [
|
||||
// TODO: remove this as soon as unit test not using jasmine.Ajax
|
||||
{ provide: AdfHttpClient, useValue: null }
|
||||
]
|
||||
});
|
||||
fixture = TestBed.createComponent(PeopleComponent);
|
||||
peopleProcessService = fixture.debugElement.injector.get(PeopleProcessService);
|
||||
|
||||
@@ -20,6 +20,7 @@ import { ProcessFilterService } from './process-filter.service';
|
||||
import { ProcessInstanceFilterRepresentation, UserProcessInstanceFilterRepresentation } from '@alfresco/js-api';
|
||||
import { of } from 'rxjs';
|
||||
import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
@@ -49,7 +50,12 @@ describe('Process filter', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }]
|
||||
imports: [],
|
||||
providers: [
|
||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
|
||||
// TODO: remove this as soon as unit test not using jasmine.Ajax
|
||||
{ provide: AdfHttpClient, useValue: null }
|
||||
]
|
||||
});
|
||||
service = TestBed.inject(ProcessFilterService);
|
||||
});
|
||||
|
||||
@@ -19,6 +19,7 @@ import { fakeAsync, TestBed } from '@angular/core/testing';
|
||||
import { PeopleProcessService } from './people-process.service';
|
||||
import { LightUserRepresentation } from '@alfresco/js-api';
|
||||
import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
@@ -45,7 +46,12 @@ describe('PeopleProcessService', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }]
|
||||
imports: [],
|
||||
providers: [
|
||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
|
||||
// TODO: remove this as soon as unit test not using jasmine.Ajax
|
||||
{ provide: AdfHttpClient, useValue: null }
|
||||
]
|
||||
});
|
||||
service = TestBed.inject(PeopleProcessService);
|
||||
});
|
||||
|
||||
+4
-1
@@ -41,6 +41,7 @@ import { MatCheckboxHarness } from '@angular/material/checkbox/testing';
|
||||
import { MatMenuItemHarness } from '@angular/material/menu/testing';
|
||||
import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { AdfHttpClient } from '@alfresco/adf-core/api';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
@@ -109,7 +110,9 @@ describe('TaskListComponent', () => {
|
||||
providers: [
|
||||
TaskListService,
|
||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
|
||||
{ provide: AppConfigService, useClass: AppConfigServiceMock }
|
||||
{ provide: AppConfigService, useClass: AppConfigServiceMock },
|
||||
// TODO: remove this as soon as unit test not using jasmine.Ajax
|
||||
{ provide: AdfHttpClient, useValue: null }
|
||||
]
|
||||
});
|
||||
appConfig = TestBed.inject(AppConfigService);
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
"@alfresco/adf-core": ["lib/core/src/public-api.ts"],
|
||||
"@alfresco/adf-core/*": ["lib/core/*/public-api.ts"],
|
||||
"@alfresco/adf-core/api": ["lib/core/api/src/index.ts"],
|
||||
"@alfresco/adf-core/auth": ["lib/core/auth/src/index.ts"],
|
||||
"@alfresco/adf-core/breadcrumbs": ["lib/core/breadcrumbs/src/index.ts"],
|
||||
"@alfresco/adf-core/feature-flags": ["lib/core/feature-flags/public-api.ts"],
|
||||
"@alfresco/adf-core/shell": ["lib/core/shell/src/index.ts"],
|
||||
|
||||
Reference in New Issue
Block a user