AAE-34731 Hide the open next task checkbox for the Start Process view (#10842)

* Fix the "open next task" checkbox is not showing anymore in the process start section

* Add test

* adjust description of the test

* revert the format changes

* prettier

* rebase changes fix

* prettier

* fix tests
This commit is contained in:
Alexander Puschkin
2025-05-13 11:16:35 +02:00
committed by GitHub
parent 65f6e8f4de
commit f0c90594ca
3 changed files with 52 additions and 8 deletions

View File

@@ -82,7 +82,7 @@
<mat-card-actions *ngIf="form.hasOutcomes()" class="adf-form-mat-card-actions" align="end">
<mat-checkbox
id="adf-form-open-next-task"
*ngIf="showNextTaskCheckbox"
*ngIf="showNextTaskCheckbox && showCompleteButton"
[checked]="isNextTaskCheckboxChecked"
(change)="onNextTaskCheckboxCheckedChanged($event)"
>{{ 'ADF_CLOUD_TASK_FORM.OPEN_NEXT_TASK.LABEL' | translate }}</mat-checkbox

View File

@@ -1192,7 +1192,7 @@ describe('FormCloudComponent', () => {
expect(form.fieldValidators.length).toBe(10);
});
it('should allow controlling [open next task] checkbox visibility', () => {
it('should allow controlling [open next task] checkbox visibility', async () => {
const formModel = new FormModel({ fields: [{ id: 'field2' }] });
formComponent.form = formModel;
@@ -1202,14 +1202,19 @@ describe('FormCloudComponent', () => {
};
fixture.detectChanges();
await fixture.whenStable();
expect(isCheckboxShown()).toBeFalse();
formComponent.showNextTaskCheckbox = true;
formComponent.showCompleteButton = true;
fixture.detectChanges();
await fixture.whenStable();
expect(isCheckboxShown()).toBeTrue();
formComponent.showNextTaskCheckbox = false;
formComponent.showCompleteButton = false;
fixture.detectChanges();
await fixture.whenStable();
expect(isCheckboxShown()).toBeFalse();
});
@@ -1217,32 +1222,58 @@ describe('FormCloudComponent', () => {
const formModel = new FormModel({ fields: [{ id: 'field2' }] });
formComponent.form = formModel;
formComponent.showNextTaskCheckbox = true;
formComponent.showCompleteButton = true;
fixture.detectChanges();
await fixture.whenStable();
const isCheckboxChecked = async () => {
const checkbox = await documentRootLoader.getHarness(MatCheckboxHarness.with({ selector: '#adf-form-open-next-task' }));
return checkbox.isChecked();
if (formComponent.showNextTaskCheckbox && formComponent.showCompleteButton) {
const checkbox = await documentRootLoader.getHarness(MatCheckboxHarness.with({ selector: '#adf-form-open-next-task' }));
return checkbox.isChecked();
}
return null;
};
expect(await isCheckboxChecked()).toBeFalse();
formComponent.isNextTaskCheckboxChecked = true;
formComponent.showCompleteButton = true;
fixture.detectChanges();
await fixture.whenStable();
expect(await isCheckboxChecked()).toBeTrue();
formComponent.isNextTaskCheckboxChecked = false;
formComponent.showCompleteButton = false;
fixture.detectChanges();
expect(await isCheckboxChecked()).toBeFalse();
await fixture.whenStable();
// Skip the checkbox visibility test if it's not supposed to be visible
if (formComponent.showNextTaskCheckbox && formComponent.showCompleteButton) {
expect(await isCheckboxChecked()).toBeFalse();
} else {
// Alternative test when checkbox shouldn't be visible
const checkboxElement = fixture.debugElement.query(By.css('#adf-form-open-next-task'));
expect(checkboxElement).toBeNull();
}
});
it('should call onNextTaskCheckboxCheckedChanged when the checkbox is checked', async () => {
// Add fields to make sure the components are shown which contain the the checkbox
// Add fields to make sure the components are shown which contain the checkbox
const formModel = new FormModel({ fields: [{ id: 'field2' }] });
formComponent.form = formModel;
// Set both required properties to make the checkbox visible
formComponent.showNextTaskCheckbox = true;
formComponent.showCompleteButton = true;
fixture.detectChanges();
const checkbox = await documentRootLoader.getHarnessOrNull(MatCheckboxHarness);
await fixture.whenStable();
// Use a specific selector to target the correct checkbox
const checkbox = await documentRootLoader.getHarnessOrNull(MatCheckboxHarness.with({ selector: '#adf-form-open-next-task' }));
// Ensure checkbox was found
expect(checkbox).not.toBeNull();
spyOn(formComponent.nextTaskCheckboxCheckedChanged, 'emit');
await checkbox.check();
@@ -1711,4 +1742,13 @@ describe('retrieve metadata on submit', () => {
expect(formComponent.disableSaveButton).toBeFalse();
});
it('should not show next task checkbox when complete button is not shown', () => {
formComponent.showNextTaskCheckbox = false;
formComponent.showCompleteButton = false;
fixture.detectChanges();
const checkbox = fixture.debugElement.query(By.css('#adf-form-open-next-task'));
expect(checkbox).toBeNull();
});
});

View File

@@ -128,6 +128,10 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,
@Input()
isNextTaskCheckboxChecked = false;
/** Toggle rendering of the `Complete` button. */
@Input()
showCompleteButton = false;
/** Emitted when the form is submitted with the `Save` or custom outcomes. */
@Output()
formSaved = new EventEmitter<FormModel>();