diff --git a/lib/core/form/components/form-field/form-field.component.spec.ts b/lib/core/form/components/form-field/form-field.component.spec.ts index 124f242d9c..55ebc1019c 100644 --- a/lib/core/form/components/form-field/form-field.component.spec.ts +++ b/lib/core/form/components/form-field/form-field.component.spec.ts @@ -21,8 +21,11 @@ import { FormFieldModel, FormFieldTypes, FormModel } from './../widgets/core/ind import { TextWidgetComponent, CheckboxWidgetComponent } from '../widgets/index'; import { FormFieldComponent } from './form-field.component'; import { setupTestBed } from '../../../testing/setup-test-bed'; -import { CoreModule } from '../../../core.module'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; +import { FormBaseModule } from '../../form-base.module'; +import { TranslationService } from '../../../services/translation.service'; +import { TranslationMock } from '../../../mock/translation.service.mock'; +import { TranslateStore } from '@ngx-translate/core'; describe('FormFieldComponent', () => { @@ -35,7 +38,11 @@ describe('FormFieldComponent', () => { setupTestBed({ imports: [ NoopAnimationsModule, - CoreModule.forRoot() + FormBaseModule + ], + providers: [ + { provide: TranslationService, useClass: TranslationMock }, + TranslateStore ] }); @@ -144,4 +151,57 @@ describe('FormFieldComponent', () => { fixture.detectChanges(); expect(fixture.nativeElement.querySelector('#field-FAKE-TXT-WIDGET-container').hidden).toBeTruthy(); }); + + it('[C213878] - Should fields be correctly rendered when filled with process variables', async () => { + const field = new FormFieldModel(form, { + fieldType: 'HyperlinkRepresentation', + id: 'label2', + name: 'Label2', + type: 'hyperlink', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { + existingColspan: 1, + maxColspan: 2 + }, + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 1 + }, + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + hyperlinkUrl: 'testtest', + displayText: null + }); + + component.field = field; + fixture.detectChanges(); + const hyperlink: HTMLLinkElement = fixture.nativeElement.querySelector('#field-label2-container hyperlink-widget a'); + expect(hyperlink).not.toBeNull(); + expect(hyperlink.href).toBe('http://testtest/'); + expect(hyperlink.textContent).toBe('testtest'); + }); }); diff --git a/lib/process-services/src/lib/mock/task/task-details.mock.ts b/lib/process-services/src/lib/mock/task/task-details.mock.ts index 5d595cb23c..86dbf9805b 100644 --- a/lib/process-services/src/lib/mock/task/task-details.mock.ts +++ b/lib/process-services/src/lib/mock/task/task-details.mock.ts @@ -18,410 +18,638 @@ import { TaskDetailsModel } from '../../task-list/models/task-details.model'; export let standaloneTaskWithForm = new TaskDetailsModel({ - 'id': '100', - 'name': 'Standalone Task With Form', - 'description': null, - 'category': null, - 'assignee': { 'id': 1001, 'firstName': 'Wilbur', 'lastName': 'Adams', 'email': 'wilbur@app.activiti.com' }, - 'created': '2016-11-03T15:25:42.749+0000', - 'dueDate': null, - 'endDate': null, - 'duration': null, - 'priority': 50, - 'parentTaskId': null, - 'parentTaskName': null, - 'processInstanceId': null, - 'processInstanceName': null, - 'processDefinitionId': null, - 'processDefinitionName': null, - 'processDefinitionDescription': null, - 'processDefinitionKey': null, - 'processDefinitionCategory': null, - 'processDefinitionVersion': null, - 'processDefinitionDeploymentId': null, - 'formKey': '222', - 'processInstanceStartUserId': null, - 'initiatorCanCompleteTask': false, - 'adhocTaskCanBeReassigned': false, - 'taskDefinitionKey': 'sid-DDECD9E4-0299-433F-9193-C3D905C3EEBE', - 'executionId': '86', - 'involvedGroups': [], - 'involvedPeople': [], - 'memberOfCandidateUsers': false, - 'managerOfCandidateGroup': false, - 'memberOfCandidateGroup': false + id: '100', + name: 'Standalone Task With Form', + description: null, + category: null, + assignee: { + id: 1001, + firstName: 'Wilbur', + lastName: 'Adams', + email: 'wilbur@app.activiti.com' + }, + created: '2016-11-03T15:25:42.749+0000', + dueDate: null, + endDate: null, + duration: null, + priority: 50, + parentTaskId: null, + parentTaskName: null, + processInstanceId: null, + processInstanceName: null, + processDefinitionId: null, + processDefinitionName: null, + processDefinitionDescription: null, + processDefinitionKey: null, + processDefinitionCategory: null, + processDefinitionVersion: null, + processDefinitionDeploymentId: null, + formKey: '222', + processInstanceStartUserId: null, + initiatorCanCompleteTask: false, + adhocTaskCanBeReassigned: false, + taskDefinitionKey: 'sid-DDECD9E4-0299-433F-9193-C3D905C3EEBE', + executionId: '86', + involvedGroups: [], + involvedPeople: [], + memberOfCandidateUsers: false, + managerOfCandidateGroup: false, + memberOfCandidateGroup: false }); export let standaloneTaskWithoutForm = new TaskDetailsModel({ - 'id': '200', - 'name': 'Standalone Task Without Form', - 'description': null, - 'category': null, - 'assignee': { 'id': 1001, 'firstName': 'Wilbur', 'lastName': 'Adams', 'email': 'wilbur@app.activiti.com' }, - 'created': '2016-11-03T15:25:42.749+0000', - 'dueDate': null, - 'endDate': null, - 'duration': null, - 'priority': 50, - 'parentTaskId': null, - 'parentTaskName': null, - 'processInstanceId': null, - 'processInstanceName': null, - 'processDefinitionId': null, - 'processDefinitionName': null, - 'processDefinitionDescription': null, - 'processDefinitionKey': null, - 'processDefinitionCategory': null, - 'processDefinitionVersion': null, - 'processDefinitionDeploymentId': null, - 'formKey': null, - 'processInstanceStartUserId': null, - 'initiatorCanCompleteTask': false, - 'adhocTaskCanBeReassigned': false, - 'taskDefinitionKey': 'sid-DDECD9E4-0299-433F-9193-C3D905C3EEBE', - 'executionId': '86', - 'involvedGroups': [], - 'involvedPeople': [], - 'memberOfCandidateUsers': false, - 'managerOfCandidateGroup': false, - 'memberOfCandidateGroup': false + id: '200', + name: 'Standalone Task Without Form', + description: null, + category: null, + assignee: { + id: 1001, + firstName: 'Wilbur', + lastName: 'Adams', + email: 'wilbur@app.activiti.com' + }, + created: '2016-11-03T15:25:42.749+0000', + dueDate: null, + endDate: null, + duration: null, + priority: 50, + parentTaskId: null, + parentTaskName: null, + processInstanceId: null, + processInstanceName: null, + processDefinitionId: null, + processDefinitionName: null, + processDefinitionDescription: null, + processDefinitionKey: null, + processDefinitionCategory: null, + processDefinitionVersion: null, + processDefinitionDeploymentId: null, + formKey: null, + processInstanceStartUserId: null, + initiatorCanCompleteTask: false, + adhocTaskCanBeReassigned: false, + taskDefinitionKey: 'sid-DDECD9E4-0299-433F-9193-C3D905C3EEBE', + executionId: '86', + involvedGroups: [], + involvedPeople: [], + memberOfCandidateUsers: false, + managerOfCandidateGroup: false, + memberOfCandidateGroup: false }); export let taskDetailsMock = new TaskDetailsModel({ - 'id': '91', - 'name': 'Request translation', - 'description': null, - 'category': null, - 'assignee': { 'id': 1001, 'firstName': 'Wilbur', 'lastName': 'Adams', 'email': 'wilbur@app.activiti.com' }, - 'created': '2016-11-03T15:25:42.749+0000', - 'dueDate': null, - 'endDate': null, - 'duration': null, - 'priority': 50, - 'parentTaskId': null, - 'parentTaskName': null, - 'processInstanceId': '86', - 'processInstanceName': null, - 'processDefinitionId': 'TranslationProcess:2:8', - 'processDefinitionName': 'Translation Process', - 'processDefinitionDescription': null, - 'processDefinitionKey': 'TranslationProcess', - 'processDefinitionCategory': 'http://www.activiti.org/processdef', - 'processDefinitionVersion': 2, - 'processDefinitionDeploymentId': '5', - 'formKey': '4', - 'processInstanceStartUserId': '1001', - 'initiatorCanCompleteTask': false, - 'adhocTaskCanBeReassigned': false, - 'taskDefinitionKey': 'sid-DDECD9E4-0299-433F-9193-C3D905C3EEBE', - 'executionId': '86', - 'involvedGroups': [], - 'involvedPeople': [], - 'memberOfCandidateUsers': false, - 'managerOfCandidateGroup': false, - 'memberOfCandidateGroup': false + id: '91', + name: 'Request translation', + description: null, + category: null, + assignee: { + id: 1001, + firstName: 'Wilbur', + lastName: 'Adams', + email: 'wilbur@app.activiti.com' + }, + created: '2016-11-03T15:25:42.749+0000', + dueDate: null, + endDate: null, + duration: null, + priority: 50, + parentTaskId: null, + parentTaskName: null, + processInstanceId: '86', + processInstanceName: null, + processDefinitionId: 'TranslationProcess:2:8', + processDefinitionName: 'Translation Process', + processDefinitionDescription: null, + processDefinitionKey: 'TranslationProcess', + processDefinitionCategory: 'http://www.activiti.org/processdef', + processDefinitionVersion: 2, + processDefinitionDeploymentId: '5', + formKey: '4', + processInstanceStartUserId: '1001', + initiatorCanCompleteTask: false, + adhocTaskCanBeReassigned: false, + taskDefinitionKey: 'sid-DDECD9E4-0299-433F-9193-C3D905C3EEBE', + executionId: '86', + involvedGroups: [], + involvedPeople: [], + memberOfCandidateUsers: false, + managerOfCandidateGroup: false, + memberOfCandidateGroup: false }); export let taskDetailsWithOutAssigneeMock = new TaskDetailsModel({ - 'id': '91', - 'name': 'Request translation', - 'description': null, - 'category': null, - 'assignee': undefined, - 'created': '2016-11-03T15:25:42.749+0000', - 'dueDate': null, - 'endDate': null, - 'duration': null, - 'priority': 50, - 'parentTaskId': null, - 'parentTaskName': null, - 'processInstanceId': '86', - 'processInstanceName': null, - 'processDefinitionId': 'TranslationProcess:2:8', - 'processDefinitionName': 'Translation Process', - 'processDefinitionDescription': null, - 'processDefinitionKey': 'TranslationProcess', - 'processDefinitionCategory': 'http://www.activiti.org/processdef', - 'processDefinitionVersion': 2, - 'processDefinitionDeploymentId': '5', - 'formKey': '4', - 'processInstanceStartUserId': '1001', - 'initiatorCanCompleteTask': false, - 'adhocTaskCanBeReassigned': false, - 'taskDefinitionKey': 'sid-DDECD9E4-0299-433F-9193-C3D905C3EEBE', - 'executionId': '86', - 'involvedGroups': [], - 'involvedPeople': [], - 'memberOfCandidateUsers': false, - 'managerOfCandidateGroup': false, - 'memberOfCandidateGroup': false + id: '91', + name: 'Request translation', + description: null, + category: null, + assignee: undefined, + created: '2016-11-03T15:25:42.749+0000', + dueDate: null, + endDate: null, + duration: null, + priority: 50, + parentTaskId: null, + parentTaskName: null, + processInstanceId: '86', + processInstanceName: null, + processDefinitionId: 'TranslationProcess:2:8', + processDefinitionName: 'Translation Process', + processDefinitionDescription: null, + processDefinitionKey: 'TranslationProcess', + processDefinitionCategory: 'http://www.activiti.org/processdef', + processDefinitionVersion: 2, + processDefinitionDeploymentId: '5', + formKey: '4', + processInstanceStartUserId: '1001', + initiatorCanCompleteTask: false, + adhocTaskCanBeReassigned: false, + taskDefinitionKey: 'sid-DDECD9E4-0299-433F-9193-C3D905C3EEBE', + executionId: '86', + involvedGroups: [], + involvedPeople: [], + memberOfCandidateUsers: false, + managerOfCandidateGroup: false, + memberOfCandidateGroup: false }); export let claimableTaskDetailsMock = new TaskDetailsModel({ - 'id': '91', - 'name': 'Request translation', - 'description': null, - 'category': null, - 'assignee': null, - 'created': '2016-11-03T15:25:42.749+0000', - 'dueDate': null, - 'endDate': null, - 'duration': null, - 'priority': 50, - 'parentTaskId': null, - 'parentTaskName': null, - 'processInstanceId': '86', - 'processInstanceName': null, - 'processDefinitionId': 'TranslationProcess:2:8', - 'processDefinitionName': 'Translation Process', - 'involvedGroups': [{ 'id': 7007, 'name': 'group1', 'externalId': null, 'status': 'active', 'groups': null }, - { 'id': 8008, 'name': 'group2', 'externalId': null, 'status': 'active', 'groups': null }], - 'involvedPeople': [], - 'managerOfCandidateGroup': true, - 'memberOfCandidateGroup': true, - 'memberOfCandidateUsers': false + id: '91', + name: 'Request translation', + description: null, + category: null, + assignee: null, + created: '2016-11-03T15:25:42.749+0000', + dueDate: null, + endDate: null, + duration: null, + priority: 50, + parentTaskId: null, + parentTaskName: null, + processInstanceId: '86', + processInstanceName: null, + processDefinitionId: 'TranslationProcess:2:8', + processDefinitionName: 'Translation Process', + involvedGroups: [ + { + id: 7007, + name: 'group1', + externalId: null, + status: 'active', + groups: null + }, + { + id: 8008, + name: 'group2', + externalId: null, + status: 'active', + groups: null + } + ], + involvedPeople: [], + managerOfCandidateGroup: true, + memberOfCandidateGroup: true, + memberOfCandidateUsers: false }); export let claimedTaskDetailsMock = new TaskDetailsModel({ - 'id': '91', - 'name': 'Request translation', - 'description': null, - 'category': null, - 'assignee': { 'id': 1001, 'firstName': 'Wilbur', 'lastName': 'Adams', 'email': 'wilbur@app.activiti.com' }, - 'created': '2016-11-03T15:25:42.749+0000', - 'dueDate': null, - 'endDate': null, - 'duration': null, - 'priority': 50, - 'parentTaskId': null, - 'parentTaskName': null, - 'processInstanceId': '86', - 'processInstanceName': null, - 'processDefinitionId': 'TranslationProcess:2:8', - 'processDefinitionName': 'Translation Process', - 'involvedGroups': [{ 'id': 7007, 'name': 'group1', 'externalId': null, 'status': 'active', 'groups': null }], - 'involvedPeople': [{ 'id': 1001, 'firstName': 'Wilbur', 'lastName': 'Adams', 'email': 'wilbur@app.activiti.com' }, - { 'id': 111, 'firstName': 'fake-first-name', 'lastName': 'fake-last-name', 'email': 'fake@app.activiti.com' }], - 'managerOfCandidateGroup': true, - 'memberOfCandidateGroup': true, - 'memberOfCandidateUsers': true + id: '91', + name: 'Request translation', + description: null, + category: null, + assignee: { + id: 1001, + firstName: 'Wilbur', + lastName: 'Adams', + email: 'wilbur@app.activiti.com' + }, + created: '2016-11-03T15:25:42.749+0000', + dueDate: null, + endDate: null, + duration: null, + priority: 50, + parentTaskId: null, + parentTaskName: null, + processInstanceId: '86', + processInstanceName: null, + processDefinitionId: 'TranslationProcess:2:8', + processDefinitionName: 'Translation Process', + involvedGroups: [ + { + id: 7007, + name: 'group1', + externalId: null, + status: 'active', + groups: null + } + ], + involvedPeople: [ + { + id: 1001, + firstName: 'Wilbur', + lastName: 'Adams', + email: 'wilbur@app.activiti.com' + }, + { + id: 111, + firstName: 'fake-first-name', + lastName: 'fake-last-name', + email: 'fake@app.activiti.com' + } + ], + managerOfCandidateGroup: true, + memberOfCandidateGroup: true, + memberOfCandidateUsers: true }); export let claimedByGroupMemberMock = new TaskDetailsModel({ - 'id': '91', - 'name': 'Request translation', - 'description': null, - 'category': null, - 'assignee': { - 'id': 111, - 'firstName': 'fake-first-name', - 'lastName': 'fake-last-name', - 'email': 'fake@app.activiti.com' + id: '91', + name: 'Request translation', + description: null, + category: null, + assignee: { + id: 111, + firstName: 'fake-first-name', + lastName: 'fake-last-name', + email: 'fake@app.activiti.com' }, - 'created': '2016-11-03T15:25:42.749+0000', - 'dueDate': null, - 'endDate': null, - 'duration': null, - 'priority': 50, - 'parentTaskId': null, - 'parentTaskName': null, - 'processInstanceId': '86', - 'processInstanceName': null, - 'processDefinitionId': 'TranslationProcess:2:8', - 'processDefinitionName': 'Translation Process', - 'involvedGroups': [{ 'id': 7007, 'name': 'group1', 'externalId': null, 'status': 'active', 'groups': null }], - 'involvedPeople': [{ 'id': 1001, 'firstName': 'Wilbur', 'lastName': 'Adams', 'email': 'wilbur@app.activiti.com' }, - { 'id': 111, 'firstName': 'fake-first-name', 'lastName': 'fake-last-name', 'email': 'fake@app.activiti.com' }], - 'managerOfCandidateGroup': true, - 'memberOfCandidateGroup': true, - 'memberOfCandidateUsers': true + created: '2016-11-03T15:25:42.749+0000', + dueDate: null, + endDate: null, + duration: null, + priority: 50, + parentTaskId: null, + parentTaskName: null, + processInstanceId: '86', + processInstanceName: null, + processDefinitionId: 'TranslationProcess:2:8', + processDefinitionName: 'Translation Process', + involvedGroups: [ + { + id: 7007, + name: 'group1', + externalId: null, + status: 'active', + groups: null + } + ], + involvedPeople: [ + { + id: 1001, + firstName: 'Wilbur', + lastName: 'Adams', + email: 'wilbur@app.activiti.com' + }, + { + id: 111, + firstName: 'fake-first-name', + lastName: 'fake-last-name', + email: 'fake@app.activiti.com' + } + ], + managerOfCandidateGroup: true, + memberOfCandidateGroup: true, + memberOfCandidateUsers: true }); export let taskDetailsWithOutCandidateGroup = new TaskDetailsModel({ - 'id': '91', - 'name': 'Request translation', - 'description': null, - 'category': null, - 'assignee': { 'id': 1001, 'firstName': 'Wilbur', 'lastName': 'Adams', 'email': 'wilbur@app.activiti.com' }, - 'created': '2016-11-03T15:25:42.749+0000', - 'dueDate': null, - 'endDate': null, - 'duration': null, - 'priority': 50, - 'parentTaskId': null, - 'parentTaskName': null, - 'processInstanceId': null, - 'processInstanceName': null, - 'processDefinitionId': 'TranslationProcess:2:8', - 'processDefinitionName': 'Translation Process', - 'managerOfCandidateGroup': false, - 'memberOfCandidateGroup': false, - 'memberOfCandidateUsers': false, - 'involvedGroups': [], - 'involvedPeople': [{ 'id': 1001, 'firstName': 'Wilbur', 'lastName': 'Adams', 'email': 'wilbur@app.activiti.com' }, - { 'id': 111, 'firstName': 'fake-first-name', 'lastName': 'fake-last-name', 'email': 'fake@app.activiti.com' }] + id: '91', + name: 'Request translation', + description: null, + category: null, + assignee: { + id: 1001, + firstName: 'Wilbur', + lastName: 'Adams', + email: 'wilbur@app.activiti.com' + }, + created: '2016-11-03T15:25:42.749+0000', + dueDate: null, + endDate: null, + duration: null, + priority: 50, + parentTaskId: null, + parentTaskName: null, + processInstanceId: null, + processInstanceName: null, + processDefinitionId: 'TranslationProcess:2:8', + processDefinitionName: 'Translation Process', + managerOfCandidateGroup: false, + memberOfCandidateGroup: false, + memberOfCandidateUsers: false, + involvedGroups: [], + involvedPeople: [ + { + id: 1001, + firstName: 'Wilbur', + lastName: 'Adams', + email: 'wilbur@app.activiti.com' + }, + { + id: 111, + firstName: 'fake-first-name', + lastName: 'fake-last-name', + email: 'fake@app.activiti.com' + } + ] }); export let completedTaskDetailsMock = new TaskDetailsModel({ - 'id': '91', - 'name': 'Request translation', - 'description': null, - 'category': null, - 'assignee': { 'id': 1001, 'firstName': 'Wilbur', 'lastName': 'Adams', 'email': 'wilbur@app.activiti.com' }, - 'created': '2016-11-03T15:25:42.749+0000', - 'dueDate': null, - 'endDate': '2016-11-03T15:25:42.749+0000', - 'duration': null, - 'priority': 50, - 'parentTaskId': null, - 'parentTaskName': null, - 'processInstanceId': '86', - 'processInstanceName': null, - 'processDefinitionId': 'TranslationProcess:2:8', - 'processDefinitionName': 'Translation Process', - 'involvedGroups': [], - 'involvedPeople': [], - 'managerOfCandidateGroup': true, - 'memberOfCandidateGroup': true, - 'memberOfCandidateUsers': false + id: '91', + name: 'Request translation', + description: null, + category: null, + assignee: { + id: 1001, + firstName: 'Wilbur', + lastName: 'Adams', + email: 'wilbur@app.activiti.com' + }, + created: '2016-11-03T15:25:42.749+0000', + dueDate: null, + endDate: '2016-11-03T15:25:42.749+0000', + duration: null, + priority: 50, + parentTaskId: null, + parentTaskName: null, + processInstanceId: '86', + processInstanceName: null, + processDefinitionId: 'TranslationProcess:2:8', + processDefinitionName: 'Translation Process', + involvedGroups: [], + involvedPeople: [], + managerOfCandidateGroup: true, + memberOfCandidateGroup: true, + memberOfCandidateUsers: false }); -export let taskFormMock = new TaskDetailsModel({ - 'id': 4, - 'name': 'Translation request', - 'processDefinitionId': 'TranslationProcess:2:8', - 'processDefinitionName': 'Translation Process', - 'processDefinitionKey': 'TranslationProcess', - 'taskId': '91', - 'taskName': 'Request translation', - 'taskDefinitionKey': 'sid-DDECD9E4-0299-433F-9193-C3D905C3EEBE', - 'tabs': [], - 'fields': [{ - 'fieldType': 'ContainerRepresentation', - 'id': '1478093984155', - 'name': 'Label', - 'type': 'container', - 'value': null, - 'required': false, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'dateDisplayFormat': null, - 'layout': null, - 'sizeX': 2, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'numberOfColumns': 2, - 'fields': { - '1': [{ - 'fieldType': 'AttachFileFieldRepresentation', - 'id': 'originalcontent', - 'name': 'Original content', - 'type': 'upload', - 'value': [], - 'required': true, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': null, - 'options': null, - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'params': {}, - 'dateDisplayFormat': null, - 'layout': { 'row': -1, 'column': -1, 'colspan': 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'metaDataColumnDefinitions': [] - }], - '2': [{ - 'fieldType': 'RestFieldRepresentation', - 'id': 'language', - 'name': 'Language', - 'type': 'dropdown', - 'value': 'Choose one...', - 'required': true, - 'readOnly': false, - 'overrideId': false, - 'colspan': 1, - 'placeholder': null, - 'minLength': 0, - 'maxLength': 0, - 'minValue': null, - 'maxValue': null, - 'regexPattern': null, - 'optionType': null, - 'hasEmptyValue': true, - 'options': [{ 'id': 'empty', 'name': 'Choose one...' }, { 'id': 'fr', 'name': 'French' }, { - 'id': 'de', - 'name': 'German' - }, { 'id': 'es', 'name': 'Spanish' }], - 'restUrl': null, - 'restResponsePath': null, - 'restIdProperty': null, - 'restLabelProperty': null, - 'tab': null, - 'className': null, - 'params': { 'existingColspan': 1, 'maxColspan': 1 }, - 'dateDisplayFormat': null, - 'layout': { 'row': -1, 'column': -1, 'colspan': 1 }, - 'sizeX': 1, - 'sizeY': 1, - 'row': -1, - 'col': -1, - 'visibilityCondition': null, - 'endpoint': null, - 'requestHeaders': null - }] - } - }], - 'outcomes': [], - 'javascriptEvents': [], - 'className': '', - 'style': '', - 'customFieldTemplates': {}, - 'metadata': {}, - 'variables': [], - 'gridsterForm': false, - 'globalDateFormat': 'D-M-YYYY' -}); +export const taskFormMock = { + id: 4, + name: 'Translation request', + processDefinitionId: 'TranslationProcess:2:8', + processDefinitionName: 'Translation Process', + processDefinitionKey: 'TranslationProcess', + taskId: '91', + taskDefinitionKey: 'sid-DDECD9E4-0299-433F-9193-C3D905C3EEBE', + tabs: [], + fields: [ + { + fieldType: 'ContainerRepresentation', + id: '1582747048995', + name: 'Label', + type: 'container', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + dateDisplayFormat: null, + layout: null, + sizeX: 2, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + numberOfColumns: 2, + fields: { + '1': [ + { + fieldType: 'FormFieldRepresentation', + id: 'text1', + name: 'Text1', + type: 'text', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { existingColspan: 1, maxColspan: 2 }, + dateDisplayFormat: null, + layout: { row: -1, column: -1, colspan: 1 }, + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null + } + ], + '2': [ + { + fieldType: 'FormFieldRepresentation', + id: 'text2', + name: 'Text2', + type: 'text', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { existingColspan: 1, maxColspan: 1 }, + dateDisplayFormat: null, + layout: { row: -1, column: -1, colspan: 1 }, + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null + } + ] + } + }, + { + fieldType: 'ContainerRepresentation', + id: '1582747052793', + name: 'Label', + type: 'container', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + dateDisplayFormat: null, + layout: null, + sizeX: 2, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null, + numberOfColumns: 2, + fields: { + '1': [ + { + fieldType: 'FormFieldRepresentation', + id: 'text3', + name: 'Text3', + type: 'text', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { existingColspan: 1, maxColspan: 2 }, + dateDisplayFormat: null, + layout: { row: -1, column: -1, colspan: 1 }, + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: { + leftFormFieldId: 'text1', + leftRestResponseId: null, + operator: '==', + rightValue: '', + rightType: null, + rightFormFieldId: 'text2', + rightRestResponseId: '', + nextConditionOperator: '', + nextCondition: null + } + } + ], + '2': [ + { + fieldType: 'FormFieldRepresentation', + id: 'numberField', + name: 'numberField', + type: 'integer', + value: null, + required: false, + readOnly: false, + overrideId: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + minValue: null, + maxValue: null, + regexPattern: null, + optionType: null, + hasEmptyValue: null, + options: null, + restUrl: null, + restResponsePath: null, + restIdProperty: null, + restLabelProperty: null, + tab: null, + className: null, + params: { + existingColspan: 1, + maxColspan: 1 + }, + dateDisplayFormat: null, + layout: { + row: -1, + column: -1, + colspan: 1 + }, + sizeX: 1, + sizeY: 1, + row: -1, + col: -1, + visibilityCondition: null + } + ] + } + } + ], + outcomes: [], + javascriptEvents: [], + className: '', + style: '', + customFieldTemplates: {}, + metadata: {}, + variables: [], + customFieldsValueInfo: {}, + gridsterForm: false, + globalDateFormat: 'D-M-YYYY' + }; export let tasksMock = [new TaskDetailsModel(taskDetailsMock)]; -export let noDataMock = [new TaskDetailsModel({ - 'id': 1005, - 'message': 'example-message', - 'created': '2017-10-06T11:54:53.443+0000', - 'createdBy': { 'id': 4004, 'firstName': 'gadget', 'lastName': 'inspector', 'email': 'gadget@inspector.com' } -})]; +export let noDataMock = [ + new TaskDetailsModel({ + id: 1005, + message: 'example-message', + created: '2017-10-06T11:54:53.443+0000', + createdBy: { + id: 4004, + firstName: 'gadget', + lastName: 'inspector', + email: 'gadget@inspector.com' + } + }) +]; diff --git a/lib/process-services/src/lib/task-list/components/task-details.component.spec.ts b/lib/process-services/src/lib/task-list/components/task-details.component.spec.ts index af54cb358b..b6d438c2ee 100644 --- a/lib/process-services/src/lib/task-list/components/task-details.component.spec.ts +++ b/lib/process-services/src/lib/task-list/components/task-details.component.spec.ts @@ -28,7 +28,9 @@ import { BpmUserService, CommentProcessService, LogService, AuthenticationService, UserProcessModel, - PeopleProcessService + PeopleProcessService, + TranslationMock, + TranslationService } from '@alfresco/adf-core'; import { TaskDetailsModel } from '../models/task-details.model'; import { @@ -42,7 +44,9 @@ import { } from '../../mock'; import { TaskListService } from './../services/tasklist.service'; import { TaskDetailsComponent } from './task-details.component'; -import { ProcessTestingModule } from '../../testing/process.testing.module'; +import { TaskListModule } from '../task-list.module'; +import { TranslateStore } from '@ngx-translate/core'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; const fakeUser: UserProcessModel = new UserProcessModel({ id: 'fake-id', @@ -68,8 +72,12 @@ describe('TaskDetailsComponent', () => { setupTestBed({ imports: [ - ProcessTestingModule + NoopAnimationsModule, + TaskListModule ], + providers: [ + { provide: TranslationService, useClass: TranslationMock }, + TranslateStore], schemas: [NO_ERRORS_SCHEMA] }); @@ -221,6 +229,86 @@ describe('TaskDetailsComponent', () => { }); })); + describe('and form with visiblity', () => { + + beforeEach(async () => { + component.taskId = '123'; + spyOn(formService, 'completeTaskForm').and.returnValue(of({})); + taskDetailsMock.formKey = '4'; + getTaskDetailsSpy.and.returnValue(of(taskDetailsMock)); + fixture.detectChanges(); + await fixture.whenStable(); + }); + + it('[C312410] - Should be possible to complete a task that has an invisible field on a form with a value', async (done) => { + component.formCompleted.subscribe((form: FormModel) => { + expect(form.id).toBe(taskFormMock.id); + done(); + }); + component.taskDetails.initiatorCanCompleteTask = true; + component.showNextTask = false; + + fixture.detectChanges(); + await fixture.whenStable(); + const inputTextOne: HTMLInputElement = fixture.nativeElement.querySelector('#text1'); + expect(inputTextOne).toBeDefined(); + expect(inputTextOne).not.toBeNull(); + const inputTextTwo: HTMLInputElement = fixture.nativeElement.querySelector('#text2'); + expect(inputTextTwo).toBeDefined(); + expect(inputTextTwo).not.toBeNull(); + let inputTextThree: HTMLInputElement = fixture.nativeElement.querySelector('#text3'); + expect(inputTextThree).toBeDefined(); + expect(inputTextThree).not.toBeNull(); + + inputTextOne.value = 'a'; + inputTextOne.dispatchEvent(new Event('input')); + inputTextTwo.value = 'a'; + inputTextTwo.dispatchEvent(new Event('input')); + inputTextThree.value = 'a'; + inputTextThree.dispatchEvent(new Event('input')); + fixture.detectChanges(); + await fixture.whenStable(); + inputTextThree = fixture.nativeElement.querySelector('#text3'); + expect(inputTextThree).toBeDefined(); + expect(inputTextThree).not.toBeNull(); + + inputTextOne.value = 'b'; + inputTextOne.dispatchEvent(new Event('input')); + fixture.detectChanges(); + await fixture.whenStable(); + const inputThreeContainer = fixture.nativeElement.querySelector('#field-text3-container'); + expect(inputThreeContainer.hidden).toBe(true); + const completeOutcomeButton: HTMLButtonElement = fixture.nativeElement.querySelector('#adf-form-complete'); + expect(completeOutcomeButton.hidden).toBe(false); + completeOutcomeButton.click(); + fixture.detectChanges(); + }); + + it('[C277278] - Should show if the form is valid via the validation icon', async () => { + const numberInput: HTMLInputElement = fixture.nativeElement.querySelector('#numberField'); + let validationForm = fixture.nativeElement.querySelector('#adf-valid-form-icon'); + + expect(numberInput).toBeDefined(); + expect(numberInput).not.toBeNull(); + expect(validationForm.textContent).toBe('check_circle'); + + numberInput.value = 'a'; + numberInput.dispatchEvent(new Event('input')); + fixture.detectChanges(); + await fixture.whenStable(); + const invalidForm = fixture.nativeElement.querySelector('#adf-invalid-form-icon'); + expect(invalidForm).not.toBeNull(); + expect(invalidForm.textContent).toBe('error'); + + numberInput.value = '4'; + numberInput.dispatchEvent(new Event('input')); + fixture.detectChanges(); + await fixture.whenStable(); + validationForm = fixture.nativeElement.querySelector('#adf-valid-form-icon'); + expect(validationForm.textContent).toBe('check_circle'); + }); + }); + describe('change detection', () => { let change; diff --git a/lib/process-services/src/lib/task-list/components/task-filters.component.spec.ts b/lib/process-services/src/lib/task-list/components/task-filters.component.spec.ts index 95e615c36c..5864d8fb90 100644 --- a/lib/process-services/src/lib/task-list/components/task-filters.component.spec.ts +++ b/lib/process-services/src/lib/task-list/components/task-filters.component.spec.ts @@ -68,8 +68,6 @@ describe('TaskFiltersComponent', () => { error: 'wrong request' }; - const mockErrorFilterPromise = Promise.reject(mockErrorFilterList); - let component: TaskFiltersComponent; let fixture: ComponentFixture; @@ -92,6 +90,7 @@ describe('TaskFiltersComponent', () => { }); it('should emit an error with a bad response', (done) => { + const mockErrorFilterPromise = Promise.reject(mockErrorFilterList); spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(from(mockErrorFilterPromise)); const appId = '1';