AAE-35676 Cleanup Open Next Task (#10952)

* [ci:force] Cleanup

* [ci:force] cleanup

* [ci:force] Re-added tests & adjusted them

* [ci:force] Update user-task-cloud.component.spec.ts

* Fixes
This commit is contained in:
Fabian Kindgen
2025-07-08 15:16:57 +02:00
committed by GitHub
parent 5438eef9db
commit 6a3623bd76
16 changed files with 45 additions and 270 deletions

View File

@@ -85,13 +85,11 @@ The template defined inside `empty-form` will be shown when no form definition i
| fieldValidators | [`FormFieldValidator`](../../../lib/core/src/lib/form/components/widgets/core/form-field-validator.ts)`[]` | | [FormFieldValidator](../../../lib/core/src/lib/form/components/widgets/core/form-field-validator.ts) allow to override the form field validators provided. |
| form | [`FormModel`](../../../lib/core/src/lib/form/components/widgets/core/form.model.ts) | | Underlying form model instance. |
| formId | `string` | | Task id to fetch corresponding form and values. |
| isNextTaskCheckboxChecked | `boolean` | false | Whether the `Open next task` checkbox is checked by default or not. |
| nameNode | `string` | | Name to assign to the new node where the metadata are stored. |
| path | `string` | | Path of the folder where the metadata will be stored. |
| processInstanceId | `string` | | ProcessInstanceId id to fetch corresponding form and values. |
| readOnly | `boolean` | false | Toggle readonly state of the form. Forces all form widgets to render as readonly if enabled. |
| showCompleteButton | `boolean` | true | Toggle rendering of the `Complete` outcome button. |
| showNextTaskCheckbox | `boolean` | false | Toggle rendering of the `Open next task` checkbox. |
| showRefreshButton | `boolean` | true | Toggle rendering of the `Refresh` button. |
| showSaveButton | `boolean` | true | Toggle rendering of the `Save` outcome button. |
| showTitle | `boolean` | true | Toggle rendering of the form title. |

View File

@@ -37,11 +37,9 @@ Starts a process.
| Name | Type | Default value | Description |
| ---- | ---- | ------------- | ----------- |
| appName | `string` | "" | (required) Name of the app. |
| isNextTaskCheckboxChecked | `boolean` | false | Whether the `Open next task` checkbox is checked by default or not. |
| maxNameLength | `number` | MAX_NAME_LENGTH | Maximum length of the process name. |
| name | `string` | "" | Name of the process. |
| processDefinitionName | `string` | | Name of the process definition. |
| showNextTaskCheckbox | `boolean` | false | Toggle rendering of the `Open next task` checkbox. |
| showSelectProcessDropdown | `boolean` | true | Show/hide the process dropdown list. |
| showTitle | `boolean` | true | Show/hide title. |
| values | [`TaskVariableCloud`](../../../lib/process-services-cloud/src/lib/form/models/task-variable-cloud.model.ts)`[]` | | Parameter to pass form field values in the start form if one is associated. |
@@ -54,7 +52,6 @@ Starts a process.
| cancel | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`ProcessInstanceCloud`](../../../lib/process-services-cloud/src/lib/process/start-process/models/process-instance-cloud.model.ts)`>` | Emitted when the starting process is cancelled |
| error | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`ProcessInstanceCloud`](../../../lib/process-services-cloud/src/lib/process/start-process/models/process-instance-cloud.model.ts)`>` | Emitted when an error occurs. |
| formContentClicked | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`ContentLinkModel`](../../../lib/core/src/lib/form/components/widgets/core/content-link.model.ts)`>` | Emitted when form content is clicked. |
| nextTaskCheckboxCheckedChanged | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`MatCheckboxChange`](https://material.angular.io/components/checkbox/api#MatCheckboxChange)`>` | Emitted when the `Open next task` checkbox was toggled. |
| processDefinitionSelection | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`ProcessDefinitionCloud`](../../../lib/process-services-cloud/src/lib/models/process-definition-cloud.model.ts)`>` | Emitted when process definition selection changes. |
| success | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`ProcessInstanceCloud`](../../../lib/process-services-cloud/src/lib/process/start-process/models/process-instance-cloud.model.ts)`>` | Emitted when the process is successfully started. |

View File

