Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AAE-23358: Fix allowing to bypass required form on start event by cli… #9977

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<mat-card appearance="outlined" class="adf-start-process" *ngIf="(loading$ | async) === false; else spinner">
<mat-card appearance="outlined" class="adf-start-process" *ngIf="processDefinitionLoaded && !isFormCloudLoading; else spinner">

<mat-card-content>

<mat-card-title
*ngIf="showTitle"
class="adf-title">
Expand All @@ -12,7 +11,7 @@
{{ errorMessageId | translate }}
</mat-card-subtitle>

<div *ngIf="!isProcessDefinitionsEmpty(); else emptyProcessDefinitionsList">
<div *ngIf="!isProcessDefinitionsEmpty; else emptyProcessDefinitionsList">
<form [formGroup]="processForm" class="adf-select-process-form">
<mat-form-field
class="adf-process-input-container"
Expand Down Expand Up @@ -72,7 +71,7 @@
</adf-inplace-form-input>
</form>

<ng-container *ngIf="hasForm() else taskFormCloudButtons">
<ng-container *ngIf="hasForm else taskFormCloudButtons">
<adf-cloud-form
[appName]="appName"
[appVersion]="processDefinitionCurrent.appVersion"
Expand Down Expand Up @@ -111,7 +110,7 @@
<button
color="primary"
mat-raised-button
[disabled]="disableStartButton() || !isProcessFormValid()"
[disabled]="disableStartButton || !isProcessFormValid"
(click)="startProcess()"
data-automation-id="btn-start"
id="button-start"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe('StartProcessCloudComponent', () => {

fixture.detectChanges();
const startBtn = fixture.nativeElement.querySelector('#button-start');
expect(component.isProcessFormValid()).toBe(true);
expect(component.isProcessFormValid).toBe(true);
expect(startBtn.disabled).toBe(false);
}));

Expand All @@ -154,7 +154,7 @@ describe('StartProcessCloudComponent', () => {

expect(component.processDefinitionCurrent.name).toBe(JSON.parse(JSON.stringify(fakeProcessDefinitions[1])).name);
const startBtn = fixture.nativeElement.querySelector('#button-start');
expect(component.isProcessFormValid()).toBe(true);
expect(component.isProcessFormValid).toBe(true);
expect(startBtn.disabled).toBe(false);
});

Expand All @@ -167,7 +167,7 @@ describe('StartProcessCloudComponent', () => {

const startBtn = fixture.nativeElement.querySelector('#button-start');
expect(startBtn.disabled).toBe(true);
expect(component.isProcessFormValid()).toBe(false);
expect(component.isProcessFormValid).toBe(false);
});

