Rebalance suites conf to be less error prone (#1819)

* rebalance suites conf to be less error prone

* shared api - wait for specific files instead of totalItems

* remove unused

* - make search api wait calls more stable on parallel runs
- remove not needed workaround from closeMoreMenu

* reorganize test suites
a few more test stabilisations

* improve copy tests for parallel running

* more changes to consider parallel running

Co-authored-by: Adina Parpalita <Adina.Parpalita@ness.com>
This commit is contained in:
Eugenio Romano
2020-12-04 12:39:39 +00:00
committed by GitHub
parent 321bcb1247
commit ad58be3d05
65 changed files with 745 additions and 1206 deletions

View File

@@ -25,8 +25,8 @@
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { Router } from '@angular/router';
import { TestBed, ComponentFixture, fakeAsync, tick } from '@angular/core/testing';
import { AlfrescoApiService, NodeFavoriteDirective, DataTableComponent, AppConfigPipe, UploadService } from '@alfresco/adf-core';
import { TestBed, ComponentFixture } from '@angular/core/testing';
import { AlfrescoApiService, NodeFavoriteDirective, DataTableComponent, AppConfigPipe } from '@alfresco/adf-core';
import { DocumentListComponent } from '@alfresco/adf-content-services';
import { of } from 'rxjs';
import { FavoritesComponent } from './favorites.component';
@@ -45,7 +45,6 @@ describe('FavoritesComponent', () => {
};
let page;
let node;
let uploadService: UploadService;
beforeEach(() => {
page = {
@@ -86,7 +85,6 @@ describe('FavoritesComponent', () => {
spyOn(alfrescoApi.favoritesApi, 'getFavorites').and.returnValue(Promise.resolve(page));
contentApi = TestBed.inject(ContentApiService);
uploadService = TestBed.inject(UploadService);
router = TestBed.inject(Router);
});
@@ -122,28 +120,6 @@ describe('FavoritesComponent', () => {
});
});
// TODO: fix with ADF 4.1
xit('should call document list reload on fileUploadComplete event', fakeAsync(() => {
spyOn(component, 'reload');
fixture.detectChanges();
uploadService.fileUploadComplete.next();
tick(500);
expect(component.reload).toHaveBeenCalled();
}));
// TODO: fix with ADF 4.1
xit('should call document list reload on fileUploadDeleted event', fakeAsync(() => {
spyOn(component, 'reload');
fixture.detectChanges();
uploadService.fileUploadDeleted.next();
tick(500);
expect(component.reload).toHaveBeenCalled();
}));
it('should navigate if node is folder', () => {
const nodeEntity: any = { entry: { isFolder: true } };
spyOn(component, 'navigate').and.stub();

View File

@@ -368,47 +368,6 @@ describe('PreviewComponent', () => {
expect(router.navigate).toHaveBeenCalledWith(['personal-files', 'folder1']);
});
// todo: Fix after Angular6 migration
xit('should navigate to original location in case of internal errors', async () => {
spyOn(router, 'navigate').and.stub();
spyOn(contentApi, 'getNodeInfo').and.returnValue(
of({
isFile: true
} as Node)
);
spyOn(component, 'getNearestNodes').and.returnValue(Promise.reject('error'));
component.previewLocation = 'personal-files';
await component.displayNode('folder1');
expect(contentApi.getNodeInfo).toHaveBeenCalledWith('folder1');
expect(router.navigate).toHaveBeenCalledWith(['personal-files', 'folder1']);
});
xit('should setup node for displaying', async () => {
spyOn(router, 'navigate').and.stub();
spyOn(component, 'getNearestNodes').and.returnValue(
Promise.resolve({
left: 'node1',
right: 'node3'
})
);
spyOn(contentApi, 'getNodeInfo').and.returnValue(
of({
id: 'node2',
parentId: 'parent1',
isFile: true
} as Node)
);
await component.displayNode('node2');
expect(component.previousNodeId).toBe('node1');
expect(component.nextNodeId).toBe('node3');
expect(component.nodeId).toBe('node2');
expect(router.navigate).not.toHaveBeenCalled();
});
it('should fetch and sort file ids for personal-files', async () => {
preferences.set('personal-files.sorting.key', 'name');
preferences.set('personal-files.sorting.direction', 'desc');
@@ -441,11 +400,6 @@ describe('PreviewComponent', () => {
expect(ids).toEqual(['node1', 'node2']);
});
xit('should require folder id to fetch ids for personal-files', async () => {
const ids = await component.getFileIds('personal-files', null);
expect(ids).toEqual([]);
});
it('should sort file ids for personal-files with [modifiedAt desc]', async () => {
spyOn(preferences, 'get').and.returnValue(null);

View File

@@ -23,9 +23,9 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { TestBed, ComponentFixture, fakeAsync, tick } from '@angular/core/testing';
import { TestBed, ComponentFixture } from '@angular/core/testing';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { AlfrescoApiService, NodeFavoriteDirective, DataTableComponent, AppConfigPipe, UploadService } from '@alfresco/adf-core';
import { AlfrescoApiService, NodeFavoriteDirective, DataTableComponent, AppConfigPipe } from '@alfresco/adf-core';
import { DocumentListComponent } from '@alfresco/adf-content-services';
import { RecentFilesComponent } from './recent-files.component';
import { AppTestingModule } from '../../testing/app-testing.module';
@@ -37,7 +37,6 @@ describe('RecentFilesComponent', () => {
let component: RecentFilesComponent;
let alfrescoApi: AlfrescoApiService;
let page;
let uploadService: UploadService;
const mockRouter = {
url: 'recent-files'
};
@@ -68,7 +67,6 @@ describe('RecentFilesComponent', () => {
component = fixture.componentInstance;
alfrescoApi = TestBed.inject(AlfrescoApiService);
uploadService = TestBed.inject(UploadService);
alfrescoApi.reset();
spyOn(alfrescoApi.peopleApi, 'getPerson').and.returnValue(
@@ -80,28 +78,6 @@ describe('RecentFilesComponent', () => {
spyOn(alfrescoApi.searchApi, 'search').and.returnValue(Promise.resolve(page));
});
// TODO: fix with ADF 4.1
xit('should call document list reload on fileUploadComplete event', fakeAsync(() => {
spyOn(component, 'reload');
fixture.detectChanges();
uploadService.fileUploadComplete.next();
tick(500);
expect(component.reload).toHaveBeenCalled();
}));
// TODO: fix with ADF 4.1
xit('should call document list reload on fileUploadDeleted event', fakeAsync(() => {
spyOn(component, 'reload');
fixture.detectChanges();
uploadService.fileUploadDeleted.next();
tick(500);
expect(component.reload).toHaveBeenCalled();
}));
it('should call showPreview method', () => {
const node: any = { entry: {} };
spyOn(component, 'showPreview');

View File

@@ -1,135 +0,0 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { TestBed, ComponentFixture, fakeAsync, tick } from '@angular/core/testing';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import {
AlfrescoApiService,
AlfrescoApiServiceMock,
NodeFavoriteDirective,
DataTableComponent,
AppConfigPipe,
UploadService
} from '@alfresco/adf-core';
import { CustomResourcesService, DocumentListComponent } from '@alfresco/adf-content-services';
import { SharedFilesComponent } from './shared-files.component';
import { AppTestingModule } from '../../testing/app-testing.module';
import { Router } from '@angular/router';
import { ContentManagementService } from '../../services/content-management.service';
import { of } from 'rxjs';
describe('SharedFilesComponent', () => {
let fixture: ComponentFixture<SharedFilesComponent>;
let component: SharedFilesComponent;
let alfrescoApi: AlfrescoApiService;
let page;
let uploadService: UploadService;
let customResourcesService: CustomResourcesService;
let contentManagementService: ContentManagementService;
const mockRouter = {
url: 'shared-files'
};
beforeEach(() => {
page = {
list: {
entries: [{ entry: { id: 1 } }, { entry: { id: 2 } }],
pagination: { data: 'data' }
}
};
});
beforeEach(() => {
TestBed.configureTestingModule({
imports: [AppTestingModule],
declarations: [DataTableComponent, NodeFavoriteDirective, DocumentListComponent, SharedFilesComponent, AppConfigPipe],
providers: [
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
{
provide: Router,
useValue: mockRouter
}
],
schemas: [NO_ERRORS_SCHEMA]
});
fixture = TestBed.createComponent(SharedFilesComponent);
uploadService = TestBed.inject(UploadService);
contentManagementService = TestBed.inject(ContentManagementService);
customResourcesService = TestBed.inject(CustomResourcesService);
component = fixture.componentInstance;
alfrescoApi = TestBed.inject(AlfrescoApiService);
alfrescoApi.reset();
spyOn(alfrescoApi.sharedLinksApi, 'findSharedLinks').and.returnValue(Promise.resolve(page));
spyOn(customResourcesService, 'loadSharedLinks').and.returnValue(of(page));
});
// TODO: fix with ADF 4.1
xit('should call document list reload on linksUnshared event', fakeAsync(() => {
spyOn(component, 'reload');
fixture.detectChanges();
contentManagementService.linksUnshared.next();
tick(500);
expect(component.reload).toHaveBeenCalled();
}));
// TODO: fix with ADF 4.1
xit('should call document list reload on fileUploadComplete event', fakeAsync(() => {
spyOn(component, 'reload');
fixture.detectChanges();
uploadService.fileUploadComplete.next();
tick(500);
expect(component.reload).toHaveBeenCalled();
}));
// TODO: fix with ADF 4.1
xit('should call document list reload on fileUploadDeleted event', fakeAsync(() => {
spyOn(component, 'reload');
fixture.detectChanges();
uploadService.fileUploadDeleted.next();
tick(500);
expect(component.reload).toHaveBeenCalled();
}));
// TODO: fix with ADF 4.1
xit('should call showPreview method', () => {
const node: any = { entry: {} };
spyOn(component, 'showPreview');
fixture.detectChanges();
component.preview(node);
expect(component.showPreview).toHaveBeenCalledWith(node, {
location: mockRouter.url
});
});
});

View File

@@ -63,7 +63,7 @@ describe('SidenavComponent', () => {
}));
// TODO: fix with ADF 4.1
xit('should set the sidenav data', async(() => {
it('should set the sidenav data', async(() => {
expect(component.groups).toEqual([
{
items: [