mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
[DW-1563] Complete button is not present for empty forms (#5269)
* [DW-1563] Complete button is not present for empty forms * [DW-1563] Revert part of the changes * [DW-1563] Remove unnecessary variable declaration
This commit is contained in:
parent
202764631a
commit
b016bf8167
@ -26,7 +26,7 @@ import {
|
|||||||
import { ProcessServiceCloudTestingModule } from '../../testing/process-service-cloud.testing.module';
|
import { ProcessServiceCloudTestingModule } from '../../testing/process-service-cloud.testing.module';
|
||||||
import { FormCloudService } from '../services/form-cloud.service';
|
import { FormCloudService } from '../services/form-cloud.service';
|
||||||
import { FormCloudComponent } from './form-cloud.component';
|
import { FormCloudComponent } from './form-cloud.component';
|
||||||
import { cloudFormMock, fakeCloudForm } from '../mocks/cloud-form.mock';
|
import { cloudFormMock, emptyFormRepresentationJSON, fakeCloudForm } from '../mocks/cloud-form.mock';
|
||||||
import { FormCloudRepresentation } from '../models/form-cloud-representation.model';
|
import { FormCloudRepresentation } from '../models/form-cloud-representation.model';
|
||||||
|
|
||||||
describe('FormCloudComponent', () => {
|
describe('FormCloudComponent', () => {
|
||||||
@ -641,13 +641,6 @@ describe('FormCloudComponent', () => {
|
|||||||
expect(form.fields[0].id).toBe('field1');
|
expect(form.fields[0].id).toBe('field1');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should provide outcomes for form definition', () => {
|
|
||||||
spyOn(formComponent, 'getFormDefinitionOutcomes').and.callThrough();
|
|
||||||
|
|
||||||
const form = formComponent.parseForm({ id: '1' });
|
|
||||||
expect(formComponent.getFormDefinitionOutcomes).toHaveBeenCalledWith(form);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should prevent default outcome execution', () => {
|
it('should prevent default outcome execution', () => {
|
||||||
|
|
||||||
const outcome = new FormOutcomeModel(<any> new FormModel(), {
|
const outcome = new FormOutcomeModel(<any> new FormModel(), {
|
||||||
@ -733,6 +726,13 @@ describe('FormCloudComponent', () => {
|
|||||||
expect(formComponent.isOutcomeButtonEnabled(completeOutcome)).toBeTruthy();
|
expect(formComponent.isOutcomeButtonEnabled(completeOutcome)).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should complete outcome button be present when the form is empty', async () => {
|
||||||
|
formComponent.form = formComponent.parseForm(emptyFormRepresentationJSON);
|
||||||
|
expect(formComponent.form.isValid).toBeTruthy();
|
||||||
|
const completeOutcome = formComponent.form.outcomes.find((outcome) => outcome.name === FormOutcomeModel.COMPLETE_ACTION);
|
||||||
|
expect(formComponent.isOutcomeButtonEnabled(completeOutcome)).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
it('should disable save outcome button when disableSaveButton is true', () => {
|
it('should disable save outcome button when disableSaveButton is true', () => {
|
||||||
const formModel = new FormModel(cloudFormMock);
|
const formModel = new FormModel(cloudFormMock);
|
||||||
formComponent.form = formModel;
|
formComponent.form = formModel;
|
||||||
|
@ -300,7 +300,7 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,
|
|||||||
});
|
});
|
||||||
|
|
||||||
const form = new FormModel(formCloudRepresentationJSON, formValues, this.readOnly);
|
const form = new FormModel(formCloudRepresentationJSON, formValues, this.readOnly);
|
||||||
if (!form || !form.fields.length) {
|
if (!form) {
|
||||||
form.outcomes = this.getFormDefinitionOutcomes(form);
|
form.outcomes = this.getFormDefinitionOutcomes(form);
|
||||||
}
|
}
|
||||||
if (this.fieldValidators && this.fieldValidators.length > 0) {
|
if (this.fieldValidators && this.fieldValidators.length > 0) {
|
||||||
|
@ -739,3 +739,22 @@ export let fakeCloudForm = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const emptyFormRepresentationJSON = {
|
||||||
|
'description': '',
|
||||||
|
'fields': [],
|
||||||
|
'id': 'form-3de070b6-63df-4058-8028-ac82283d64fa',
|
||||||
|
'metadata': {},
|
||||||
|
'name': 'form',
|
||||||
|
'outcomes': [],
|
||||||
|
'length': 0,
|
||||||
|
'processDefinitionId': 'ed4a6233-0ad8-11ea-8616-e6267bbdb057',
|
||||||
|
'processInstanceId': 'ec921948-0ad9-11ea-8616-e6267bbdb057',
|
||||||
|
'processVariables': [],
|
||||||
|
'standAlone': true,
|
||||||
|
'tabs': [],
|
||||||
|
'taskId': 'ec92194b-0ad9-11ea-8616-e6267bbdb057',
|
||||||
|
'taskName': null,
|
||||||
|
'variables': [],
|
||||||
|
'version': 0
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user