Process list implement pagination interface (#2872)

This commit is contained in:
Maurizio Vitale
2018-02-03 18:22:05 +00:00
committed by Eugenio Romano
parent 105bc80d2c
commit 0f6ac42e4c
17 changed files with 311 additions and 141 deletions

View File

@@ -61,48 +61,48 @@ describe('ProcessAttachmentListComponent', () => {
});
mockAttachment = {
'size': 2,
'total': 2,
'start': 0,
'data': [{
'id': 4001,
'name': 'Invoice01.pdf',
'created': '2017-05-12T12:50:05.522+0000',
'createdBy': {
'id': 1,
'firstName': 'Apps',
'lastName': 'Administrator',
'email': 'admin@app.activiti.com',
'company': 'Alfresco.com',
'pictureId': 3003
size: 2,
total: 2,
start: 0,
data: [{
id: 4001,
name: 'Invoice01.pdf',
created: '2017-05-12T12:50:05.522+0000',
createdBy: {
id: 1,
firstName: 'Apps',
lastName: 'Administrator',
email: 'admin@app.activiti.com',
company: 'Alfresco.com',
pictureId: 3003
},
'relatedContent': true,
'contentAvailable': true,
'link': false,
'mimeType': 'application/pdf',
'simpleType': 'pdf',
'previewStatus': 'created',
'thumbnailStatus': 'created'
relatedContent: true,
contentAvailable: true,
link: false,
mimeType: 'application/pdf',
simpleType: 'pdf',
previewStatus: 'created',
thumbnailStatus: 'created'
},
{
'id': 4002,
'name': 'Invoice02.pdf',
'created': '2017-05-12T12:50:05.522+0000',
'createdBy': {
'id': 1,
'firstName': 'Apps',
'lastName': 'Administrator',
'email': 'admin@app.activiti.com',
'company': 'Alfresco.com',
'pictureId': 3003
id: 4002,
name: 'Invoice02.pdf',
created: '2017-05-12T12:50:05.522+0000',
createdBy: {
id: 1,
firstName: 'Apps',
lastName: 'Administrator',
email: 'admin@app.activiti.com',
company: 'Alfresco.com',
pictureId: 3003
},
'relatedContent': true,
'contentAvailable': true,
'link': false,
'mimeType': 'application/pdf',
'simpleType': 'pdf',
'previewStatus': 'created',
'thumbnailStatus': 'created'
relatedContent: true,
contentAvailable: true,
link: false,
mimeType: 'application/pdf',
simpleType: 'pdf',
previewStatus: 'created',
thumbnailStatus: 'created'
}]
};
@@ -115,6 +115,14 @@ describe('ProcessAttachmentListComponent', () => {
));
});
afterEach(() => {
const overlayContainers = <any> window.document.querySelectorAll('.cdk-overlay-container');
overlayContainers.forEach((overlayContainer) => {
overlayContainer.innerHTML = '';
});
});
it('should load attachments when processInstanceId specified', () => {
let change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change });
@@ -154,7 +162,7 @@ describe('ProcessAttachmentListComponent', () => {
});
}));
it('should display all actions if attachements are not read only', () => {
it('should display all actions if attachements are not read only', async(() => {
let change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change });
@@ -163,14 +171,15 @@ describe('ProcessAttachmentListComponent', () => {
actionButton.click();
fixture.whenStable().then(() => {
fixture.detectChanges();
let actionMenu = fixture.debugElement.nativeElement.querySelectorAll('button.mat-menu-item').length;
expect(fixture.debugElement.nativeElement.querySelector('[data-automation-id="View"]')).not.toBeNull();
expect(fixture.debugElement.nativeElement.querySelector('[data-automation-id="Remove"]')).not.toBeNull();
let actionMenu = window.document.querySelectorAll('button.mat-menu-item').length;
expect(window.document.querySelector('[data-automation-id="ADF_PROCESS_LIST.MENU_ACTIONS.VIEW_CONTENT"]')).not.toBeNull();
expect(window.document.querySelector('[data-automation-id="ADF_PROCESS_LIST.MENU_ACTIONS.REMOVE_CONTENT"]')).not.toBeNull();
expect(window.document.querySelector('[data-automation-id="ADF_PROCESS_LIST.MENU_ACTIONS.DOWNLOAD_CONTENT"]')).not.toBeNull();
expect(actionMenu).toBe(3);
});
});
}));
it('should not display remove action if attachments are read only', () => {
it('should not display remove action if attachments are read only', async(() => {
let change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'processInstanceId': change });
component.disabled = true;
@@ -180,12 +189,13 @@ describe('ProcessAttachmentListComponent', () => {
actionButton.click();
fixture.whenStable().then(() => {
fixture.detectChanges();
let actionMenu = fixture.debugElement.nativeElement.querySelectorAll('button.mat-menu-item').length;
expect(fixture.debugElement.nativeElement.querySelector('[data-automation-id="View"]')).not.toBeNull();
expect(fixture.debugElement.nativeElement.querySelector('[data-automation-id="Remove"]')).toBeNull();
let actionMenu = window.document.querySelectorAll('button.mat-menu-item').length;
expect(window.document.querySelector('[data-automation-id="ADF_PROCESS_LIST.MENU_ACTIONS.VIEW_CONTENT"]')).not.toBeNull();
expect(window.document.querySelector('[data-automation-id="ADF_PROCESS_LIST.MENU_ACTIONS.DOWNLOAD_CONTENT"]')).not.toBeNull();
expect(window.document.querySelector('[data-automation-id="ADF_PROCESS_LIST.MENU_ACTIONS.REMOVE_CONTENT"]')).toBeNull();
expect(actionMenu).toBe(2);
});
});
}));
it('should show the empty list component when the attachments list is empty', async(() => {
getProcessRelatedContentSpy.and.returnValue(Observable.of({
@@ -325,12 +335,12 @@ describe('Custom CustomEmptyTemplateComponent', () => {
fixture.detectChanges();
});
it('should render the custom template', () => {
it('should render the custom template', async(() => {
fixture.whenStable().then(() => {
fixture.detectChanges();
let title: any = fixture.debugElement.queryAll(By.css('[adf-empty-list-header]'));
expect(title.length).toBe(1);
expect(title[0].nativeElement.innerText).toBe('Custom header');
});
});
}));
});

View File

@@ -61,7 +61,7 @@ export class ProcessAttachmentListComponent implements OnChanges, AfterContentIn
hasCustomTemplate: boolean = false;
attachments: any[] = [];
isLoading: boolean = true;
isLoading: boolean = false;
constructor(private activitiContentService: ProcessContentService,
private contentService: ContentService,

View File

@@ -99,6 +99,13 @@ describe('TaskAttachmentList', () => {
getFileRawContentSpy = spyOn(service, 'getFileRawContent').and.returnValue(Observable.of(blobObj));
});
afterEach(() => {
const overlayContainers = <any> window.document.querySelectorAll('.cdk-overlay-container');
overlayContainers.forEach((overlayContainer) => {
overlayContainer.innerHTML = '';
});
});
it('should load attachments when taskId specified', () => {
let change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'taskId': change });
@@ -168,7 +175,7 @@ describe('TaskAttachmentList', () => {
});
}));
it('should display all actions if attachments are not read only', () => {
it('should display all actions if attachments are not read only', async(() => {
let change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'taskId': change });
fixture.detectChanges();
@@ -177,14 +184,15 @@ describe('TaskAttachmentList', () => {
actionButton.click();
fixture.whenStable().then(() => {
fixture.detectChanges();
let actionMenu = fixture.debugElement.nativeElement.querySelectorAll('button.mat-menu-item').length;
expect(fixture.debugElement.nativeElement.querySelector('[data-automation-id="View"]')).not.toBeNull();
expect(fixture.debugElement.nativeElement.querySelector('[data-automation-id="Remove"]')).not.toBeNull();
let actionMenu = window.document.querySelectorAll('button.mat-menu-item').length;
expect(window.document.querySelector('[data-automation-id="ADF_TASK_LIST.MENU_ACTIONS.VIEW_CONTENT"]')).not.toBeNull();
expect(window.document.querySelector('[data-automation-id="ADF_TASK_LIST.MENU_ACTIONS.REMOVE_CONTENT"]')).not.toBeNull();
expect(window.document.querySelector('[data-automation-id="ADF_TASK_LIST.MENU_ACTIONS.DOWNLOAD_CONTENT"]')).not.toBeNull();
expect(actionMenu).toBe(3);
});
});
}));
it('should not display remove action if attachments are read only', () => {
it('should not display remove action if attachments are read only', async(() => {
let change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'taskId': change });
component.disabled = true;
@@ -194,12 +202,13 @@ describe('TaskAttachmentList', () => {
actionButton.click();
fixture.whenStable().then(() => {
fixture.detectChanges();
let actionMenu = fixture.debugElement.nativeElement.querySelectorAll('button.mat-menu-item').length;
expect(fixture.debugElement.nativeElement.querySelector('[data-automation-id="View"]')).not.toBeNull();
expect(fixture.debugElement.nativeElement.querySelector('[data-automation-id="Remove"]')).toBeNull();
let actionMenu = window.document.querySelectorAll('button.mat-menu-item').length;
expect(window.document.querySelector('[data-automation-id="ADF_TASK_LIST.MENU_ACTIONS.VIEW_CONTENT"]')).not.toBeNull();
expect(window.document.querySelector('[data-automation-id="ADF_TASK_LIST.MENU_ACTIONS.DOWNLOAD_CONTENT"]')).not.toBeNull();
expect(window.document.querySelector('[data-automation-id="ADF_TASK_LIST.MENU_ACTIONS.REMOVE_CONTENT"]')).toBeNull();
expect(actionMenu).toBe(2);
});
});
}));
it('should show the empty list component when the attachments list is empty', async(() => {
getTaskRelatedContentSpy.and.returnValue(Observable.of({
@@ -330,12 +339,12 @@ describe('Custom CustomEmptyTemplateComponent', () => {
fixture.detectChanges();
});
it('should render the custom template', () => {
it('should render the custom template', async(() => {
fixture.whenStable().then(() => {
fixture.detectChanges();
let title: any = fixture.debugElement.queryAll(By.css('[adf-empty-list-header]'));
expect(title.length).toBe(1);
expect(title[0].nativeElement.innerText).toBe('Custom header');
});
});
}));
});