mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
[AAE-2505] [PS cloud] Should not allow to start the process if is not created (#5659)
* * fixed bug * * cherry pick
This commit is contained in:
parent
1430314815
commit
7d2af84a58
@ -24,7 +24,7 @@ import {
|
|||||||
StringUtil,
|
StringUtil,
|
||||||
StartTasksCloudPage,
|
StartTasksCloudPage,
|
||||||
TaskFormCloudComponent,
|
TaskFormCloudComponent,
|
||||||
StartProcessPage
|
StartProcessCloudPage
|
||||||
} from '@alfresco/adf-testing';
|
} from '@alfresco/adf-testing';
|
||||||
import { browser, by } from 'protractor';
|
import { browser, by } from 'protractor';
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ describe('Task cloud visibility', async () => {
|
|||||||
const tasksCloudDemoPage = new TasksCloudDemoPage();
|
const tasksCloudDemoPage = new TasksCloudDemoPage();
|
||||||
const startTask = new StartTasksCloudPage();
|
const startTask = new StartTasksCloudPage();
|
||||||
const taskFormCloudComponent = new TaskFormCloudComponent();
|
const taskFormCloudComponent = new TaskFormCloudComponent();
|
||||||
const startProcessPage = new StartProcessPage();
|
const startProcessPage = new StartProcessCloudPage();
|
||||||
const processCloudDemoPage = new ProcessCloudDemoPage();
|
const processCloudDemoPage = new ProcessCloudDemoPage();
|
||||||
const loginSSOPage = new LoginSSOPage();
|
const loginSSOPage = new LoginSSOPage();
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ describe('Task cloud visibility', async () => {
|
|||||||
await startProcessPage.selectFromProcessDropdown(browser.params.resources.ACTIVITI_CLOUD_APPS.SIMPLE_APP.processes.numbervisibilityprocess);
|
await startProcessPage.selectFromProcessDropdown(browser.params.resources.ACTIVITI_CLOUD_APPS.SIMPLE_APP.processes.numbervisibilityprocess);
|
||||||
|
|
||||||
await startProcessPage.enterProcessName(processName);
|
await startProcessPage.enterProcessName(processName);
|
||||||
await browser.sleep(400);
|
await startProcessPage.checkStartProcessButtonIsEnabled();
|
||||||
await startProcessPage.clickStartProcessButton();
|
await startProcessPage.clickStartProcessButton();
|
||||||
|
|
||||||
await processCloudDemoPage.editProcessFilterCloudComponent().setFilter({ processName });
|
await processCloudDemoPage.editProcessFilterCloudComponent().setFilter({ processName });
|
||||||
|
@ -78,7 +78,7 @@
|
|||||||
<button mat-button (click)="cancelStartProcess()" id="cancel_process">
|
<button mat-button (click)="cancelStartProcess()" id="cancel_process">
|
||||||
{{ 'ADF_CLOUD_PROCESS_LIST.ADF_CLOUD_START_PROCESS.FORM.ACTION.CANCEL' | translate | uppercase}}
|
{{ 'ADF_CLOUD_PROCESS_LIST.ADF_CLOUD_START_PROCESS.FORM.ACTION.CANCEL' | translate | uppercase}}
|
||||||
</button>
|
</button>
|
||||||
<button color="primary" mat-button [disabled]="!isProcessFormValid()" (click)="startProcess()"
|
<button color="primary" mat-button [disabled]="!currentCreatedProcess || !isProcessFormValid()" (click)="startProcess()"
|
||||||
data-automation-id="btn-start" id="button-start" class="btn-start">
|
data-automation-id="btn-start" id="button-start" class="btn-start">
|
||||||
{{'ADF_CLOUD_PROCESS_LIST.ADF_CLOUD_START_PROCESS.FORM.ACTION.START' | translate | uppercase}}
|
{{'ADF_CLOUD_PROCESS_LIST.ADF_CLOUD_START_PROCESS.FORM.ACTION.START' | translate | uppercase}}
|
||||||
</button>
|
</button>
|
||||||
|
@ -27,7 +27,7 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
|||||||
import { TranslateModule, TranslateStore } from '@ngx-translate/core';
|
import { TranslateModule, TranslateStore } from '@ngx-translate/core';
|
||||||
import { MatCardModule, MatOptionModule, MatAutocompleteModule, MatIconModule, MatButtonModule, MatFormFieldModule, MatInputModule, MatRippleModule, MatCommonModule } from '@angular/material';
|
import { MatCardModule, MatOptionModule, MatAutocompleteModule, MatIconModule, MatButtonModule, MatFormFieldModule, MatInputModule, MatRippleModule, MatCommonModule } from '@angular/material';
|
||||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||||
import { FormCloudModule } from 'process-services-cloud/src/lib/form/form-cloud.module';
|
import { FormCloudModule } from '../../../form/form-cloud.module';
|
||||||
|
|
||||||
import { fakeProcessDefinitions, fakeStartForm, fakeStartFormNotValid,
|
import { fakeProcessDefinitions, fakeStartForm, fakeStartFormNotValid,
|
||||||
fakeProcessInstance, fakeNoNameProcessDefinitions,
|
fakeProcessInstance, fakeNoNameProcessDefinitions,
|
||||||
@ -124,16 +124,18 @@ describe('StartProcessCloudComponent', () => {
|
|||||||
typeValueInto('#processName', 'OLE');
|
typeValueInto('#processName', 'OLE');
|
||||||
typeValueInto('#processDefinitionName', 'processwithoutform2');
|
typeValueInto('#processDefinitionName', 'processwithoutform2');
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
fixture.whenStable();
|
|
||||||
tick(450);
|
tick(450);
|
||||||
|
|
||||||
const startBtn = fixture.nativeElement.querySelector('#button-start');
|
fixture.whenStable().then(() => {
|
||||||
expect(startBtn.disabled).toBe(false);
|
fixture.detectChanges();
|
||||||
expect(component.isProcessFormValid()).toBe(true);
|
const startBtn = fixture.nativeElement.querySelector('#button-start');
|
||||||
expect(createProcessSpy).toHaveBeenCalledWith('MyApp', new ProcessPayloadCloud({name: 'OLE',
|
expect(startBtn.disabled).toBe(false);
|
||||||
processDefinitionKey: fakeProcessDefinitions[1].key}));
|
expect(component.isProcessFormValid()).toBe(true);
|
||||||
expect(component.currentCreatedProcess.status).toBe('CREATED');
|
expect(createProcessSpy).toHaveBeenCalledWith('MyApp', new ProcessPayloadCloud({name: 'OLE',
|
||||||
expect(component.currentCreatedProcess.startDate).toBeNull();
|
processDefinitionKey: fakeProcessDefinitions[1].key}));
|
||||||
|
expect(component.currentCreatedProcess.status).toBe('CREATED');
|
||||||
|
expect(component.currentCreatedProcess.startDate).toBeNull();
|
||||||
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should be able to start a process with a valid process name and process definition', async(() => {
|
it('should be able to start a process with a valid process name and process definition', async(() => {
|
||||||
@ -152,6 +154,28 @@ describe('StartProcessCloudComponent', () => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('should have start button disabled if create operation failed', fakeAsync(() => {
|
||||||
|
createProcessSpy.and.returnValue(throwError('fake error'));
|
||||||
|
const change = new SimpleChange(null, 'MyApp', true);
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
component.ngOnChanges({ 'appName': change });
|
||||||
|
fixture.detectChanges();
|
||||||
|
tick();
|
||||||
|
typeValueInto('#processName', 'OLE');
|
||||||
|
typeValueInto('#processDefinitionName', 'processwithoutform2');
|
||||||
|
fixture.detectChanges();
|
||||||
|
tick(450);
|
||||||
|
|
||||||
|
fixture.whenStable().then(() => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
const startBtn = fixture.nativeElement.querySelector('#button-start');
|
||||||
|
expect(startBtn.disabled).toBe(true);
|
||||||
|
expect(component.isProcessFormValid()).toBe(false);
|
||||||
|
expect(createProcessSpy).toHaveBeenCalledWith('MyApp', component.processPayloadCloud);
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
it('should have start button disabled when no process is selected', async(() => {
|
it('should have start button disabled when no process is selected', async(() => {
|
||||||
component.name = '';
|
component.name = '';
|
||||||
component.processDefinitionName = '';
|
component.processDefinitionName = '';
|
||||||
@ -191,7 +215,7 @@ describe('StartProcessCloudComponent', () => {
|
|||||||
component.name = 'My new process with form';
|
component.name = 'My new process with form';
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to start a process with a valid form', async(() => {
|
it('should be able to start a process with a valid form', fakeAsync(() => {
|
||||||
component.processDefinitionName = 'processwithform';
|
component.processDefinitionName = 'processwithform';
|
||||||
getDefinitionsSpy.and.returnValue(of(fakeSingleProcessDefinition(component.processDefinitionName)));
|
getDefinitionsSpy.and.returnValue(of(fakeSingleProcessDefinition(component.processDefinitionName)));
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@ -200,8 +224,14 @@ describe('StartProcessCloudComponent', () => {
|
|||||||
const change = new SimpleChange(null, 'MyApp', true);
|
const change = new SimpleChange(null, 'MyApp', true);
|
||||||
component.ngOnChanges({ 'appName': change });
|
component.ngOnChanges({ 'appName': change });
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
tick();
|
||||||
|
typeValueInto('#processName', 'My new process with form');
|
||||||
|
typeValueInto('#processDefinitionName', 'processwithform');
|
||||||
|
fixture.detectChanges();
|
||||||
|
tick(450);
|
||||||
|
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
|
fixture.detectChanges();
|
||||||
const firstNameEl = fixture.nativeElement.querySelector('#firstName');
|
const firstNameEl = fixture.nativeElement.querySelector('#firstName');
|
||||||
expect(firstNameEl).toBeDefined();
|
expect(firstNameEl).toBeDefined();
|
||||||
const lastNameEl = fixture.nativeElement.querySelector('#lastName');
|
const lastNameEl = fixture.nativeElement.querySelector('#lastName');
|
||||||
@ -212,8 +242,7 @@ describe('StartProcessCloudComponent', () => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should NOT be able to start a process with a form NOT valid', async(() => {
|
it('should NOT be able to start a process with a form NOT valid', fakeAsync(() => {
|
||||||
component.processDefinitionName = 'processwithform';
|
|
||||||
getDefinitionsSpy.and.returnValue(of(fakeSingleProcessDefinition(component.processDefinitionName)));
|
getDefinitionsSpy.and.returnValue(of(fakeSingleProcessDefinition(component.processDefinitionName)));
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
formDefinitionSpy = spyOn(formCloudService, 'getForm').and.returnValue(of(fakeStartFormNotValid));
|
formDefinitionSpy = spyOn(formCloudService, 'getForm').and.returnValue(of(fakeStartFormNotValid));
|
||||||
@ -222,7 +251,14 @@ describe('StartProcessCloudComponent', () => {
|
|||||||
component.ngOnChanges({ 'appName': change });
|
component.ngOnChanges({ 'appName': change });
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
tick();
|
||||||
|
typeValueInto('#processName', 'My new process with form');
|
||||||
|
typeValueInto('#processDefinitionName', 'processwithform');
|
||||||
|
fixture.detectChanges();
|
||||||
|
tick(450);
|
||||||
|
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
|
fixture.detectChanges();
|
||||||
const firstNameEl = fixture.nativeElement.querySelector('#firstName');
|
const firstNameEl = fixture.nativeElement.querySelector('#firstName');
|
||||||
expect(firstNameEl).toBeDefined();
|
expect(firstNameEl).toBeDefined();
|
||||||
const lastNameEl = fixture.nativeElement.querySelector('#lastName');
|
const lastNameEl = fixture.nativeElement.querySelector('#lastName');
|
||||||
@ -233,7 +269,7 @@ describe('StartProcessCloudComponent', () => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should be able to start a process with a prefilled valid form', async(() => {
|
it('should be able to start a process with a prefilled valid form', fakeAsync(() => {
|
||||||
component.processDefinitionName = 'processwithform';
|
component.processDefinitionName = 'processwithform';
|
||||||
getDefinitionsSpy.and.returnValue(of(fakeSingleProcessDefinition(component.processDefinitionName)));
|
getDefinitionsSpy.and.returnValue(of(fakeSingleProcessDefinition(component.processDefinitionName)));
|
||||||
component.values = [{'name': 'firstName', 'value': 'FakeName'}, {'name': 'lastName', 'value': 'FakeLastName'}];
|
component.values = [{'name': 'firstName', 'value': 'FakeName'}, {'name': 'lastName', 'value': 'FakeLastName'}];
|
||||||
@ -244,7 +280,14 @@ describe('StartProcessCloudComponent', () => {
|
|||||||
component.ngOnChanges({ 'appName': change });
|
component.ngOnChanges({ 'appName': change });
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
tick();
|
||||||
|
typeValueInto('#processName', 'My new process with form');
|
||||||
|
typeValueInto('#processDefinitionName', 'processwithform');
|
||||||
|
fixture.detectChanges();
|
||||||
|
tick(450);
|
||||||
|
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
|
fixture.detectChanges();
|
||||||
const firstNameEl = fixture.nativeElement.querySelector('#firstName');
|
const firstNameEl = fixture.nativeElement.querySelector('#firstName');
|
||||||
expect(firstNameEl).toBeDefined();
|
expect(firstNameEl).toBeDefined();
|
||||||
expect(firstNameEl.value).toEqual('FakeName');
|
expect(firstNameEl.value).toEqual('FakeName');
|
||||||
@ -293,17 +336,19 @@ describe('StartProcessCloudComponent', () => {
|
|||||||
const change = new SimpleChange(null, 'MyApp', true);
|
const change = new SimpleChange(null, 'MyApp', true);
|
||||||
component.ngOnChanges({ 'appName': change });
|
component.ngOnChanges({ 'appName': change });
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
fixture.whenStable();
|
|
||||||
tick(450);
|
tick(450);
|
||||||
|
|
||||||
const startBtn = fixture.nativeElement.querySelector('#button-start');
|
fixture.whenStable().then(() => {
|
||||||
expect(startBtn.disabled).toBe(false);
|
fixture.detectChanges();
|
||||||
expect(component.formCloud.isValid).toBe(true);
|
const startBtn = fixture.nativeElement.querySelector('#button-start');
|
||||||
expect(component.isProcessFormValid()).toBe(true);
|
expect(startBtn.disabled).toBe(false);
|
||||||
expect(createProcessSpy).toHaveBeenCalledWith('MyApp', new ProcessPayloadCloud({name: 'testFormWithProcess',
|
expect(component.formCloud.isValid).toBe(true);
|
||||||
processDefinitionKey: fakeProcessDefinitions[1].key}));
|
expect(component.isProcessFormValid()).toBe(true);
|
||||||
expect(component.currentCreatedProcess.status).toBe('CREATED');
|
expect(createProcessSpy).toHaveBeenCalledWith('MyApp', new ProcessPayloadCloud({name: 'testFormWithProcess',
|
||||||
expect(component.currentCreatedProcess.startDate).toBeNull();
|
processDefinitionKey: fakeProcessDefinitions[1].key}));
|
||||||
|
expect(component.currentCreatedProcess.status).toBe('CREATED');
|
||||||
|
expect(component.currentCreatedProcess.startDate).toBeNull();
|
||||||
|
});
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ import { FormControl, Validators, FormGroup, AbstractControl, FormBuilder, Valid
|
|||||||
import { FormModel, ContentLinkModel } from '@alfresco/adf-core';
|
import { FormModel, ContentLinkModel } from '@alfresco/adf-core';
|
||||||
import { MatAutocompleteTrigger } from '@angular/material';
|
import { MatAutocompleteTrigger } from '@angular/material';
|
||||||
import { ProcessPayloadCloud } from '../models/process-payload-cloud.model';
|
import { ProcessPayloadCloud } from '../models/process-payload-cloud.model';
|
||||||
import { debounceTime, takeUntil, switchMap, filter, distinctUntilChanged } from 'rxjs/operators';
|
import { debounceTime, takeUntil, switchMap, filter, distinctUntilChanged, tap } from 'rxjs/operators';
|
||||||
import { ProcessDefinitionCloud } from '../models/process-definition-cloud.model';
|
import { ProcessDefinitionCloud } from '../models/process-definition-cloud.model';
|
||||||
import { Subject, Observable, concat } from 'rxjs';
|
import { Subject, Observable, concat } from 'rxjs';
|
||||||
import { TaskVariableCloud } from '../../../form/models/task-variable-cloud.model';
|
import { TaskVariableCloud } from '../../../form/models/task-variable-cloud.model';
|
||||||
@ -122,6 +122,7 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy
|
|||||||
|
|
||||||
this.processForm.valueChanges
|
this.processForm.valueChanges
|
||||||
.pipe(
|
.pipe(
|
||||||
|
tap(() => this.currentCreatedProcess = undefined),
|
||||||
debounceTime(400),
|
debounceTime(400),
|
||||||
distinctUntilChanged(),
|
distinctUntilChanged(),
|
||||||
filter(() => this.isProcessSelectionValid()),
|
filter(() => this.isProcessSelectionValid()),
|
||||||
|
@ -39,19 +39,19 @@ export class GroupCloudComponentPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async selectGroupFromList(name: string): Promise<void> {
|
async selectGroupFromList(name: string): Promise<void> {
|
||||||
const groupRow = element.all(by.cssContainingText('mat-option span', name)).first();
|
const groupRow = element.all(by.css(`mat-option[data-automation-id="adf-cloud-group-chip-${name}"]`)).first();
|
||||||
|
|
||||||
await BrowserActions.click(groupRow);
|
await BrowserActions.click(groupRow);
|
||||||
await BrowserVisibility.waitUntilElementIsNotVisible(groupRow);
|
await BrowserVisibility.waitUntilElementIsNotVisible(groupRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
async checkGroupIsDisplayed(name: string): Promise<void> {
|
async checkGroupIsDisplayed(name: string): Promise<void> {
|
||||||
const groupRow = element.all(by.cssContainingText('mat-option span', name)).first();
|
const groupRow = element.all(by.css(`mat-option[data-automation-id="adf-cloud-group-chip-${name}"]`)).first();
|
||||||
await BrowserVisibility.waitUntilElementIsVisible(groupRow);
|
await BrowserVisibility.waitUntilElementIsVisible(groupRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
async checkGroupIsNotDisplayed(name: string): Promise<void> {
|
async checkGroupIsNotDisplayed(name: string): Promise<void> {
|
||||||
const groupRow = element.all(by.cssContainingText('mat-option span', name)).first();
|
const groupRow = element.all(by.css(`mat-option[data-automation-id="adf-cloud-group-chip-${name}"]`)).first();
|
||||||
await BrowserVisibility.waitUntilElementIsNotVisible(groupRow);
|
await BrowserVisibility.waitUntilElementIsNotVisible(groupRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,6 +87,7 @@ export class StartProcessCloudPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async checkStartProcessButtonIsEnabled(): Promise<boolean> {
|
async checkStartProcessButtonIsEnabled(): Promise<boolean> {
|
||||||
|
await browser.sleep(1000); // waiting for API response
|
||||||
await BrowserVisibility.waitUntilElementIsPresent(this.startProcessButton);
|
await BrowserVisibility.waitUntilElementIsPresent(this.startProcessButton);
|
||||||
return this.startProcessButton.isEnabled();
|
return this.startProcessButton.isEnabled();
|
||||||
}
|
}
|
||||||
@ -114,7 +115,6 @@ export class StartProcessCloudPage {
|
|||||||
await this.clearField(this.processNameInput);
|
await this.clearField(this.processNameInput);
|
||||||
await this.enterProcessName(processName);
|
await this.enterProcessName(processName);
|
||||||
await this.selectFromProcessDropdown(processDefinition);
|
await this.selectFromProcessDropdown(processDefinition);
|
||||||
await browser.sleep(4000); // remove this once AAE-2505 is fixed
|
|
||||||
await this.checkStartProcessButtonIsEnabled();
|
await this.checkStartProcessButtonIsEnabled();
|
||||||
await this.clickStartProcessButton();
|
await this.clickStartProcessButton();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user