Skip to content

Commit

Permalink
[affected:*][ci:force] - REBASED
Browse files Browse the repository at this point in the history
  • Loading branch information
VitoAlbano committed Jul 9, 2024
1 parent e859e16 commit f09fe70
Show file tree
Hide file tree
Showing 35 changed files with 360 additions and 236 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { CoreTestingModule, IdentityUserModel, InitialUsernamePipe, UserInfoMode } from '@alfresco/adf-core';
import { IdentityUserModel, InitialUsernamePipe, UserInfoMode } from '@alfresco/adf-core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MatMenuModule } from '@angular/material/menu';
import { By, DomSanitizer } from '@angular/platform-browser';
Expand Down Expand Up @@ -119,7 +119,7 @@ describe('ContentUserInfoComponent', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [CoreTestingModule, ContentTestingModule, MatMenuModule]
imports: [ContentTestingModule, MatMenuModule]
});
fixture = TestBed.createComponent(ContentUserInfoComponent);
component = fixture.componentInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { AspectEntry, Node } from '@alfresco/js-api';
import { NodesApiService } from '../common/services/nodes-api.service';
import { By } from '@angular/platform-browser';
import { AspectListComponent } from './aspect-list.component';
import { HttpClientTestingModule } from '@angular/common/http/testing';

