mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACA-3522] Fix start process feature (infinite loop, process name gets updated every second) (#5818)
This commit is contained in:
@@ -57,6 +57,8 @@ describe('StartProcessCloudComponent', () => {
|
|||||||
let createProcessSpy: jasmine.Spy;
|
let createProcessSpy: jasmine.Spy;
|
||||||
let formDefinitionSpy: jasmine.Spy;
|
let formDefinitionSpy: jasmine.Spy;
|
||||||
|
|
||||||
|
const firstChange = new SimpleChange(undefined, 'myApp', true);
|
||||||
|
|
||||||
const selectOptionByName = (name: string) => {
|
const selectOptionByName = (name: string) => {
|
||||||
|
|
||||||
const selectElement = fixture.nativeElement.querySelector('button#adf-select-process-dropdown');
|
const selectElement = fixture.nativeElement.querySelector('button#adf-select-process-dropdown');
|
||||||
@@ -540,7 +542,7 @@ describe('StartProcessCloudComponent', () => {
|
|||||||
|
|
||||||
describe('input changes', () => {
|
describe('input changes', () => {
|
||||||
|
|
||||||
const change = new SimpleChange('myApp', 'myApp1', true);
|
const change = new SimpleChange('myApp', 'myApp1', false);
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
component.appName = 'myApp';
|
component.appName = 'myApp';
|
||||||
@@ -554,7 +556,7 @@ describe('StartProcessCloudComponent', () => {
|
|||||||
it('should have labels for process name and type', async(() => {
|
it('should have labels for process name and type', async(() => {
|
||||||
component.appName = 'myApp';
|
component.appName = 'myApp';
|
||||||
component.processDefinitionName = 'NewProcess 2';
|
component.processDefinitionName = 'NewProcess 2';
|
||||||
component.ngOnChanges({});
|
component.ngOnChanges({ appName: firstChange });
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const inputLabelsNodes = document.querySelectorAll('.adf-start-process .adf-process-input-container mat-label');
|
const inputLabelsNodes = document.querySelectorAll('.adf-start-process .adf-process-input-container mat-label');
|
||||||
expect(inputLabelsNodes.length).toBe(2);
|
expect(inputLabelsNodes.length).toBe(2);
|
||||||
@@ -572,6 +574,7 @@ describe('StartProcessCloudComponent', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('should reload processes when appName input changed', async(() => {
|
it('should reload processes when appName input changed', async(() => {
|
||||||
|
component.ngOnChanges({ appName: firstChange });
|
||||||
component.ngOnChanges({ appName: change });
|
component.ngOnChanges({ appName: change });
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
@@ -579,6 +582,16 @@ describe('StartProcessCloudComponent', () => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('should reload processes ONLY when appName input changed', async(() => {
|
||||||
|
component.ngOnChanges({ appName: firstChange });
|
||||||
|
fixture.detectChanges();
|
||||||
|
component.ngOnChanges({ maxNameLength: new SimpleChange(0, 2, false) });
|
||||||
|
fixture.detectChanges();
|
||||||
|
fixture.whenStable().then(() => {
|
||||||
|
expect(getDefinitionsSpy).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
it('should get current processDef', () => {
|
it('should get current processDef', () => {
|
||||||
component.ngOnChanges({ appName: change });
|
component.ngOnChanges({ appName: change });
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@@ -724,7 +737,7 @@ describe('StartProcessCloudComponent', () => {
|
|||||||
it('should have start button disabled process name has a space as the first or last character.', async(() => {
|
it('should have start button disabled process name has a space as the first or last character.', async(() => {
|
||||||
component.appName = 'myApp';
|
component.appName = 'myApp';
|
||||||
component.processDefinitionName = ' Space in the beginning';
|
component.processDefinitionName = ' Space in the beginning';
|
||||||
component.ngOnChanges({});
|
component.ngOnChanges({ appName: firstChange });
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const startBtn = fixture.nativeElement.querySelector('#button-start');
|
const startBtn = fixture.nativeElement.querySelector('#button-start');
|
||||||
expect(startBtn.disabled).toBe(true);
|
expect(startBtn.disabled).toBe(true);
|
||||||
@@ -734,6 +747,9 @@ describe('StartProcessCloudComponent', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
it('should emit processDefinitionSelection event when a process definition is selected', (done) => {
|
it('should emit processDefinitionSelection event when a process definition is selected', (done) => {
|
||||||
|
component.appName = 'myApp';
|
||||||
|
component.ngOnChanges({ appName: firstChange });
|
||||||
|
|
||||||
component.processDefinitionSelection.subscribe((processDefinition) => {
|
component.processDefinitionSelection.subscribe((processDefinition) => {
|
||||||
expect(processDefinition).toEqual(fakeProcessDefinitions[0]);
|
expect(processDefinition).toEqual(fakeProcessDefinitions[0]);
|
||||||
done();
|
done();
|
||||||
|
@@ -148,12 +148,12 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy
|
|||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
if (changes['appName'] && changes['appName'].currentValue !== changes['appName'].previousValue) {
|
if (changes['appName'] && changes['appName'].currentValue !== changes['appName'].previousValue) {
|
||||||
this.appName = changes['appName'].currentValue;
|
this.appName = changes['appName'].currentValue;
|
||||||
}
|
|
||||||
|
|
||||||
if (this.appName || this.appName === '') {
|
if (this.appName || this.appName === '') {
|
||||||
this.loadProcessDefinitions();
|
this.loadProcessDefinitions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
hasForm(): boolean {
|
hasForm(): boolean {
|
||||||
return this.processDefinitionCurrent && !!this.processDefinitionCurrent.formKey;
|
return this.processDefinitionCurrent && !!this.processDefinitionCurrent.formKey;
|
||||||
|
Reference in New Issue
Block a user