@@ -36,11 +36,9 @@ Save and Complete buttons get disabled when at least one of the form's inputs ar
| Name | Type | Default value | Description |
| ------------------------- | ------------------------------------- | ------------- | ------------------------------------------------------------------- |
| appName | `string` | "" | App id to fetch corresponding form and values. |
| isNextTaskCheckboxChecked | `boolean` | false | Whether the `Open next task` checkbox is checked by default or not. |
| readOnly | `boolean` | false | Toggle readonly state of the task. |
| showCancelButton | `boolean` | true | Toggle rendering of the `Cancel` button. |
| showCompleteButton | `boolean` | true | Toggle rendering of the `Complete` button. |
| showNextTaskCheckbox | `boolean` | false | Toggle rendering of the `Open next task` checkbox. |
| showRefreshButton | `boolean` | false | Toggle rendering of the `Refresh` button. |
| showTitle | `boolean` | true | Toggle rendering of the form title. |
| showValidationIcon | `boolean` | true | Toggle rendering of the `Validation` icon. |
@@ -57,7 +55,6 @@ Save and Complete buttons get disabled when at least one of the form's inputs ar
| formCompleted | `EventEmitter<FormModel>` | Emitted when the form is submitted with the `Complete` outcome. |
| formContentClicked | `EventEmitter<ContentLinkModel>` | Emitted when form content is clicked. |
| formSaved | `EventEmitter<FormModel>` | Emitted when the form is saved. |
| nextTaskCheckboxCheckedChanged | `EventEmitter<MatCheckboxChange>` | Emitted when the `Open next task` checkbox was toggled. |
| onTaskLoaded | `EventEmitter<TaskDetailsCloudModel>` | Emitted when a task is loaded. |
| taskClaimed | `EventEmitter<string>` | Emitted when the task is claimed. |
| taskCompleted | `EventEmitter<string>` | Emitted when the task is completed. |

View File

@@ -79,14 +79,6 @@
<adf-form-renderer [formDefinition]="form" [readOnly]="readOnly" />
</mat-card-content>
<mat-card-actions *ngIf="form.hasOutcomes()" class="adf-cloud-form-content-card-actions" align="end">
<mat-checkbox
id="adf-form-open-next-task"
*ngIf="showNextTaskCheckbox && showCompleteButton"
[checked]="isNextTaskCheckboxChecked"
(change)="onNextTaskCheckboxCheckedChanged($event)"
>{{ 'ADF_CLOUD_TASK_FORM.OPEN_NEXT_TASK.LABEL' | translate }}</mat-checkbox
>
<span class="adf-card-actions-spacer"></span>
<ng-content select="adf-cloud-form-custom-outcomes" />
<ng-container *ngFor="let outcome of form.outcomes">
<button

View File