const aspectListMock: AspectEntry[] = [
{
Expand Down Expand Up @@ -113,7 +114,7 @@ describe('AspectListDialogComponent', () => {
excludedAspects: []
};
await TestBed.configureTestingModule({
imports: [ContentTestingModule, MatDialogModule],
imports: [HttpClientTestingModule, ContentTestingModule, MatDialogModule],
providers: [
{ provide: MAT_DIALOG_DATA, useValue: data },
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,29 @@
*/

import { TestBed } from '@angular/core/testing';
import { AlfrescoApiService, CoreTestingModule } from '@alfresco/adf-core';
import { AlfrescoApiService } from '@alfresco/adf-core';
import { AspectListService } from './aspect-list.service';
import { AspectPaging, AspectsApi, AspectEntry } from '@alfresco/js-api';
import { HttpClientTestingModule } from '@angular/common/http/testing';

const stdAspect1: AspectEntry = { entry: { id: 'std:standardAspectOne', description: 'Standard Aspect One', title: 'StandardAspectOne' } };
const stdAspect2: AspectEntry = { entry: { id: 'std:standardAspectTwo', description: 'Standard Aspect Two', title: 'StandardAspectTwo' } };
const stdAspect3: AspectEntry = { entry: { id: 'std:standardAspectThree', description: 'Standard Aspect Three', title: 'StandardAspectThree' } };
const standardAspectPagingMock: AspectPaging = { list: { entries: [ stdAspect1, stdAspect2, stdAspect3 ] } };
const standardAspectPagingMock: AspectPaging = { list: { entries: [stdAspect1, stdAspect2, stdAspect3] } };

const cstAspect1: AspectEntry = { entry: { id: 'cst:customAspectOne', description: 'Custom Aspect One', title: 'CustomAspectOne' } };
const cstAspect2: AspectEntry = { entry: { id: 'cst:customAspectTwo', description: 'Custom Aspect Two', title: 'CustomAspectTwo' } };
const cstAspect3: AspectEntry = { entry: { id: 'cst:customAspectThree', description: 'Custom Aspect Three', title: 'CustomAspectThree' } };
const customAspectPagingMock: AspectPaging = { list: { entries: [ cstAspect1, cstAspect2, cstAspect3 ] } };
const customAspectPagingMock: AspectPaging = { list: { entries: [cstAspect1, cstAspect2, cstAspect3] } };

describe('AspectListService', () => {

let aspectListService: AspectListService;
let apiService: AlfrescoApiService;
let aspectsApi: AspectsApi;

beforeEach(() => {
TestBed.configureTestingModule({
imports: [
CoreTestingModule
]
imports: [HttpClientTestingModule]
});

aspectListService = TestBed.inject(AspectListService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* limitations under the License.
*/

import { CoreTestingModule } from '@alfresco/adf-core';
import { fakeAsync, TestBed } from '@angular/core/testing';
import { CategoryService } from '../services/category.service';
import { CategoryNode, CategoryTreeDatasourceService } from '@alfresco/adf-content-services';
Expand All @@ -25,17 +24,12 @@ import { EMPTY, of } from 'rxjs';
import { Pagination } from '@alfresco/js-api';

describe('CategoryTreeDatasourceService', () => {
let categoryTreeDatasourceService: CategoryTreeDatasourceService;
let categoryService: CategoryService;
let categoryTreeDatasourceService: CategoryTreeDatasourceService;
let categoryService: CategoryService;

beforeEach(() => {
TestBed.configureTestingModule({
imports: [
CoreTestingModule
],
providers: [
{ provide: CategoryService, useClass: CategoryServiceMock }
]
providers: [CategoryTreeDatasourceService, { provide: CategoryService, useClass: CategoryServiceMock }]
});

categoryTreeDatasourceService = TestBed.inject(CategoryTreeDatasourceService);
Expand All @@ -44,7 +38,7 @@ describe('CategoryTreeDatasourceService', () => {

it('should get root level categories', fakeAsync(() => {
spyOn(categoryTreeDatasourceService, 'getParentNode').and.returnValue(undefined);
categoryTreeDatasourceService.getSubNodes(null, 0 , 100).subscribe((treeResponse: TreeResponse<CategoryNode>) => {
categoryTreeDatasourceService.getSubNodes(null, 0, 100).subscribe((treeResponse: TreeResponse<CategoryNode>) => {
expect(treeResponse.entries.length).toBe(1);
expect(treeResponse.entries[0].level).toBe(0);
expect(treeResponse.entries[0].nodeType).toBe(TreeNodeType.RegularNode);
Expand All @@ -62,7 +56,7 @@ describe('CategoryTreeDatasourceService', () => {
nodeType: TreeNodeType.RegularNode
};
spyOn(categoryTreeDatasourceService, 'getParentNode').and.returnValue(parentNode);
categoryTreeDatasourceService.getSubNodes(parentNode.id, 0 , 100).subscribe((treeResponse: TreeResponse<CategoryNode>) => {
categoryTreeDatasourceService.getSubNodes(parentNode.id, 0, 100).subscribe((treeResponse: TreeResponse<CategoryNode>) => {
expect(treeResponse.entries.length).toBe(2);
expect(treeResponse.entries[0].parentId).toBe(parentNode.id);
expect(treeResponse.entries[0].level).toBe(1);
Expand All @@ -84,7 +78,8 @@ describe('CategoryTreeDatasourceService', () => {
});

it('should call getCategory for every instance if value of name parameter is defined', (done) => {
spyOn(categoryService, 'getCategory').and.returnValues(of({
spyOn(categoryService, 'getCategory').and.returnValues(
of({
entry: {
name: 'name',
id: 'some id 1',
Expand All @@ -97,18 +92,18 @@ describe('CategoryTreeDatasourceService', () => {
id: 'some id 2',
hasChildren: false
}
}));
categoryTreeDatasourceService.getSubNodes('id', undefined, undefined, 'name')
.subscribe(() => {

expect(categoryService.getCategory).toHaveBeenCalledWith('some id 1');
expect(categoryService.getCategory).toHaveBeenCalledWith('some id 2');
done();
});
})
);
categoryTreeDatasourceService.getSubNodes('id', undefined, undefined, 'name').subscribe(() => {
expect(categoryService.getCategory).toHaveBeenCalledWith('some id 1');
expect(categoryService.getCategory).toHaveBeenCalledWith('some id 2');
done();
});
});

it('should return observable which emits correct categories', (done) => {
spyOn(categoryService, 'getCategory').and.returnValues(of({
spyOn(categoryService, 'getCategory').and.returnValues(
of({
entry: {
name: 'some name',
id: 'some id 1',
Expand All @@ -121,32 +116,35 @@ describe('CategoryTreeDatasourceService', () => {
id: 'some id 2',
hasChildren: false
}
}));
categoryTreeDatasourceService.getSubNodes('id', undefined, undefined, 'name')
.subscribe((response) => {
const pagination = new Pagination();
pagination.count = 2;
expect(response).toEqual({
pagination,
entries: [{
})
);
categoryTreeDatasourceService.getSubNodes('id', undefined, undefined, 'name').subscribe((response) => {
const pagination = new Pagination();
pagination.count = 2;
expect(response).toEqual({
pagination,
entries: [
{
id: 'some id 1',
nodeName: 'some name',
parentId: 'parent id 1',
level: 0,
nodeType: TreeNodeType.RegularNode,
hasChildren: true,
isLoading: false
}, {
},
{
id: 'some id 2',
nodeName: 'Language/some other name',
parentId: 'parent id 2',
level: 0,
nodeType: TreeNodeType.RegularNode,
hasChildren: false,
isLoading: false
}]
});
done();
}
]
});
done();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { AppConfigService, CoreTestingModule, UserPreferencesService } from '@alfresco/adf-core';
import { AppConfigService, TranslationMock, TranslationService, UserPreferencesService } from '@alfresco/adf-core';
import {
CategoryBody,
CategoryEntry,
Expand All @@ -29,6 +29,8 @@ import {
} from '@alfresco/js-api';
import { fakeAsync, TestBed } from '@angular/core/testing';
import { CategoryService } from './category.service';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { TranslateModule } from '@ngx-translate/core';

describe('CategoryService', () => {
let categoryService: CategoryService;
Expand All @@ -44,7 +46,8 @@ describe('CategoryService', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [CoreTestingModule]
imports: [HttpClientTestingModule, TranslateModule.forRoot()],
providers: [CategoryService, UserPreferencesService, { provide: TranslationService, useClass: TranslationMock }]
});

categoryService = TestBed.inject(CategoryService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@

import { TestBed } from '@angular/core/testing';
import { ContentService } from './content.service';
import { AppConfigService, AuthenticationService, StorageService, CoreTestingModule } from '@alfresco/adf-core';
import { AppConfigService, AuthenticationService, RedirectAuthService, StorageService } from '@alfresco/adf-core';
import { Node, PermissionsInfo } from '@alfresco/js-api';
import { EMPTY } from 'rxjs';
import { HttpClientTestingModule } from '@angular/common/http/testing';

describe('ContentService', () => {
let contentService: ContentService;
Expand All @@ -27,7 +29,8 @@ describe('ContentService', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [CoreTestingModule]
imports: [HttpClientTestingModule],
providers: [ContentService, AuthenticationService, { provide: RedirectAuthService, useValue: { onLogin: EMPTY } }]
});
authService = TestBed.inject(AuthenticationService);
contentService = TestBed.inject(ContentService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,12 @@ describe('PeopleContentService', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [CoreTestingModule],
providers: [{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }]
imports: [HttpClientTestingModule],
providers: [
PeopleContentService,
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
{ provide: RedirectAuthService, useValue: { onLogin: EMPTY } }
]
});

peopleContentService = TestBed.inject(PeopleContentService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import { EventEmitter } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { AppConfigService, CoreTestingModule } from '@alfresco/adf-core';
import { AlfrescoApiService, AlfrescoApiServiceMock, AppConfigModule, AppConfigService } from '@alfresco/adf-core';
import { UploadService } from './upload.service';
import { RepositoryInfo } from '@alfresco/js-api';
import { BehaviorSubject } from 'rxjs';
Expand All @@ -35,8 +35,10 @@ describe('UploadService', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [CoreTestingModule],
imports: [AppConfigModule],
providers: [
UploadService,
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
{
provide: DiscoveryApiService,
useValue: {
Expand Down Expand Up @@ -158,7 +160,9 @@ describe('UploadService', () => {
service.uploadFilesInTheQueue(emitter);

const request = jasmine.Ajax.requests.mostRecent();
expect(request.url).toContain('/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children?autoRename=true&include=allowableOperations');
expect(request.url).toBe(
'http://localhost:9876/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children?autoRename=true&include=allowableOperations'
);
expect(request.method).toBe('POST');

jasmine.Ajax.requests.mostRecent().respondWith({
Expand All @@ -179,8 +183,9 @@ describe('UploadService', () => {
const fileFake = new FileModel({ name: 'fake-name', size: 10 } as File, { parentId: '-root-' });
service.addToQueue(fileFake);
service.uploadFilesInTheQueue(null, emitter);
expect(jasmine.Ajax.requests.mostRecent().url)
.toContain('ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children?autoRename=true&include=allowableOperations');
expect(jasmine.Ajax.requests.mostRecent().url).toBe(
'http://localhost:9876/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children?autoRename=true&include=allowableOperations'
);

jasmine.Ajax.requests.mostRecent().respondWith({
status: 404,
Expand Down Expand Up @@ -214,7 +219,9 @@ describe('UploadService', () => {
emitterDisposable.unsubscribe();

const deleteRequest = jasmine.Ajax.requests.mostRecent();
expect(deleteRequest.url).toContain('ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/myNodeId?permanent=true');
expect(deleteRequest.url).toBe(
'http://localhost:9876/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/myNodeId?permanent=true'
);
expect(deleteRequest.method).toBe('DELETE');

jasmine.Ajax.requests.mostRecent().respondWith({
Expand All @@ -233,7 +240,9 @@ describe('UploadService', () => {
service.cancelUpload(...file);

const request = jasmine.Ajax.requests.mostRecent();
expect(request.url).toContain('ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children?autoRename=true&include=allowableOperations');
expect(request.url).toBe(
'http://localhost:9876/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children?autoRename=true&include=allowableOperations'
);
expect(request.method).toBe('POST');

jasmine.Ajax.requests.mostRecent().respondWith({
Expand All @@ -255,7 +264,7 @@ describe('UploadService', () => {
emitterDisposable.unsubscribe();

const deleteRequest = jasmine.Ajax.requests.mostRecent();
expect(deleteRequest.url).toContain('ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/myNodeId/versions/1.1');
expect(deleteRequest.url).toBe('http://localhost:9876/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/myNodeId/versions/1.1');
expect(deleteRequest.method).toBe('DELETE');

jasmine.Ajax.requests.mostRecent().respondWith({
Expand Down Expand Up @@ -329,7 +338,9 @@ describe('UploadService', () => {
service.uploadFilesInTheQueue(emitter);

const request = jasmine.Ajax.requests.mostRecent();
expect(request.url).toContain('ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/123/children?autoRename=true&include=allowableOperations');
expect(request.url).toContain(
'/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/123/children?autoRename=true&include=allowableOperations'
);
expect(request.method).toBe('POST');

jasmine.Ajax.requests.mostRecent().respondWith({
Expand Down
Loading

0 comments on commit f09fe70

Please sign in to comment.