Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
dotCMS/core#14999 UI feedback when delete a field without permission (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
fmontes committed Aug 17, 2018
1 parent 5837b8f commit cf17237
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,26 @@ describe('ContentTypesEditComponent edit mode', () => {
expect(comp.fields).toEqual(fieldsReturnByServer);
});

it('should handle remove field error', () => {
spyOn(dotHttpErrorManagerService, 'handle').and.callThrough();
const fieldService = fixture.debugElement.injector.get(FieldService);
spyOn(fieldService, 'deleteFields').and.returnValue(Observable.throw(mockResponseView(403)));

const contentTypeFieldsDropZone = de.query(By.css('dot-content-type-fields-drop-zone'));

const fieldToRemove = {
name: 'field 3',
id: '3',
clazz: 'com.dotcms.contenttype.model.field.ImmutableColumnField',
sortOrder: 3
};

// when: the saveFields event is tiggered in content-type-fields-drop-zone
contentTypeFieldsDropZone.componentInstance.removeFields.emit(fieldToRemove);

expect(dotHttpErrorManagerService.handle).toHaveBeenCalledTimes(1);
});

describe('update', () => {
let contentTypeForm: DebugElement;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ export class ContentTypesEditComponent implements OnInit {
.pluck('fields')
.subscribe((fields: ContentTypeField[]) => {
this.fields = fields;
}, (err: ResponseView) => {
this.dotHttpErrorManagerService.handle(err).subscribe((() => {}));
});
}

Expand Down

0 comments on commit cf17237

Please sign in to comment.