@@ -19,10 +19,6 @@
display: flex;
position: relative;
}
.adf-card-actions-spacer {
flex: 1 1 auto;
}
}
&-fullscreen-container {

View File

@@ -66,7 +66,6 @@ import { FormCloudDisplayMode } from '../../services/form-fields.interfaces';
import { CloudFormRenderingService } from './cloud-form-rendering.service';
import { ProcessServiceCloudTestingModule } from '../../testing/process-service-cloud.testing.module';
import { TaskVariableCloud } from '../models/task-variable-cloud.model';
import { MatCheckboxHarness } from '@angular/material/checkbox/testing';
const mockOauth2Auth: any = {
oauth2Auth: {
@@ -1216,95 +1215,6 @@ describe('FormCloudComponent', () => {
expect(form.fieldValidators.length).toBe(10);
});
it('should allow controlling [open next task] checkbox visibility', async () => {
const formModel = new FormModel({ fields: [{ id: 'field2' }] });
formComponent.form = formModel;
const isCheckboxShown = () => {
const checkbox = fixture.debugElement.query(By.css('#adf-form-open-next-task'));
return !!checkbox;
};
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();
});
it('should allow controlling [open next task] checkbox value', async () => {
const formModel = new FormModel({ fields: [{ id: 'field2' }] });
formComponent.form = formModel;
formComponent.showNextTaskCheckbox = true;
formComponent.showCompleteButton = true;
fixture.detectChanges();
await fixture.whenStable();
const isCheckboxChecked = async () => {
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();
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 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();
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();
expect(formComponent.nextTaskCheckboxCheckedChanged.emit).toHaveBeenCalled();
});
describe('form validations', () => {
it('should be able to set visibility conditions for Attach File widget', async () => {
spyOn(formCloudService, 'getForm').and.returnValue(of(conditionalUploadWidgetsMock));
@@ -1804,13 +1714,4 @@ 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

@@ -67,7 +67,6 @@ import { MatButtonModule } from '@angular/material/button';
import { MatCardModule } from '@angular/material/card';
import { MatIconModule } from '@angular/material/icon';
import { A11yModule } from '@angular/cdk/a11y';
import { MatCheckboxChange, MatCheckboxModule } from '@angular/material/checkbox';
export const FORM_CLOUD_FIELD_VALIDATORS_TOKEN = new InjectionToken<FormFieldValidator[]>('FORM_CLOUD_FIELD_VALIDATORS_TOKEN');
@@ -83,8 +82,7 @@ export const FORM_CLOUD_FIELD_VALIDATORS_TOKEN = new InjectionToken<FormFieldVal
MatIconModule,
ToolbarDividerComponent,
ToolbarComponent,
A11yModule,
MatCheckboxModule
A11yModule
],
providers: [FormCloudSpinnerService],
templateUrl: './form-cloud.component.html',
@@ -119,14 +117,6 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,
@Input()
displayModeConfigurations: FormCloudDisplayModeConfiguration[];
/** Toggle rendering of the `Open next task` checkbox. */
@Input()
showNextTaskCheckbox = false;
/** Whether the `Open next task` checkbox is checked by default or not. */
@Input()
isNextTaskCheckboxChecked = false;
/** Toggle rendering of the `Complete` button. */
@Input()
showCompleteButton = false;
@@ -159,10 +149,6 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,
@Output()
displayModeOff = new EventEmitter<FormCloudDisplayModeConfiguration>();
/** Emitted when the `Open next task` checkbox was toggled. */
@Output()
nextTaskCheckboxCheckedChanged = new EventEmitter<MatCheckboxChange>();
protected subscriptions: Subscription[] = [];
nodeId: string;
formCloudRepresentationJSON: any;
@@ -526,8 +512,4 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,
this.fieldValidators = [...this.fieldValidators, ...injectedFieldValidators];
}
}
onNextTaskCheckboxCheckedChanged(event: MatCheckboxChange) {
this.nextTaskCheckboxCheckedChanged.emit(event);
}
}

View File

@@ -379,8 +379,7 @@
"ERROR": {
"INVALID_DESTINATION_FOLDER_PATH": "Invalid destination folder path",
"DESTINATION_FOLDER_PATH_ERROR": "The destination path is incorrect or does not exist, rollback to -my- location"
},
"OPEN_NEXT_TASK": {"LABEL": "Open next task"}
}
},
"ADF_CLOUD_FORM_COMPONENT": {
"RETRIEVE_METADATA": "Autofill Form"

View File

@@ -89,12 +89,9 @@
[showRefreshButton]="false"
[showValidationIcon]="false"
[showTitle]="false"
[showNextTaskCheckbox]="showNextTaskCheckbox"
[isNextTaskCheckboxChecked]="isNextTaskCheckboxChecked"
(formContentClicked)="onFormContentClicked($event)"
(formLoaded)="onFormLoaded($event)"
(executeOutcome)="onCustomOutcomeClicked($event.outcome.name)"
(nextTaskCheckboxCheckedChanged)="onNextTaskCheckboxCheckedChanged($event)"
>
<adf-cloud-form-custom-outcomes>
<ng-template [ngTemplateOutlet]="taskFormCloudButtons" />

View File

@@ -61,7 +61,6 @@ import { MatInputModule } from '@angular/material/input';
import { MatOptionModule } from '@angular/material/core';
import { FormCloudComponent } from '../../../form/components/form-cloud.component';
import { FormCustomOutcomesComponent } from '../../../form/components/form-cloud-custom-outcomes.component';
import { MatCheckboxChange } from '@angular/material/checkbox';
import { MatDialog } from '@angular/material/dialog';
const MAX_NAME_LENGTH: number = 255;
@@ -138,14 +137,6 @@ export class StartProcessCloudComponent implements OnChanges, OnInit {
@Input()
displayModeConfigurations: FormCloudDisplayModeConfiguration[];
/** Toggle rendering of the `Open next task` checkbox. */
@Input()
showNextTaskCheckbox = false;
/** Whether the `Open next task` checkbox is checked by default or not. */
@Input()
isNextTaskCheckboxChecked = false;
/** Emitted when the process is successfully started. */
@Output()
success = new EventEmitter<ProcessInstanceCloud>();
@@ -166,10 +157,6 @@ export class StartProcessCloudComponent implements OnChanges, OnInit {
@Output()
processDefinitionSelection: EventEmitter<ProcessDefinitionCloud> = new EventEmitter<ProcessDefinitionCloud>();
/** Emitted when the `Open next task` checkbox was toggled. */
@Output()
nextTaskCheckboxCheckedChanged = new EventEmitter<MatCheckboxChange>();
processDefinitionList: ProcessDefinitionCloud[] = [];
processDefinitionCurrent?: ProcessDefinitionCloud;
errorMessageId: string = '';
@@ -589,8 +576,4 @@ export class StartProcessCloudComponent implements OnChanges, OnInit {
}
return processName;
}
onNextTaskCheckboxCheckedChanged(event: MatCheckboxChange) {
this.nextTaskCheckboxCheckedChanged.emit(event);
}
}

View File

@@ -12,8 +12,6 @@
[showCompleteButton]="canCompleteTask()"
[showSaveButton]="canCompleteTask()"
[displayModeConfigurations]="displayModeConfigurations"
[showNextTaskCheckbox]="showNextTaskCheckbox"
[isNextTaskCheckboxChecked]="isNextTaskCheckboxChecked"
(formSaved)="onFormSaved($event)"
(formCompleted)="onFormCompleted($event)"
(formError)="onError($event)"
@@ -22,7 +20,6 @@
(executeOutcome)="onFormExecuteOutcome($event)"
(displayModeOn)="onDisplayModeOn($event)"
(displayModeOff)="onDisplayModeOff($event)"
(nextTaskCheckboxCheckedChanged)="onNextTaskCheckboxCheckedChanged($event)"
>
<adf-cloud-form-custom-outcomes>
<adf-cloud-user-task-cloud-buttons

View File

@@ -27,7 +27,6 @@ import { TaskDetailsCloudModel } from '../../../models/task-details-cloud.model'
import { CommonModule } from '@angular/common';
import { UserTaskCloudButtonsComponent } from '../user-task-cloud-buttons/user-task-cloud-buttons.component';
import { FormCustomOutcomesComponent } from '../../../../form/components/form-cloud-custom-outcomes.component';
import { MatCheckboxChange } from '@angular/material/checkbox';
@Component({
selector: 'adf-cloud-task-form',
@@ -87,14 +86,6 @@ export class TaskFormCloudComponent {
@Input()
taskDetails: TaskDetailsCloudModel;
/** Toggle rendering of the `Open next task` checkbox. */
@Input()
showNextTaskCheckbox = false;
/** Whether the `Open next task` checkbox is checked by default or not. */
@Input()
isNextTaskCheckboxChecked = false;
/** Emitted when the form is saved. */
@Output()
formSaved = new EventEmitter<FormModel>();
@@ -142,10 +133,6 @@ export class TaskFormCloudComponent {
@Output()
displayModeOff = new EventEmitter<FormCloudDisplayModeConfiguration>();
/** Emitted when the `Open next task` checkbox was toggled. */
@Output()
nextTaskCheckboxCheckedChanged = new EventEmitter<MatCheckboxChange>();
@ViewChild('adfCloudForm', { static: false })
adfCloudForm: FormCloudComponent;
@@ -237,8 +224,4 @@ export class TaskFormCloudComponent {
onDisplayModeOff(displayModeConfiguration: FormCloudDisplayModeConfiguration) {
this.displayModeOff.emit(displayModeConfiguration);
}
onNextTaskCheckboxCheckedChanged(event: MatCheckboxChange) {
this.nextTaskCheckboxCheckedChanged.emit(event);
}
}

View File

@@ -12,8 +12,6 @@
[showTitle]="showTitle"
[taskId]="taskId"
[taskDetails]="taskDetails"
[showNextTaskCheckbox]="showNextTaskCheckbox && canCompleteTask() && nextTaskCheckboxForFormsActivated"
[isNextTaskCheckboxChecked]="isNextTaskCheckboxChecked"
(cancelClick)="onCancelForm()"
(executeOutcome)="onExecuteOutcome($event)"
(error)="onError($event)"
@@ -22,7 +20,6 @@
(taskCompleted)="onCompleteTaskForm()"
(taskClaimed)="onClaimTask()"
(taskUnclaimed)="onTaskUnclaimed()"
(nextTaskCheckboxCheckedChanged)="onNextTaskCheckboxCheckedChanged($event)"
/>
</ng-container>
@@ -70,14 +67,6 @@
/>
</mat-card-content>
<mat-card-actions class="adf-task-form-actions" align="end">
<mat-checkbox
id="adf-form-open-next-task"
*ngIf="showNextTaskCheckbox && canCompleteTask() && nextTaskCheckboxForFormsActivated"
[checked]="isNextTaskCheckboxChecked"
(change)="onNextTaskCheckboxCheckedChanged($event)"
>{{ 'ADF_CLOUD_TASK_FORM.OPEN_NEXT_TASK.LABEL' | translate }}
</mat-checkbox>
<span class="adf-card-actions-spacer"></span>
<ng-template [ngTemplateOutlet]="taskFormCloudButtons" />
<button
*ngIf="canCompleteTask()"

View File

@@ -4,10 +4,6 @@
> div {
height: 100%;
}
.adf-card-actions-spacer {
flex: 1 1 auto;
}
}
.adf-user-task-cloud-spinner {

View File

@@ -27,7 +27,7 @@ import {
} from '@alfresco/adf-process-services-cloud';
import { HarnessLoader } from '@angular/cdk/testing';
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { SimpleChange } from '@angular/core';
import { Component, EventEmitter, Input, Output, SimpleChange } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MatButtonHarness } from '@angular/material/button/testing';
import { MatCardHarness } from '@angular/material/card/testing';
@@ -37,7 +37,8 @@ import { of, throwError } from 'rxjs';
import { IdentityUserService } from '../../../../people/services/identity-user.service';
import { UserTaskCloudComponent } from './user-task-cloud.component';
import { By } from '@angular/platform-browser';
import { MatCheckboxHarness } from '@angular/material/checkbox/testing';
import { TaskScreenCloudComponent } from '../../../../screen/components/screen-cloud/screen-cloud.component';
import { MatCheckboxChange } from '@angular/material/checkbox';
const taskDetails: TaskDetailsCloudModel = {
appName: 'simple-app',
@@ -54,6 +55,34 @@ const taskDetails: TaskDetailsCloudModel = {
permissions: [TASK_VIEW_PERMISSION]
};
@Component({
selector: 'adf-cloud-task-screen',
standalone: true,
template: ''
})
class TaskScreenCloudMockComponent {
@Input() taskId: string;
@Input() appName: string = '';
@Input() canClaimTask: boolean;
@Input() canUnclaimTask: boolean;
@Input() showCancelButton: boolean;
@Input() screenId: string = '';
@Input() processInstanceId: string = '';
@Input() taskName: string = '';
@Input() readOnly = false;
@Input() rootProcessInstanceId: string = '';
@Input() isNextTaskCheckboxChecked = false;
@Input() showNextTaskCheckbox = false;
@Output() taskSaved = new EventEmitter();
@Output() taskCompleted = new EventEmitter<any>();
@Output() error = new EventEmitter<any>();
@Output() cancelTask = new EventEmitter<any>();
@Output() claimTask = new EventEmitter<any>();
@Output() unclaimTask = new EventEmitter<any>();
@Output() nextTaskCheckboxCheckedChanged = new EventEmitter<MatCheckboxChange>();
}
describe('UserTaskCloudComponent', () => {
let component: UserTaskCloudComponent;
let fixture: ComponentFixture<UserTaskCloudComponent>;
@@ -67,7 +96,11 @@ describe('UserTaskCloudComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [ProcessServiceCloudTestingModule, UserTaskCloudComponent, TaskFormCloudComponent]
}).overrideComponent(UserTaskCloudComponent, {
remove: { imports: [TaskScreenCloudComponent] },
add: { imports: [TaskScreenCloudMockComponent] }
});
fixture = TestBed.createComponent(UserTaskCloudComponent);
component = fixture.componentInstance;
errorEmitSpy = spyOn(component.error, 'emit');
@@ -480,12 +513,8 @@ describe('UserTaskCloudComponent', () => {
});
it('should allow controlling [open next task] checkbox visibility', () => {
if (!component.nextTaskCheckboxForFormsActivated) {
expect(true).toBeTrue();
return;
}
taskDetails.formKey = 'form';
taskDetails.formKey = 'my-screen';
component.taskDetails = { ...taskDetails };
component.getTaskType();
component.taskId = 'taskId';
component.appName = 'app';
@@ -493,8 +522,11 @@ describe('UserTaskCloudComponent', () => {
const spy = spyOn(taskCloudService, 'canCompleteTask');
const isCheckboxShown = () => {
const checkbox = fixture.debugElement.query(By.css('#adf-form-open-next-task'));
return !!checkbox;
const screenElement = fixture.debugElement.query(By.css('adf-cloud-task-screen'));
expect(screenElement).toBeTruthy();
const screenComponent: TaskScreenCloudMockComponent = screenElement.componentInstance;
expect(screenComponent).toBeTruthy();
return screenComponent.showNextTaskCheckbox;
};
const prepareTestCase = (testCase: {
@@ -559,62 +591,4 @@ describe('UserTaskCloudComponent', () => {
prepareTestCase({ showNextTaskCheckbox: true, showCompleteButton: true, readOnly: false, canCompleteTask: true });
expect(isCheckboxShown()).toBeTrue();
});
it('should allow controlling [open next task] checkbox value', async () => {
if (!component.nextTaskCheckboxForFormsActivated) {
expect(true).toBeTrue();
return;
}
taskDetails.formKey = 'form';
component.getTaskType();
component.taskId = 'taskId';
component.appName = 'app';
component.showNextTaskCheckbox = true;
component.showCompleteButton = true;
component.readOnly = false;
spyOn(taskCloudService, 'canCompleteTask').and.returnValue(true);
const isCheckboxChecked = async () => {
const checkbox = await loader.getHarness(MatCheckboxHarness.with({ selector: '#adf-form-open-next-task' }));
return checkbox.isChecked();
};
fixture.detectChanges();
expect(await isCheckboxChecked()).toBeFalse();
component.isNextTaskCheckboxChecked = true;
fixture.detectChanges();
expect(await isCheckboxChecked()).toBeTrue();
component.isNextTaskCheckboxChecked = false;
fixture.detectChanges();
expect(await isCheckboxChecked()).toBeFalse();
});
it('should call onNextTaskCheckboxCheckedChanged when the checkbox is checked', async () => {
if (!component.nextTaskCheckboxForFormsActivated) {
expect(true).toBeTrue();
return;
}
taskDetails.formKey = 'form';
component.getTaskType();
component.taskId = 'taskId';
component.appName = 'app';
component.showNextTaskCheckbox = true;
component.showCompleteButton = true;
component.readOnly = false;
spyOn(taskCloudService, 'canCompleteTask').and.returnValue(true);
fixture.detectChanges();
const checkbox = await loader.getHarnessOrNull(MatCheckboxHarness);
spyOn(component.nextTaskCheckboxCheckedChanged, 'emit');
await checkbox.check();
expect(component.nextTaskCheckboxCheckedChanged.emit).toHaveBeenCalled();
});
});

View File

@@ -86,7 +86,7 @@ export class UserTaskCloudComponent implements OnInit, OnChanges {
@Input()
showCompleteButton = true;
/** Toggle rendering of the `Open next task` checkbox. */
/** Toggle rendering of the `Open next task` checkbox (for screens only). */
@Input()
showNextTaskCheckbox = false;
@@ -159,12 +159,6 @@ export class UserTaskCloudComponent implements OnInit, OnChanges {
taskType: TaskTypesType;
taskTypeEnum = TaskTypes;
/**
* The `Open next task` feature is currently disabled for forms only.
* See https://hyland.atlassian.net/browse/AAE-34514 for further details.
*/
readonly nextTaskCheckboxForFormsActivated = false;
private taskCloudService: TaskCloudService = inject(TaskCloudService);
private readonly destroyRef = inject(DestroyRef);