mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
Add diagrams Event unit test
This commit is contained in:
parent
b0882e7322
commit
f0207fe718
@ -1,97 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export var chartProcessDefOverview = {
|
||||
'elements': [{
|
||||
'id': 'id1585876275153',
|
||||
'type': 'table',
|
||||
'rows': [
|
||||
['__KEY_REPORTING.DEFAULT-REPORTS.PROCESS-DEFINITION-OVERVIEW.GENERAL-TABLE-TOTAL-PROCESS-DEFINITIONS', '9'],
|
||||
['__KEY_REPORTING.DEFAULT-REPORTS.PROCESS-DEFINITION-OVERVIEW.GENERAL-TABLE-TOTAL-PROCESS-INSTANCES', '41'],
|
||||
['__KEY_REPORTING.DEFAULT-REPORTS.PROCESS-DEFINITION-OVERVIEW.GENERAL-TABLE-ACTIVE-PROCESS-INSTANCES', '3'],
|
||||
['__KEY_REPORTING.DEFAULT-REPORTS.PROCESS-DEFINITION-OVERVIEW.GENERAL-TABLE-COMPLETED-PROCESS-INSTANCES', '38']
|
||||
]
|
||||
}, {
|
||||
'id': 'id1585876413072',
|
||||
'type': 'pieChart',
|
||||
'title': 'Total process instances overview',
|
||||
'titleKey': 'REPORTING.DEFAULT-REPORTS.PROCESS-DEFINITION-OVERVIEW.PROC-INST-CHART-TITLE',
|
||||
'values': [{
|
||||
'key': 'Second Process',
|
||||
'y': 4,
|
||||
'keyAndValue': ['Second Process', '4']
|
||||
}, {
|
||||
'key': 'Simple process',
|
||||
'y': 30,
|
||||
'keyAndValue': ['Simple process', '30']
|
||||
}, {
|
||||
'key': 'Third Process',
|
||||
'y': 7,
|
||||
'keyAndValue': ['Third Process', '7']
|
||||
}]
|
||||
}, {
|
||||
'id': 'id1585877659181',
|
||||
'type': 'table',
|
||||
'title': 'Process definition details',
|
||||
'titleKey': 'REPORTING.DEFAULT-REPORTS.PROCESS-DEFINITION-OVERVIEW.DETAIL-TABLE',
|
||||
'columnNames': ['Process definition', 'Total', 'Active', 'Completed'],
|
||||
'columnNameKeys': ['REPORTING.DEFAULT-REPORTS.PROCESS-DEFINITION-OVERVIEW.DETAIL-TABLE-PROCESS',
|
||||
'REPORTING.DEFAULT-REPORTS.PROCESS-DEFINITION-OVERVIEW.DETAIL-TABLE-TOTAL',
|
||||
'REPORTING.DEFAULT-REPORTS.PROCESS-DEFINITION-OVERVIEW.DETAIL-TABLE-ACTIVE',
|
||||
'REPORTING.DEFAULT-REPORTS.PROCESS-DEFINITION-OVERVIEW.DETAIL-TABLE-COMPLETED'],
|
||||
'columnsCentered': [false, false, false, false],
|
||||
'rows': [
|
||||
['Second Process', '4', '0', '4'],
|
||||
['Simple process', '30', '3', '27'],
|
||||
['Third Process', '7', '0', '7']
|
||||
]
|
||||
}]
|
||||
};
|
||||
|
||||
export var chartTaskOverview = {
|
||||
'elements': [{
|
||||
'id': 'id792351752194',
|
||||
'type': 'barChart',
|
||||
'title': 'title',
|
||||
'titleKey': 'REPORTING.DEFAULT-REPORTS.TASK-OVERVIEW.TASK-HISTOGRAM-TITLE',
|
||||
'values': [{
|
||||
'key': 'series1',
|
||||
'values': [['2016-09-30T00:00:00.000+0000', 3], ['2016-10-04T00:00:00.000+0000', 1]]
|
||||
}],
|
||||
'xAxisType': 'date_month',
|
||||
'yAxisType': 'count'
|
||||
}, {
|
||||
'id': 'id792349721129',
|
||||
'type': 'masterDetailTable',
|
||||
'title': 'Detailed task statistics',
|
||||
'titleKey': 'REPORTING.DEFAULT-REPORTS.TASK-OVERVIEW.DETAILED-TASK-STATS-TITLE',
|
||||
'columnNames': ['Task', 'Count', 'Sum', 'Min duration', 'Max duration', 'Average duration', 'Stddev duration'],
|
||||
'columnNameKeys': [
|
||||
'REPORTING.DEFAULT-REPORTS.TASK-OVERVIEW.DETAILED-TASK-STATS-TASK',
|
||||
'REPORTING.DEFAULT-REPORTS.TASK-OVERVIEW.COUNT',
|
||||
'REPORTING.DEFAULT-REPORTS.TASK-OVERVIEW.SUM',
|
||||
'REPORTING.DEFAULT-REPORTS.TASK-OVERVIEW.MIN-DURATION',
|
||||
'REPORTING.DEFAULT-REPORTS.TASK-OVERVIEW.MAX-DURATION',
|
||||
'REPORTING.DEFAULT-REPORTS.TASK-OVERVIEW.AVERAGE',
|
||||
'REPORTING.DEFAULT-REPORTS.TASK-OVERVIEW.STDDE'],
|
||||
'columnsCentered': [false, false, false, false],
|
||||
'rows': [
|
||||
['fake 1 user task', '1', '2.0', '3.0', '4.0', '5.0', '6.0'],
|
||||
['fake 2 user task', '1', '2.0', '3.0', '4.0', '5.0', '6.0']
|
||||
]
|
||||
}]
|
||||
};
|
@ -1,127 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* 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 { ReportParameterDetailsModel } from '../models/report.model';
|
||||
|
||||
export var reportDefParamStatus = {
|
||||
'id': 2005,
|
||||
'name': 'Fake Task overview status',
|
||||
'created': '2016-10-05T15:39:40.222+0000',
|
||||
'definition': '{ "parameters" :[{"id":"status","name":null,"nameKey":null,"type":"status","value":null,"dependsOn":null}]}'
|
||||
};
|
||||
|
||||
export var reportDefParamNumber = {
|
||||
'id': 2005,
|
||||
'name': 'Fake Process instances overview',
|
||||
'created': '2016-10-05T15:39:40.222+0000',
|
||||
'definition': '{ "parameters"' +
|
||||
' :[{"id":"slowProcessInstanceInteger","name":null,"nameKey":null,"type":"integer","value":10,"dependsOn":null}]}'
|
||||
};
|
||||
|
||||
export var reportDefParamDuration = {
|
||||
'id': 2005,
|
||||
'name': 'Fake Task service level agreement',
|
||||
'created': '2016-10-05T15:39:40.222+0000',
|
||||
'definition': '{ "parameters"' +
|
||||
' :[{"id":"duration","name":null,"nameKey":null,"type":"duration","value":null,"dependsOn":null}]}'
|
||||
};
|
||||
|
||||
export var reportDefParamCheck = {
|
||||
'id': 2005,
|
||||
'name': 'Fake Task service level agreement',
|
||||
'created': '2016-10-05T15:39:40.222+0000',
|
||||
'definition': '{ "parameters"' +
|
||||
' :[{"id":"typeFiltering","name":null,"nameKey":null,"type":"boolean","value":true,"dependsOn":null}]}'
|
||||
};
|
||||
|
||||
export var reportDefParamDateRange = {
|
||||
'id': 2005,
|
||||
'name': 'Fake Process instances overview',
|
||||
'created': '2016-10-05T15:39:40.222+0000',
|
||||
'definition': '{ "parameters" :[{"id":"dateRange","name":null,"nameKey":null,"type":"dateRange","value":null,"dependsOn":null}]}'
|
||||
};
|
||||
|
||||
export var reportDefParamRangeInterval = {
|
||||
'id': 2006,
|
||||
'name': 'Fake Task overview RangeInterval',
|
||||
'created': '2016-10-05T15:39:40.222+0000',
|
||||
'definition': '{ "parameters" :[{"id":"dateRangeInterval","name":null,"nameKey":null,"type":"dateInterval","value":null,"dependsOn":null}]}'
|
||||
};
|
||||
|
||||
export var reportDefParamProcessDef = {
|
||||
'id': 2006,
|
||||
'name': 'Fake Task overview ProcessDefinition',
|
||||
'created': '2016-10-05T15:39:40.222+0000',
|
||||
'definition': '{ "parameters" :[{"id":"processDefinitionId","name":null,"nameKey":null,"type":"processDefinition","value":null,"dependsOn":null}]}'
|
||||
};
|
||||
|
||||
export var reportDefParamProcessDefOptions = {
|
||||
'size': 4, 'total': 4, 'start': 0, 'data': [
|
||||
{
|
||||
'id': 'FakeProcessTest 1:1:1',
|
||||
'name': 'Fake Process Test 1 Name ',
|
||||
'version': 1
|
||||
},
|
||||
{
|
||||
'id': 'FakeProcessTest 1:2:1',
|
||||
'name': 'Fake Process Test 1 Name ',
|
||||
'version': 2
|
||||
},
|
||||
{
|
||||
'id': 'FakeProcessTest 2:1:1',
|
||||
'name': 'Fake Process Test 2 Name ',
|
||||
'version': 1
|
||||
},
|
||||
{
|
||||
'id': 'FakeProcessTest 3:1:1',
|
||||
'name': 'Fake Process Test 3 Name ',
|
||||
'version': 1
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
export var reportDefParamProcessDefOptionsApp = {
|
||||
'size': 2, 'total': 2, 'start': 2, 'data': [
|
||||
{
|
||||
'id': 'FakeProcessTest 1:1:1',
|
||||
'name': 'Fake Process Test 1 Name ',
|
||||
'version': 1
|
||||
},
|
||||
{
|
||||
'id': 'FakeProcessTest 1:2:1',
|
||||
'name': 'Fake Process Test 1 Name ',
|
||||
'version': 2
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
export var reportDefParamTask = {
|
||||
'id': 2006,
|
||||
'name': 'Fake Task service level agreement',
|
||||
'created': '2016-10-05T15:39:40.222+0000',
|
||||
'definition': '{ "parameters" :[{"id":"taskName","name":null,"nameKey":null,"type":"task","value":null,"dependsOn":"processDefinitionId"}]}'
|
||||
};
|
||||
|
||||
export var reportDefParamTaskOptions = ['Fake task name 1', 'Fake task name 2'];
|
||||
|
||||
export var fieldProcessDef = new ReportParameterDetailsModel(
|
||||
{
|
||||
id: 'processDefinitionId',
|
||||
type: 'processDefinition',
|
||||
value: 'fake-process-name:1:15027'
|
||||
}
|
||||
);
|
@ -0,0 +1,91 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export let startEvent = {
|
||||
id: 'startEvent1',
|
||||
type: 'StartEvent',
|
||||
width: 30,
|
||||
height: 30,
|
||||
x: 15,
|
||||
y: 48.5,
|
||||
properties: [{}]
|
||||
};
|
||||
|
||||
export let startTimeEvent = {
|
||||
id: 'startEvent1',
|
||||
type: 'StartEvent',
|
||||
width: 30,
|
||||
height: 30,
|
||||
x: 15,
|
||||
y: 48.5,
|
||||
eventDefinition: {type: 'timer'},
|
||||
properties: [{}]
|
||||
};
|
||||
|
||||
export let startSignalEvent = {
|
||||
id: 'startEvent1',
|
||||
type: 'StartEvent',
|
||||
width: 30,
|
||||
height: 30,
|
||||
x: 15,
|
||||
y: 48.5,
|
||||
eventDefinition: {type: 'signal'},
|
||||
properties: [{}]
|
||||
};
|
||||
|
||||
export let startMessageEvent = {
|
||||
id: 'startEvent1',
|
||||
type: 'StartEvent',
|
||||
width: 30,
|
||||
height: 30,
|
||||
x: 15,
|
||||
y: 48.5,
|
||||
eventDefinition: {type: 'message'},
|
||||
properties: [{}]
|
||||
};
|
||||
|
||||
export let startErrorEvent = {
|
||||
id: 'startEvent1',
|
||||
type: 'StartEvent',
|
||||
width: 30,
|
||||
height: 30,
|
||||
x: 15,
|
||||
y: 48.5,
|
||||
eventDefinition: {type: 'error'},
|
||||
properties: [{}]
|
||||
};
|
||||
|
||||
export let endEvent = {
|
||||
id: 'sid-CED2A8DB-47E2-4057-A7B8-3ABBE5CE795E',
|
||||
type: 'EndEvent',
|
||||
width: 28,
|
||||
height: 28,
|
||||
x: 15,
|
||||
y: 48.5,
|
||||
properties: [{}]
|
||||
};
|
||||
|
||||
export let endErrorEvent = {
|
||||
id: 'sid-CED2A8DB-47E2-4057-A7B8-3ABBE5CE795E',
|
||||
type: 'EndEvent',
|
||||
width: 28,
|
||||
height: 28,
|
||||
x: 15,
|
||||
y: 48.5,
|
||||
eventDefinition: {type: 'error'},
|
||||
properties: [{}]
|
||||
};
|
@ -24,6 +24,7 @@ import { DIAGRAM_DIRECTIVES, DIAGRAM_PROVIDERS } from './index';
|
||||
import { RAPHAEL_DIRECTIVES, RAPHAEL_PROVIDERS } from './raphael/index';
|
||||
import { DiagramComponent } from './index';
|
||||
import { DebugElement } from '@angular/core';
|
||||
import * as diagramsEventsMock from '../assets/diagramEvents.mock';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
@ -64,40 +65,50 @@ describe('Test ng2-activiti-diagrams ', () => {
|
||||
window['componentHandler'] = componentHandler;
|
||||
});
|
||||
|
||||
describe('Diagrams component ', () => {
|
||||
describe('Diagrams component Events: ', () => {
|
||||
beforeEach(() => {
|
||||
jasmine.Ajax.install();
|
||||
component.processDefinitionId = 'fakeprocess:24:38399';
|
||||
component.metricPercentages = {startEvent: 0};
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
it('Should render the StartEvent', async(() => {
|
||||
component.processDefinitionId = 'fakeprocess:24:38399';
|
||||
component.metricPercentages = {startEvent: 0};
|
||||
it('Should render the Start Event', async(() => {
|
||||
component.onSuccess.subscribe((res) => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(res).not.toBeNull();
|
||||
let event: any = element.querySelector('diagram-start-event > diagram-event > raphael-circle');
|
||||
expect(event).not.toBeNull();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
let resp = {elements: [diagramsEventsMock.startEvent]};
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: resp
|
||||
});
|
||||
}));
|
||||
|
||||
it('Should render the Start Timer Event', async(() => {
|
||||
component.onSuccess.subscribe((res) => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(res).toBeDefined();
|
||||
let startEvent: any = element.querySelector('diagram-start-event');
|
||||
expect(startEvent).toBeDefined();
|
||||
let raphaelCircle: any = element.querySelector('raphael-circle');
|
||||
expect(raphaelCircle).toBeDefined();
|
||||
let event: any = element.querySelector('diagram-start-event > diagram-event > raphael-circle');
|
||||
expect(event).not.toBeNull();
|
||||
|
||||
let iconEvent: any = element.querySelector('diagram-start-event > diagram-event >' +
|
||||
' diagram-container-icon-event > div > div > diagram-icon-timer > raphael-icon-timer');
|
||||
expect(iconEvent).not.toBeNull();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
let startEvent = {
|
||||
id: 'startEvent1',
|
||||
type: 'StartEvent',
|
||||
width: 30,
|
||||
height: 30,
|
||||
x: 15,
|
||||
y: 48.5,
|
||||
properties: [{}]
|
||||
};
|
||||
let resp = {elements : [startEvent] };
|
||||
let resp = {elements: [diagramsEventsMock.startTimeEvent]};
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
@ -105,5 +116,111 @@ describe('Test ng2-activiti-diagrams ', () => {
|
||||
responseText: resp
|
||||
});
|
||||
}));
|
||||
|
||||
it('Should render the Start Signal Event', async(() => {
|
||||
component.onSuccess.subscribe((res) => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(res).toBeDefined();
|
||||
let event: any = element.querySelector('diagram-start-event > diagram-event > raphael-circle');
|
||||
expect(event).not.toBeNull();
|
||||
|
||||
let iconEvent: any = element.querySelector('diagram-start-event > diagram-event >' +
|
||||
' diagram-container-icon-event > div > div > diagram-icon-signal > raphael-icon-signal');
|
||||
expect(iconEvent).not.toBeNull();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
let resp = {elements: [diagramsEventsMock.startSignalEvent]};
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: resp
|
||||
});
|
||||
}));
|
||||
|
||||
it('Should render the Start Message Event', async(() => {
|
||||
component.onSuccess.subscribe((res) => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(res).toBeDefined();
|
||||
let event: any = element.querySelector('diagram-start-event > diagram-event > raphael-circle');
|
||||
expect(event).not.toBeNull();
|
||||
|
||||
let iconEvent: any = element.querySelector('diagram-start-event > diagram-event >' +
|
||||
' diagram-container-icon-event > div > div > diagram-icon-message > raphael-icon-message');
|
||||
expect(iconEvent).not.toBeNull();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
let resp = {elements: [diagramsEventsMock.startMessageEvent]};
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: resp
|
||||
});
|
||||
}));
|
||||
|
||||
it('Should render the Start Error Event', async(() => {
|
||||
component.onSuccess.subscribe((res) => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(res).toBeDefined();
|
||||
let event: any = element.querySelector('diagram-start-event > diagram-event > raphael-circle');
|
||||
expect(event).not.toBeNull();
|
||||
|
||||
let iconEvent: any = element.querySelector('diagram-start-event > diagram-event >' +
|
||||
' diagram-container-icon-event > div > div > diagram-icon-error > raphael-icon-error');
|
||||
expect(iconEvent).not.toBeNull();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
let resp = {elements: [diagramsEventsMock.startErrorEvent]};
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: resp
|
||||
});
|
||||
}));
|
||||
|
||||
it('Should render the End Event', async(() => {
|
||||
component.onSuccess.subscribe((res) => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(res).toBeDefined();
|
||||
let event: any = element.querySelector('diagram-end-event > diagram-event > raphael-circle');
|
||||
expect(event).not.toBeNull();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
let resp = {elements: [diagramsEventsMock.endEvent]};
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: resp
|
||||
});
|
||||
}));
|
||||
|
||||
it('Should render the End Error Event', async(() => {
|
||||
component.onSuccess.subscribe((res) => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(res).toBeDefined();
|
||||
let event: any = element.querySelector('diagram-end-event > diagram-event > raphael-circle');
|
||||
expect(event).not.toBeNull();
|
||||
|
||||
let iconEvent: any = element.querySelector('diagram-end-event > diagram-event >' +
|
||||
' diagram-container-icon-event > div > div > diagram-icon-error > raphael-icon-error');
|
||||
expect(iconEvent).not.toBeNull();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
let resp = {elements: [diagramsEventsMock.endErrorEvent]};
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: resp
|
||||
});
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user