it('should have start button disabled when name not filled out', async () => {
Expand All @@ -179,7 +179,7 @@ describe('StartProcessCloudComponent', () => {

const startBtn = fixture.nativeElement.querySelector('#button-start');
expect(startBtn.disabled).toBe(true);
expect(component.isProcessFormValid()).toBe(false);
expect(component.isProcessFormValid).toBe(false);
});

it('should include the static input mappings in the resolved values', fakeAsync(() => {
Expand Down Expand Up @@ -334,7 +334,7 @@ describe('StartProcessCloudComponent', () => {

const startBtn = fixture.nativeElement.querySelector('#button-start');
expect(startBtn.disabled).toBe(false);
expect(component.isProcessFormValid()).toBe(true);
expect(component.isProcessFormValid).toBe(true);
});

it('should have start button enabled when default values are set', async () => {
Expand Down Expand Up @@ -444,7 +444,7 @@ describe('StartProcessCloudComponent', () => {
await fixture.whenStable();

const processForm = fixture.nativeElement.querySelector('adf-cloud-form');
expect(component.hasForm()).toBeTruthy();
expect(component.hasForm).toBeTruthy();
expect(processForm).not.toBeNull();
});

Expand Down Expand Up @@ -713,7 +713,7 @@ describe('StartProcessCloudComponent', () => {
await fixture.whenStable();

const processForm = fixture.nativeElement.querySelector('adf-cloud-form');
expect(component.hasForm()).toBeTruthy();
expect(component.hasForm).toBeTruthy();
expect(processForm).not.toBeNull();

const payload: ProcessPayloadCloud = new ProcessPayloadCloud({
Expand Down Expand Up @@ -896,7 +896,6 @@ describe('StartProcessCloudComponent', () => {
});

it('should hide title', () => {
component.loading$.next(false);
component.showTitle = false;
fixture.detectChanges();

Expand All @@ -906,7 +905,7 @@ describe('StartProcessCloudComponent', () => {
});

it('should show title', () => {
component.loading$.next(false);
component.processDefinitionLoaded = true;
fixture.detectChanges();

const title = fixture.debugElement.query(By.css('.adf-title'));
Expand All @@ -915,7 +914,7 @@ describe('StartProcessCloudComponent', () => {
});

it('should show process definition dropdown', () => {
component.loading$.next(false);
component.processDefinitionLoaded = true;
component.processDefinitionList = fakeProcessDefinitions;
fixture.detectChanges();

Expand All @@ -925,7 +924,7 @@ describe('StartProcessCloudComponent', () => {
});

it('should hide process definition dropdown', () => {
component.loading$.next(false);
component.processDefinitionLoaded = true;
component.processDefinitionList = fakeProcessDefinitions;
component.showSelectProcessDropdown = false;
fixture.detectChanges();
Expand All @@ -936,7 +935,17 @@ describe('StartProcessCloudComponent', () => {
});

it('should show the loading spinner before process definitions loaded', () => {
component.loading$.next(true);
component.processDefinitionLoaded = false;
fixture.detectChanges();

const spinner = fixture.debugElement.query(By.css('.adf-loading'));

expect(spinner).toBeTruthy();
});

it('should show the loading spinner when cloud form is loading', () => {
component.processDefinitionLoaded = true;
component.isFormCloudLoading = true;
fixture.detectChanges();

const spinner = fixture.debugElement.query(By.css('.adf-loading'));
Expand All @@ -945,7 +954,7 @@ describe('StartProcessCloudComponent', () => {
});

it('should show the process card after process definitions loaded', () => {
component.loading$.next(false);
component.processDefinitionLoaded = true;
fixture.detectChanges();

const card = fixture.debugElement.query(By.css('.adf-start-process'));
Expand All @@ -968,27 +977,27 @@ describe('StartProcessCloudComponent', () => {
fixture.detectChanges();
component.processForm.controls['processInstanceName'].setValue(fakeProcessDefinitions[0].id);
component.appName = 'test app name';
component.isLoading = false;
component.isProcessStarting = false;
fixture.detectChanges();
await fixture.whenStable();

const startButton = fixture.debugElement.query(By.css('#button-start'));
expect(startButton).not.toBeNull();
expect(component.disableStartButton()).toBeFalse();
expect(component.disableStartButton).toBeFalse();
expect((startButton.nativeElement as HTMLButtonElement).disabled).toBeFalse();
});

it('start process button should be disabled when isLoading is true', async () => {
wiktord2000 marked this conversation as resolved.
Show resolved Hide resolved
fixture.detectChanges();
component.processForm.controls['processInstanceName'].setValue(fakeProcessDefinitions[0].id);
component.appName = 'test app name';
component.isLoading = true;
component.isProcessStarting = true;
fixture.detectChanges();
await fixture.whenStable();

const startButton = fixture.debugElement.query(By.css('#button-start'));
expect(startButton).not.toBeNull();
expect(component.disableStartButton()).toBeTrue();
expect(component.disableStartButton).toBeTrue();
expect((startButton.nativeElement as HTMLButtonElement).disabled).toBeTrue();
});
});
Expand Down
Loading
Loading