mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACA-4479][ACA-4480] - Enable Save button when the form is invalid (#7131)
* [ACA-4479][ACA-4480] - Enable Save button when the form is invalid * Add a unit test for form cloud * Fix e2e
This commit is contained in:
@@ -110,11 +110,11 @@ describe('People and Group of people Widgets', () => {
|
|||||||
await expect (activePeopleField).toBe(false);
|
await expect (activePeopleField).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('[C325004] Should be able to save only for valid input in the People field if the Required option is selected ', async () => {
|
it('[C325004] Should save button be enabled for both valid and invalid inputs in the People field', async () => {
|
||||||
await formCloudComponentPage.setConfigToEditor(peopleRequiredFormMock);
|
await formCloudComponentPage.setConfigToEditor(peopleRequiredFormMock);
|
||||||
|
|
||||||
await peopleCloudWidget.isPeopleWidgetVisible(peopleValueString.peopleCloudWidgetRequiredField);
|
await peopleCloudWidget.isPeopleWidgetVisible(peopleValueString.peopleCloudWidgetRequiredField);
|
||||||
await expect(await formPage.isSaveButtonDisabled()).toBe(true);
|
await expect(await formPage.isSaveButtonDisabled()).toBe(false);
|
||||||
await expect(await formPage.isValidationIconRed()).toBe(true);
|
await expect(await formPage.isValidationIconRed()).toBe(true);
|
||||||
|
|
||||||
const requiredPeople = await peopleCloudWidget.getFieldValue(widgets.peopleCloudWidgetRequiredId);
|
const requiredPeople = await peopleCloudWidget.getFieldValue(widgets.peopleCloudWidgetRequiredId);
|
||||||
@@ -163,11 +163,11 @@ describe('People and Group of people Widgets', () => {
|
|||||||
await expect (activeGroupField).toBe(false);
|
await expect (activeGroupField).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('[C325005] Should be able to save only for valid input in the Group of people field if the Required option is selected', async () => {
|
it('[C325005] Should save button be enabled for both valid and invalid inputs in the Group of people field', async () => {
|
||||||
await formCloudComponentPage.setConfigToEditor(groupRequiredFormMock);
|
await formCloudComponentPage.setConfigToEditor(groupRequiredFormMock);
|
||||||
|
|
||||||
await groupCloudWidget.isGroupWidgetVisible(groupValueString.groupCloudWidgetRequiredField);
|
await groupCloudWidget.isGroupWidgetVisible(groupValueString.groupCloudWidgetRequiredField);
|
||||||
await expect(await formPage.isSaveButtonDisabled()).toBe(true);
|
await expect(await formPage.isSaveButtonDisabled()).toBe(false);
|
||||||
await expect(await formPage.isValidationIconRed()).toBe(true);
|
await expect(await formPage.isValidationIconRed()).toBe(true);
|
||||||
|
|
||||||
const groupRequired = await groupCloudWidget.getGroupsFieldContent();
|
const groupRequired = await groupCloudWidget.getGroupsFieldContent();
|
||||||
|
@@ -88,23 +88,16 @@ describe('Date and time widget', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('[C268819] Should be able to set advanced settings for Date Time widget ', async () => {
|
it('[C268819] Should be able to set advanced settings for Date Time widget ', async () => {
|
||||||
await widget.dateTimeWidget().openDatepicker(app.FIELD.date_time_between_input);
|
|
||||||
await widget.dateTimeWidget().closeDataTimeWidget();
|
|
||||||
|
|
||||||
await widget.dateTimeWidget().setDateTimeInput(app.FIELD.date_time_between_input, '20-03-17 07:30 PM');
|
await widget.dateTimeWidget().setDateTimeInput(app.FIELD.date_time_between_input, '20-03-17 07:30 PM');
|
||||||
await taskPage.formFields().saveForm();
|
|
||||||
await expect(await widget.dateTimeWidget().getErrorMessage(app.FIELD.date_time_between_input)).toContain('Can\'t be less than');
|
|
||||||
|
|
||||||
await widget.dateTimeWidget().openDatepicker(app.FIELD.date_time_between_input);
|
|
||||||
await widget.dateTimeWidget().closeDataTimeWidget();
|
await widget.dateTimeWidget().closeDataTimeWidget();
|
||||||
await widget.dateTimeWidget().removeFromDatetimeWidget(app.FIELD.date_time_between_input);
|
await taskPage.formFields().completeForm();
|
||||||
|
await expect(await widget.dateTimeWidget().getErrorMessage(app.FIELD.date_time_between_input)).toContain('Can\'t be less than');
|
||||||
|
|
||||||
await browser.refresh();
|
await browser.refresh();
|
||||||
|
|
||||||
await widget.dateTimeWidget().setDateTimeInput(app.FIELD.date_time_between_input, '20-03-19 07:30 PM');
|
await widget.dateTimeWidget().setDateTimeInput(app.FIELD.date_time_between_input, '20-03-19 07:30 PM');
|
||||||
await widget.dateTimeWidget().closeDataTimeWidget();
|
await widget.dateTimeWidget().closeDataTimeWidget();
|
||||||
|
await taskPage.formFields().completeForm();
|
||||||
await taskPage.formFields().saveForm();
|
|
||||||
|
|
||||||
await expect(await widget.dateTimeWidget().getErrorMessage(app.FIELD.date_time_between_input)).toContain('Can\'t be greater than');
|
await expect(await widget.dateTimeWidget().getErrorMessage(app.FIELD.date_time_between_input)).toContain('Can\'t be greater than');
|
||||||
});
|
});
|
||||||
|
@@ -123,7 +123,7 @@ export abstract class FormBaseComponent {
|
|||||||
|
|
||||||
if (outcome) {
|
if (outcome) {
|
||||||
if (outcome.name === FormOutcomeModel.SAVE_ACTION) {
|
if (outcome.name === FormOutcomeModel.SAVE_ACTION) {
|
||||||
return this.disableSaveButton ? false : this.form.isValid;
|
return !this.disableSaveButton;
|
||||||
}
|
}
|
||||||
if (outcome.name === FormOutcomeModel.COMPLETE_ACTION) {
|
if (outcome.name === FormOutcomeModel.COMPLETE_ACTION) {
|
||||||
return this.disableCompleteButton ? false : this.form.isValid;
|
return this.disableCompleteButton ? false : this.form.isValid;
|
||||||
|
@@ -870,6 +870,15 @@ describe('FormCloudComponent', () => {
|
|||||||
expect(formComponent.isOutcomeButtonEnabled(saveOutcome)).toBeTruthy();
|
expect(formComponent.isOutcomeButtonEnabled(saveOutcome)).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should save outcome button be enabled when the form is invalid', () => {
|
||||||
|
const formModel = new FormModel(cloudFormMock);
|
||||||
|
formComponent.form = formModel;
|
||||||
|
formModel.isValid = false;
|
||||||
|
|
||||||
|
const saveOutcome = formComponent.form.outcomes.find((outcome) => outcome.name === FormOutcomeModel.SAVE_ACTION);
|
||||||
|
expect(formComponent.isOutcomeButtonEnabled(saveOutcome)).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
it('should disable start process outcome button when disableStartProcessButton is true', () => {
|
it('should disable start process outcome button when disableStartProcessButton is true', () => {
|
||||||
const formModel = new FormModel(cloudFormMock);
|
const formModel = new FormModel(cloudFormMock);
|
||||||
formComponent.form = formModel;
|
formComponent.form = formModel;
|
||||||
|
@@ -904,7 +904,7 @@ describe('FormComponent', () => {
|
|||||||
expect(formComponent.isOutcomeButtonEnabled(saveOutcome)).toBeFalsy();
|
expect(formComponent.isOutcomeButtonEnabled(saveOutcome)).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should disable save outcome button when the form is invalid', () => {
|
it('should save outcome button be enabled when the form is invalid', () => {
|
||||||
const formModel = new FormModel();
|
const formModel = new FormModel();
|
||||||
formComponent.form = formModel;
|
formComponent.form = formModel;
|
||||||
|
|
||||||
@@ -926,7 +926,7 @@ describe('FormComponent', () => {
|
|||||||
name: FormOutcomeModel.SAVE_ACTION
|
name: FormOutcomeModel.SAVE_ACTION
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(formComponent.isOutcomeButtonEnabled(saveOutcome)).toBeFalsy();
|
expect(formComponent.isOutcomeButtonEnabled(saveOutcome)).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should disable start process outcome button when disableStartProcessButton is true', () => {
|
it('should disable start process outcome button when disableStartProcessButton is true', () => {
|
||||||
|
Reference in New Issue
Block a user