fix random test failing part 2 (#3395)

* fix random failing test core search/comment/auth/user

* fix node delete directive

* fix lint issues

* node restore fix

* fix comment test

* remove fdescribe

* fix tests and tslint

* fix upload test

* unsubscribe success event task test

* copy comment object during test

* use the data pipe performance improvement and standard usage

* uncomment random test

* fix comment date random failing test

* disposable unsubscribe

* fix start process

* remove fdescribe

* change start process test and remove commented code

* fix error event check double click

* clone object form test

* refactor date time test

* fix service mock

* fix test dropdown and context

* git hook lint

* fix language test

* unsubscribe documentlist event test

* fix disposable error

* fix console log service error document list

* unusbscribe search test

* clear input field

* remove wrong test
This commit is contained in:
Eugenio Romano
2018-05-29 11:18:17 +02:00
committed by Denys Vuika
parent 22006395c7
commit eb0f91c5db
43 changed files with 4475 additions and 4332 deletions

View File

@@ -50,7 +50,7 @@ describe('FormFieldComponent', () => {
fixture.destroy();
});
it('should create default component instance', () => {
it('should create default component instance', (done) => {
let field = new FormFieldModel(form, {
type: FormFieldTypes.TEXT,
id: 'FAKE-TXT-WIDGET'
@@ -59,25 +59,32 @@ describe('FormFieldComponent', () => {
component.field = field;
fixture.detectChanges();
expect(component.componentRef).toBeDefined();
expect(component.componentRef.componentType).toBe(TextWidgetComponent);
fixture.whenStable().then(() => {
expect(component.componentRef).toBeDefined();
expect(component.componentRef.instance instanceof TextWidgetComponent).toBeTruthy();
done();
});
});
it('should create custom component instance', () => {
it('should create custom component instance', (done) => {
formRenderingService.setComponentTypeResolver(FormFieldTypes.AMOUNT, () => CheckboxWidgetComponent, true);
let field = new FormFieldModel(form, {
type: FormFieldTypes.TEXT,
type: FormFieldTypes.AMOUNT,
id: 'FAKE-TXT-WIDGET'
});
formRenderingService.setComponentTypeResolver(FormFieldTypes.TEXT, () => CheckboxWidgetComponent, true);
component.field = field;
fixture.detectChanges();
expect(component.componentRef).toBeDefined();
expect(component.componentRef.componentType).toBe(CheckboxWidgetComponent);
fixture.whenStable().then(() => {
expect(component.componentRef).toBeDefined();
expect(component.componentRef.instance instanceof CheckboxWidgetComponent).toBeTruthy();
done();
});
});
it('should require component type to be resolved', () => {
it('should require component type to be resolved', (done) => {
let field = new FormFieldModel(form, {
type: FormFieldTypes.TEXT,
id: 'FAKE-TXT-WIDGET'
@@ -87,11 +94,14 @@ describe('FormFieldComponent', () => {
component.field = field;
fixture.detectChanges();
expect(formRenderingService.resolveComponentType).toHaveBeenCalled();
expect(component.componentRef).toBeUndefined();
fixture.whenStable().then(() => {
expect(formRenderingService.resolveComponentType).toHaveBeenCalled();
expect(component.componentRef).toBeUndefined();
done();
});
});
it('should hide the field when it is not visible', () => {
it('should hide the field when it is not visible', (done) => {
let field = new FormFieldModel(form, {
type: FormFieldTypes.TEXT,
id: 'FAKE-TXT-WIDGET'
@@ -100,10 +110,13 @@ describe('FormFieldComponent', () => {
component.field = field;
component.field.isVisible = false;
fixture.detectChanges();
expect(fixture.nativeElement.querySelector('#field-FAKE-TXT-WIDGET-container').hidden).toBeTruthy();
fixture.whenStable().then(() => {
expect(fixture.nativeElement.querySelector('#field-FAKE-TXT-WIDGET-container').hidden).toBeTruthy();
done();
});
});
it('should show the field when it is visible', () => {
it('should show the field when it is visible', (done) => {
let field = new FormFieldModel(form, {
type: FormFieldTypes.TEXT,
id: 'FAKE-TXT-WIDGET'
@@ -111,7 +124,11 @@ describe('FormFieldComponent', () => {
component.field = field;
fixture.detectChanges();
expect(fixture.nativeElement.querySelector('#field-FAKE-TXT-WIDGET-container').hidden).toBeFalsy();
fixture.whenStable().then(() => {
expect(fixture.nativeElement.querySelector('#field-FAKE-TXT-WIDGET-container').hidden).toBeFalsy();
done();
});
});
it('should hide a visible element', () => {

View File

@@ -226,7 +226,7 @@ describe('FormComponent', () => {
});
it('should refresh visibility when the form is loaded', () => {
spyOn(formService, 'getFormDefinitionById').and.returnValue(Observable.of(fakeForm));
spyOn(formService, 'getFormDefinitionById').and.returnValue(Observable.of(JSON.parse(JSON.stringify(fakeForm))));
const formId = '123';
formComponent.formId = formId;
@@ -816,7 +816,7 @@ describe('FormComponent', () => {
});
it('should refresh form values when data is changed', () => {
formComponent.form = new FormModel(fakeForm);
formComponent.form = new FormModel(JSON.parse(JSON.stringify(fakeForm)));
let formFields = formComponent.form.getFormFields();
let labelField = formFields.find(field => field.id === 'label');
@@ -842,7 +842,7 @@ describe('FormComponent', () => {
});
it('should refresh radio buttons value when id is given to data', () => {
formComponent.form = new FormModel(fakeForm);
formComponent.form = new FormModel(JSON.parse(JSON.stringify(fakeForm)));
let formFields = formComponent.form.getFormFields();
let radioFieldById = formFields.find(field => field.id === 'radio');

View File

@@ -46,6 +46,7 @@ describe('DateTimeWidgetComponent', () => {
afterEach(() => {
fixture.destroy();
TestBed.resetTestingModule();
});
it('should setup min value for date picker', () => {

View File

@@ -100,7 +100,12 @@ describe('DateWidgetComponent', () => {
describe('template check', () => {
beforeEach(() => {
afterEach(() => {
fixture.destroy();
TestBed.resetTestingModule();
});
it('should show visible date widget', async(() => {
widget.field = new FormFieldModel(new FormModel(), {
id: 'date-field-id',
name: 'date-name',
@@ -109,15 +114,8 @@ describe('DateWidgetComponent', () => {
readOnly: 'false'
});
widget.field.isVisible = true;
widget.ngOnInit();
fixture.detectChanges();
});
afterEach(() => {
fixture.destroy();
TestBed.resetTestingModule();
});
it('should show visible date widget', async(() => {
fixture.whenStable().then(() => {
expect(element.querySelector('#date-field-id')).toBeDefined();
expect(element.querySelector('#date-field-id')).not.toBeNull();
@@ -127,11 +125,17 @@ describe('DateWidgetComponent', () => {
}));
it('should check correctly the min value with different formats', async(() => {
widget.field.value = '11-30-9999';
widget.field.dateDisplayFormat = 'MM-DD-YYYY';
widget.field.minValue = '30-12-9999';
widget.field = new FormFieldModel(new FormModel(), {
id: 'date-field-id',
name: 'date-name',
value: '11-30-9999',
type: 'date',
readOnly: 'false',
dateDisplayFormat : 'MM-DD-YYYY',
minValue : '30-12-9999'
});
widget.field.isVisible = true;
widget.ngOnInit();
widget.field.validate();
fixture.detectChanges();
fixture.whenStable()
.then(() => {
@@ -144,7 +148,14 @@ describe('DateWidgetComponent', () => {
}));
it('should show the correct format type', async(() => {
widget.field.value = '12-30-9999';
widget.field = new FormFieldModel(new FormModel(), {
id: 'date-field-id',
name: 'date-name',
value: '12-30-9999';
type: 'date',
readOnly: 'false'
});
widget.field.isVisible = true;
widget.field.dateDisplayFormat = 'MM-DD-YYYY';
widget.ngOnInit();
fixture.detectChanges();
@@ -158,6 +169,14 @@ describe('DateWidgetComponent', () => {
}));
it('should disable date button when is readonly', async(() => {
widget.field = new FormFieldModel(new FormModel(), {
id: 'date-field-id',
name: 'date-name',
value: '9-9-9999',
type: 'date',
readOnly: 'false'
});
widget.field.isVisible = true;
widget.field.readOnly = false;
fixture.detectChanges();