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 formDefinitionSpy: jasmine.Spy;
|
||||
|
||||
const firstChange = new SimpleChange(undefined, 'myApp', true);
|
||||
|
||||
const selectOptionByName = (name: string) => {
|
||||
|
||||
const selectElement = fixture.nativeElement.querySelector('button#adf-select-process-dropdown');
|
||||
@@ -540,7 +542,7 @@ describe('StartProcessCloudComponent', () => {
|
||||
|
||||
describe('input changes', () => {
|
||||
|
||||
const change = new SimpleChange('myApp', 'myApp1', true);
|
||||
const change = new SimpleChange('myApp', 'myApp1', false);
|
||||
|
||||
beforeEach(async(() => {
|
||||
component.appName = 'myApp';
|
||||
@@ -554,7 +556,7 @@ describe('StartProcessCloudComponent', () => {
|
||||
it('should have labels for process name and type', async(() => {
|
||||
component.appName = 'myApp';
|
||||
component.processDefinitionName = 'NewProcess 2';
|
||||
component.ngOnChanges({});
|
||||
component.ngOnChanges({ appName: firstChange });
|
||||
fixture.detectChanges();
|
||||
const inputLabelsNodes = document.querySelectorAll('.adf-start-process .adf-process-input-container mat-label');
|
||||
expect(inputLabelsNodes.length).toBe(2);
|
||||
@@ -572,6 +574,7 @@ describe('StartProcessCloudComponent', () => {
|
||||
}));
|
||||
|
||||
it('should reload processes when appName input changed', async(() => {
|
||||
component.ngOnChanges({ appName: firstChange });
|
||||
component.ngOnChanges({ appName: change });
|
||||
fixture.detectChanges();
|
||||
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', () => {
|
||||
component.ngOnChanges({ appName: change });
|
||||
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(() => {
|
||||
component.appName = 'myApp';
|
||||
component.processDefinitionName = ' Space in the beginning';
|
||||
component.ngOnChanges({});
|
||||
component.ngOnChanges({ appName: firstChange });
|
||||
fixture.detectChanges();
|
||||
const startBtn = fixture.nativeElement.querySelector('#button-start');
|
||||
expect(startBtn.disabled).toBe(true);
|
||||
@@ -734,6 +747,9 @@ describe('StartProcessCloudComponent', () => {
|
||||
}));
|
||||
|
||||
it('should emit processDefinitionSelection event when a process definition is selected', (done) => {
|
||||
component.appName = 'myApp';
|
||||
component.ngOnChanges({ appName: firstChange });
|
||||
|
||||
component.processDefinitionSelection.subscribe((processDefinition) => {
|
||||
expect(processDefinition).toEqual(fakeProcessDefinitions[0]);
|
||||
done();
|
||||
|
@@ -148,10 +148,10 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
if (changes['appName'] && changes['appName'].currentValue !== changes['appName'].previousValue) {
|
||||
this.appName = changes['appName'].currentValue;
|
||||
}
|
||||
|
||||
if (this.appName || this.appName === '') {
|
||||
this.loadProcessDefinitions();
|
||||
if (this.appName || this.appName === '') {
|
||||
this.loadProcessDefinitions();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user