diff --git a/resources/i18n/en.json b/resources/i18n/en.json index 70a1fc20b0..46d7617f6c 100644 --- a/resources/i18n/en.json +++ b/resources/i18n/en.json @@ -44,19 +44,21 @@ "sub-community-list": { "head": "Communities of this Community" }, - "edit": { - "head": "Edit collction", - "name": "Name", - "description": "Short Description", - "introductory": "Introductory text (HTML)", - "copyright": "Copyright text (HTML)", - "news": "News (HTML)", - "submit": "Submit", - "cancel": "Cancel", - "required": { - "name": "Please enter a community name" + "form": { + "title": "Name", + "description": "Introductory text (HTML)", + "abstract": "Short Description", + "rights": "Copyright text (HTML)", + "tableofcontents": "News (HTML)", + "errors": { + "title": { + "required": "Please enter a community name" + } } }, + "edit": { + "head": "Edit collection" + }, "create": { "head": "Create a Community", "sub-head": "Create a Sub-Community for Community {{ parent }}" diff --git a/src/app/+collection-page/collection-form/collection-form.component.spec.ts b/src/app/+collection-page/collection-form/collection-form.component.spec.ts index d2aafa2050..71ae92572d 100644 --- a/src/app/+collection-page/collection-form/collection-form.component.spec.ts +++ b/src/app/+collection-page/collection-form/collection-form.component.spec.ts @@ -4,9 +4,10 @@ import { TranslateModule } from '@ngx-translate/core'; import { CommonModule } from '@angular/common'; import { RouterTestingModule } from '@angular/router/testing'; import { By } from '@angular/platform-browser'; -import { DebugElement } from '@angular/core'; +import { DebugElement, NO_ERRORS_SCHEMA } from '@angular/core'; import { CollectionFormComponent } from './collection-form.component'; import { Location } from '@angular/common'; +import { DynamicFormService } from '@ng-dynamic-forms/core'; describe('CommunityFormComponent', () => { let comp: CollectionFormComponent; @@ -24,8 +25,9 @@ describe('CommunityFormComponent', () => { imports: [TranslateModule.forRoot(), SharedModule, CommonModule, RouterTestingModule], declarations: [CollectionFormComponent], providers: [ - { provide: Location, useValue: locationStub } - ] + { provide: Location, useValue: locationStub }, + ], + schemas: [NO_ERRORS_SCHEMA] }).compileComponents(); })); diff --git a/src/app/+collection-page/create-collection-page/create-collection-page.component.spec.ts b/src/app/+collection-page/create-collection-page/create-collection-page.component.spec.ts index 6196945d80..837741d593 100644 --- a/src/app/+collection-page/create-collection-page/create-collection-page.component.spec.ts +++ b/src/app/+collection-page/create-collection-page/create-collection-page.component.spec.ts @@ -1,15 +1,11 @@ import { SharedModule } from '../../shared/shared.module'; import { Community } from '../../core/shared/community.model'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { DSOSuccessResponse, ErrorResponse } from '../../core/cache/response-cache.models'; -import { CommonModule } from '@angular/common'; -import { CreateCommunityPageComponent } from '../../+community-page/create-community-page/create-community-page.component'; +import { CommonModule, Location } from '@angular/common'; import { Router } from '@angular/router'; import { TranslateModule } from '@ngx-translate/core'; -import { CommunityFormComponent } from '../../+community-page/community-form/community-form.component'; -import { Observable } from 'rxjs/Observable'; +import { Observable } from 'rxjs'; import { CommunityDataService } from '../../core/data/community-data.service'; -import { RequestError } from '../../core/data/request.models'; import { RouteService } from '../../shared/services/route.service'; import { RemoteData } from '../../core/data/remote-data'; import { CreateCollectionPageComponent } from './create-collection-page.component'; @@ -17,6 +13,8 @@ import { CollectionDataService } from '../../core/data/collection-data.service'; import { Collection } from '../../core/shared/collection.model'; import { RouterTestingModule } from '@angular/router/testing'; import { CollectionFormComponent } from '../collection-form/collection-form.component'; +import { of as observableOf } from 'rxjs'; +import { NO_ERRORS_SCHEMA } from '@angular/core'; describe('CreateCollectionPageComponent', () => { let comp: CreateCollectionPageComponent; @@ -28,25 +26,33 @@ describe('CreateCollectionPageComponent', () => { const community = Object.assign(new Community(), { uuid: 'a20da287-e174-466a-9926-f66b9300d347', - name: 'test community' + metadata: [{ + key: 'dc.title', + value: 'test collection' + }] }); const collection = Object.assign(new Collection(), { uuid: 'ce41d451-97ed-4a9c-94a1-7de34f16a9f4', - name: 'new collection' - }); + metadata: [{ + key: 'dc.title', + value: 'new collection' + }] }); const collectionDataServiceStub = { - create: (col, uuid?) => Observable.of(new RemoteData(false, false, true, undefined, collection)) + create: (col, uuid?) => observableOf(new RemoteData(false, false, true, undefined, collection)) }; const communityDataServiceStub = { - findById: (uuid) => Observable.of(new RemoteData(false, false, true, null, Object.assign(new Community(), { + findById: (uuid) => observableOf(new RemoteData(false, false, true, null, Object.assign(new Community(), { uuid: uuid, - name: community.name + metadata: [{ + key: 'dc.title', + value: community.name + }] }))) }; const routeServiceStub = { - getQueryParameterValue: (param) => Observable.of(community.uuid) + getQueryParameterValue: (param) => observableOf(community.uuid) }; const routerStub = { navigate: (commands) => commands @@ -55,13 +61,14 @@ describe('CreateCollectionPageComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [TranslateModule.forRoot(), SharedModule, CommonModule, RouterTestingModule], - declarations: [CreateCollectionPageComponent, CollectionFormComponent], + declarations: [CreateCollectionPageComponent], providers: [ { provide: CollectionDataService, useValue: collectionDataServiceStub }, { provide: CommunityDataService, useValue: communityDataServiceStub }, { provide: RouteService, useValue: routeServiceStub }, { provide: Router, useValue: routerStub } - ] + ], + schemas: [NO_ERRORS_SCHEMA] }).compileComponents(); })); @@ -77,7 +84,10 @@ describe('CreateCollectionPageComponent', () => { describe('onSubmit', () => { const data = { - name: 'test' + metadata: [{ + key: 'dc.title', + value:'test' + }] }; it('should navigate when successful', () => { @@ -89,7 +99,7 @@ describe('CreateCollectionPageComponent', () => { it('should not navigate on failure', () => { spyOn(router, 'navigate'); - spyOn(collectionDataService, 'create').and.returnValue(Observable.of(new RemoteData(true, true, false, undefined, collection))); + spyOn(collectionDataService, 'create').and.returnValue(observableOf(new RemoteData(true, true, false, undefined, collection))); comp.onSubmit(data); fixture.detectChanges(); expect(router.navigate).not.toHaveBeenCalled(); diff --git a/src/app/+collection-page/create-collection-page/create-collection-page.component.ts b/src/app/+collection-page/create-collection-page/create-collection-page.component.ts index d934e1d7a0..1bb4c31596 100644 --- a/src/app/+collection-page/create-collection-page/create-collection-page.component.ts +++ b/src/app/+collection-page/create-collection-page/create-collection-page.component.ts @@ -9,7 +9,6 @@ import { Observable } from 'rxjs'; import { take } from 'rxjs/operators'; import { RemoteData } from '../../core/data/remote-data'; import { isNotEmpty } from '../../shared/empty.util'; -import { NormalizedCollection } from '../../core/cache/models/normalized-collection.model'; import { ResourceType } from '../../core/shared/resource-type'; @Component({ diff --git a/src/app/+community-page/community-form/community-form.component.html b/src/app/+community-page/community-form/community-form.component.html index 637506f86d..c47f077022 100644 --- a/src/app/+community-page/community-form/community-form.component.html +++ b/src/app/+community-page/community-form/community-form.component.html @@ -1,4 +1,3 @@ - - + [formModel]="formModel" (submitForm)="onSubmit()"> \ No newline at end of file diff --git a/src/app/+community-page/community-form/community-form.component.spec.ts b/src/app/+community-page/community-form/community-form.component.spec.ts index ea17d15942..b90a2b0713 100644 --- a/src/app/+community-page/community-form/community-form.component.spec.ts +++ b/src/app/+community-page/community-form/community-form.component.spec.ts @@ -1,31 +1,65 @@ import { CommunityFormComponent } from './community-form.component'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { SharedModule } from '../../shared/shared.module'; import { TranslateModule } from '@ngx-translate/core'; -import { CommonModule } from '@angular/common'; -import { RouterTestingModule } from '@angular/router/testing'; -import { By } from '@angular/platform-browser'; -import { DebugElement } from '@angular/core'; import { Location } from '@angular/common'; +import { RouterTestingModule } from '@angular/router/testing'; +import { NO_ERRORS_SCHEMA } from '@angular/core'; +import { + DynamicFormService, + DynamicInputControlModel, + DynamicInputModel +} from '@ng-dynamic-forms/core'; +import { FormControl, FormGroup } from '@angular/forms'; +import { DynamicFormControlModel } from '@ng-dynamic-forms/core/src/model/dynamic-form-control.model'; +import { Community } from '../../core/shared/community.model'; +import { ResourceType } from '../../core/shared/resource-type'; -describe('CommunityFormComponent', () => { +fdescribe('CommunityFormComponent', () => { let comp: CommunityFormComponent; let fixture: ComponentFixture; let location: Location; + const formServiceStub: any = { + createFormGroup: (formModel: DynamicFormControlModel[]) => { + const controls = {}; + formModel.forEach((controlModel) => { + controls[controlModel.id] = new FormControl((controlModel as any).value); + }); + return new FormGroup(controls); + } + }; + const titleMD = { key: 'dc.title', value: 'Community Title' }; + const randomMD = { key: 'dc.random', value: 'Random metadata excluded from form' }; + const abstractMD = { key: 'dc.description.abstract', value: 'Community description' }; + const newTitleMD = { key: 'dc.title', value: 'New Community Title' }; + const formModel = [ + new DynamicInputModel({ + id: 'title', + name: newTitleMD.key, + value: newTitleMD.value + }), + new DynamicInputModel({ + id: 'abstract', + name: abstractMD.key, + value: abstractMD.value + }) + ]; /* tslint:disable:no-empty */ const locationStub = { - back: () => {} + back: () => { + } }; /* tslint:enable:no-empty */ beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [TranslateModule.forRoot(), SharedModule, CommonModule, RouterTestingModule], + imports: [TranslateModule.forRoot(), RouterTestingModule], declarations: [CommunityFormComponent], providers: [ - { provide: Location, useValue: locationStub } - ] + { provide: Location, useValue: locationStub }, + { provide: DynamicFormService, useValue: formServiceStub } + ], + schemas: [NO_ERRORS_SCHEMA] }).compileComponents(); })); @@ -34,38 +68,41 @@ describe('CommunityFormComponent', () => { comp = fixture.componentInstance; fixture.detectChanges(); location = (comp as any).location; + comp.formModel = formModel; }); - describe('when submitting', () => { - let input: DebugElement; - let submit: DebugElement; - let cancel: DebugElement; - let error: DebugElement; - + describe('onSubmit', () => { beforeEach(() => { - input = fixture.debugElement.query(By.css('input#community-name')); - submit = fixture.debugElement.query(By.css('button#community-submit')); - cancel = fixture.debugElement.query(By.css('button#community-cancel')); - error = fixture.debugElement.query(By.css('div.invalid-feedback')); + spyOn(comp.submitForm, 'emit'); }); - it('should display an error when leaving name empty', () => { - const el = input.nativeElement; + it('should update emit the new version of the community', () => { + comp.community = Object.assign( + new Community(), + { + metadata: [ + titleMD, + randomMD + ] + } + ); - el.value = ''; - el.dispatchEvent(new Event('input')); - submit.nativeElement.click(); - fixture.detectChanges(); + comp.onSubmit(); - expect(error.nativeElement.style.display).not.toEqual('none'); - }); - - it('should navigate back when pressing cancel', () => { - spyOn(location, 'back'); - cancel.nativeElement.click(); - fixture.detectChanges(); - - expect(location.back).toHaveBeenCalled(); - }); - }) + expect(comp.submitForm.emit).toHaveBeenCalledWith( + Object.assign( + {}, + new Community(), + { + metadata: [ + randomMD, + newTitleMD, + abstractMD + ], + type: ResourceType.Community + }, + ) + ); + }) + }); }); diff --git a/src/app/+community-page/community-form/community-form.component.ts b/src/app/+community-page/community-form/community-form.component.ts index fd0b490146..c470cbbf91 100644 --- a/src/app/+community-page/community-form/community-form.component.ts +++ b/src/app/+community-page/community-form/community-form.component.ts @@ -9,7 +9,11 @@ import { FormGroup } from '@angular/forms'; import { DynamicFormControlModel } from '@ng-dynamic-forms/core/src/model/dynamic-form-control.model'; import { Community } from '../../core/shared/community.model'; import { ResourceType } from '../../core/shared/resource-type'; -import { hasValue, isNotEmpty } from '../../shared/empty.util'; +import { isNotEmpty } from '../../shared/empty.util'; +import { TranslateService } from '@ngx-translate/core'; + +const LABEL_KEY_PREFIX = 'community.form.'; +const ERROR_KEY_PREFIX = 'community.form.errors.'; @Component({ selector: 'ds-community-form', @@ -17,40 +21,34 @@ import { hasValue, isNotEmpty } from '../../shared/empty.util'; templateUrl: './community-form.component.html' }) export class CommunityFormComponent implements OnInit { - @Input() community: Community = new Community(); formModel: DynamicFormControlModel[] = [ new DynamicInputModel({ id: 'title', name: 'dc.title', - label: 'Name', required: true, validators: { required: null }, errorMessages: { required: 'Please enter a name for this title' - } + }, }), new DynamicTextAreaModel({ id: 'description', name: 'dc.description', - label: 'Introductory text (HTML)', }), new DynamicTextAreaModel({ id: 'abstract', name: 'dc.description.abstract', - label: 'Short Description', }), new DynamicTextAreaModel({ id: 'rights', name: 'dc.rights', - label: 'Copyright text (HTML)', }), new DynamicTextAreaModel({ id: 'tableofcontents', name: 'dc.description.tableofcontents', - label: 'News (HTML)', }), ]; @@ -58,7 +56,9 @@ export class CommunityFormComponent implements OnInit { @Output() submitForm: EventEmitter = new EventEmitter(); - public constructor(private location: Location, private formService: DynamicFormService) { + public constructor(private location: Location, + private formService: DynamicFormService, + private translate: TranslateService) { } ngOnInit(): void { @@ -68,10 +68,14 @@ export class CommunityFormComponent implements OnInit { } ); this.formGroup = this.formService.createFormGroup(this.formModel); + this.updateFieldTranslations(); + this.translate.onLangChange + .subscribe(() => { + this.updateFieldTranslations(); + }); } - onSubmit(event: Event) { - event.stopPropagation(); + onSubmit() { const metadata = this.formModel.map( (fieldModel: DynamicInputModel) => { return { key: fieldModel.name, value: fieldModel.value } @@ -87,7 +91,17 @@ export class CommunityFormComponent implements OnInit { this.submitForm.emit(updatedCommunity); } - cancel() { - this.location.back(); + private updateFieldTranslations() { + this.formModel.forEach( + (fieldModel: DynamicInputModel) => { + fieldModel.label = this.translate.instant(LABEL_KEY_PREFIX + fieldModel.id); + if (isNotEmpty(fieldModel.validators)) { + fieldModel.errorMessages = {}; + Object.keys(fieldModel.validators).forEach((key) => { + fieldModel.errorMessages[key] = this.translate.instant(ERROR_KEY_PREFIX + fieldModel.id + '.' + key); + }); + } + } + ); } } diff --git a/src/app/+community-page/create-community-page/create-community-page.component.html b/src/app/+community-page/create-community-page/create-community-page.component.html index bb0f5b83af..aeb4713b52 100644 --- a/src/app/+community-page/create-community-page/create-community-page.component.html +++ b/src/app/+community-page/create-community-page/create-community-page.component.html @@ -1,9 +1,9 @@
- - -

{{ 'community.create.sub-head' | translate:{ parent: community.name } }}

+ + +

{{ 'community.create.sub-head' | translate:{ parent: parent.name } }}

diff --git a/src/app/+community-page/create-community-page/create-community-page.component.spec.ts b/src/app/+community-page/create-community-page/create-community-page.component.spec.ts index e76b10bde6..83db9561cc 100644 --- a/src/app/+community-page/create-community-page/create-community-page.component.spec.ts +++ b/src/app/+community-page/create-community-page/create-community-page.component.spec.ts @@ -4,55 +4,76 @@ import { CommunityDataService } from '../../core/data/community-data.service'; import { RouteService } from '../../shared/services/route.service'; import { Router } from '@angular/router'; import { TranslateModule } from '@ngx-translate/core'; -import { Observable } from 'rxjs/Observable'; +import { of as observableOf } from 'rxjs'; import { RemoteData } from '../../core/data/remote-data'; import { Community } from '../../core/shared/community.model'; -import { DSOSuccessResponse, ErrorResponse } from '../../core/cache/response-cache.models'; import { SharedModule } from '../../shared/shared.module'; import { CommonModule } from '@angular/common'; -import { CommunityFormComponent } from '../community-form/community-form.component'; import { RouterTestingModule } from '@angular/router/testing'; +import { NO_ERRORS_SCHEMA } from '@angular/core'; -describe('CreateCommunityPageComponent', () => { +fdescribe('CreateCommunityPageComponent', () => { let comp: CreateCommunityPageComponent; let fixture: ComponentFixture; let communityDataService: CommunityDataService; let routeService: RouteService; let router: Router; - const community = Object.assign(new Community(), { - uuid: 'a20da287-e174-466a-9926-f66b9300d347', - name: 'test community' - }); + let community; + let newCommunity; + let communityDataServiceStub; + let routeServiceStub; + let routerStub; - const newCommunity = Object.assign(new Community(), { - uuid: '1ff59938-a69a-4e62-b9a4-718569c55d48', - name: 'new community' - }); + function initializeVars() { + community = Object.assign(new Community(), { + uuid: 'a20da287-e174-466a-9926-f66b9300d347', + metadata: [{ + key: 'dc.title', + value: 'test community' + }] + }); - const communityDataServiceStub = { - findById: (uuid) => Observable.of(new RemoteData(false, false, true, null, Object.assign(new Community(), { - uuid: uuid, - name: community.name - }))), - create: (com, uuid?) => Observable.of(new RemoteData(false, false, true, undefined, newCommunity)) - }; - const routeServiceStub = { - getQueryParameterValue: (param) => Observable.of(community.uuid) - }; - const routerStub = { - navigate: (commands) => commands - }; + newCommunity = Object.assign(new Community(), { + uuid: '1ff59938-a69a-4e62-b9a4-718569c55d48', + metadata: [{ + key: 'dc.title', + value: 'new community' + }] + }); + + communityDataServiceStub = { + findById: (uuid) => observableOf(new RemoteData(false, false, true, null, Object.assign(new Community(), { + uuid: uuid, + metadata: [{ + key: 'dc.title', + value: community.name + }] + }))), + create: (com, uuid?) => observableOf(new RemoteData(false, false, true, undefined, newCommunity)) + + }; + + routeServiceStub = { + getQueryParameterValue: (param) => observableOf(community.uuid) + }; + routerStub = { + navigate: (commands) => commands + }; + + } beforeEach(async(() => { + initializeVars(); TestBed.configureTestingModule({ imports: [TranslateModule.forRoot(), SharedModule, CommonModule, RouterTestingModule], - declarations: [CreateCommunityPageComponent, CommunityFormComponent], + declarations: [CreateCommunityPageComponent], providers: [ { provide: CommunityDataService, useValue: communityDataServiceStub }, { provide: RouteService, useValue: routeServiceStub }, - { provide: Router, useValue: routerStub } - ] + { provide: Router, useValue: routerStub }, + ], + schemas: [NO_ERRORS_SCHEMA] }).compileComponents(); })); @@ -66,10 +87,15 @@ describe('CreateCommunityPageComponent', () => { }); describe('onSubmit', () => { - const data = { - name: 'test' - }; - + let data; + beforeEach(() => { + data = Object.assign(new Community(), { + metadata: [{ + key: 'dc.title', + value: 'test' + }] + }); + }); it('should navigate when successful', () => { spyOn(router, 'navigate'); comp.onSubmit(data); @@ -79,7 +105,7 @@ describe('CreateCommunityPageComponent', () => { it('should not navigate on failure', () => { spyOn(router, 'navigate'); - spyOn(communityDataService, 'create').and.returnValue(Observable.of(new RemoteData(true, true, false, undefined, newCommunity))); + spyOn(communityDataService, 'create').and.returnValue(observableOf(new RemoteData(true, true, false, undefined, newCommunity))); comp.onSubmit(data); fixture.detectChanges(); expect(router.navigate).not.toHaveBeenCalled(); diff --git a/src/app/+community-page/create-community-page/create-community-page.component.ts b/src/app/+community-page/create-community-page/create-community-page.component.ts index 5373abfe22..8871d33547 100644 --- a/src/app/+community-page/create-community-page/create-community-page.component.ts +++ b/src/app/+community-page/create-community-page/create-community-page.component.ts @@ -5,7 +5,7 @@ import { Observable } from 'rxjs'; import { RouteService } from '../../shared/services/route.service'; import { Router } from '@angular/router'; import { RemoteData } from '../../core/data/remote-data'; -import { isNotEmpty } from '../../shared/empty.util'; +import { isNotEmpty, isNotUndefined } from '../../shared/empty.util'; import { DSpaceObject } from '../../core/shared/dspace-object.model'; import { map, take } from 'rxjs/operators'; import { getSucceededRemoteData } from '../../core/shared/operators'; @@ -42,8 +42,10 @@ export class CreateCommunityPageComponent implements OnInit { this.communityDataService.create(community, uuid) .pipe(getSucceededRemoteData()) .subscribe((communityRD: RemoteData) => { - const newUUID = communityRD.payload.uuid; - this.router.navigate(['/communities/' + newUUID]); + if (isNotUndefined(communityRD)) { + const newUUID = communityRD.payload.uuid; + this.router.navigate(['/communities/' + newUUID]); + } }); }); } diff --git a/src/app/+community-page/edit-community-page/edit-community-page.component.html b/src/app/+community-page/edit-community-page/edit-community-page.component.html index eb9f797b3d..1dc6442307 100644 --- a/src/app/+community-page/edit-community-page/edit-community-page.component.html +++ b/src/app/+community-page/edit-community-page/edit-community-page.component.html @@ -1,10 +1,7 @@
- - -

{{ 'community.edit.sub-head' | translate:{ parent: parent.name } }}

-
+
diff --git a/src/app/+community-page/edit-community-page/edit-community-page.component.spec.ts b/src/app/+community-page/edit-community-page/edit-community-page.component.spec.ts index 6c5eb5f591..84edd47e1d 100644 --- a/src/app/+community-page/edit-community-page/edit-community-page.component.spec.ts +++ b/src/app/+community-page/edit-community-page/edit-community-page.component.spec.ts @@ -1,65 +1,91 @@ -import { CreateCommunityPageComponent } from './create-community-page.component'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { CommunityDataService } from '../../core/data/community-data.service'; import { RouteService } from '../../shared/services/route.service'; -import { Router } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; import { TranslateModule } from '@ngx-translate/core'; -import { Observable } from 'rxjs/Observable'; +import { of as observableOf } from 'rxjs'; import { RemoteData } from '../../core/data/remote-data'; import { Community } from '../../core/shared/community.model'; -import { DSOSuccessResponse, ErrorResponse } from '../../core/cache/response-cache.models'; -import { BrowserModule } from '@angular/platform-browser'; import { SharedModule } from '../../shared/shared.module'; import { CommonModule } from '@angular/common'; -import { CommunityFormComponent } from '../community-form/community-form.component'; import { RouterTestingModule } from '@angular/router/testing'; -import { RequestError } from '../../core/data/request.models'; +import { NO_ERRORS_SCHEMA } from '@angular/core'; +import { EditCommunityPageComponent } from './edit-community-page.component'; +import { ActivatedRouteStub } from '../../shared/testing/active-router-stub'; -describe('CreateCommunityPageComponent', () => { - let comp: CreateCommunityPageComponent; - let fixture: ComponentFixture; +fdescribe('EditCommunityPageComponent', () => { + let comp: EditCommunityPageComponent; + let fixture: ComponentFixture; let communityDataService: CommunityDataService; let routeService: RouteService; let router: Router; - const community = Object.assign(new Community(), { - uuid: 'a20da287-e174-466a-9926-f66b9300d347', - name: 'test community' - }); + let community; + let newCommunity; + let communityDataServiceStub; + let routeServiceStub; + let routerStub; + let routeStub; - const newCommunity = Object.assign(new Community(), { - uuid: '1ff59938-a69a-4e62-b9a4-718569c55d48', - name: 'new community' - }); + function initializeVars() { + community = Object.assign(new Community(), { + uuid: 'a20da287-e174-466a-9926-f66b9300d347', + metadata: [{ + key: 'dc.title', + value: 'test community' + }] + }); - const communityDataServiceStub = { - findById: (uuid) => Observable.of(new RemoteData(false, false, true, null, Object.assign(new Community(), { - uuid: uuid, - name: community.name - }))), - create: (com, uuid?) => Observable.of(new RemoteData(false, false, true, undefined, newCommunity)) - }; - const routeServiceStub = { - getQueryParameterValue: (param) => Observable.of(community.uuid) - }; - const routerStub = { - navigate: (commands) => commands - }; + newCommunity = Object.assign(new Community(), { + uuid: '1ff59938-a69a-4e62-b9a4-718569c55d48', + metadata: [{ + key: 'dc.title', + value: 'new community' + }] + }); + + communityDataServiceStub = { + findById: (uuid) => observableOf(new RemoteData(false, false, true, null, Object.assign(new Community(), { + uuid: uuid, + metadata: [{ + key: 'dc.title', + value: community.name + }] + }))), + update: (com, uuid?) => observableOf(new RemoteData(false, false, true, undefined, newCommunity)) + + }; + + routeServiceStub = { + getQueryParameterValue: (param) => observableOf(community.uuid) + }; + routerStub = { + navigate: (commands) => commands + }; + + routeStub = { + data: observableOf(community) + }; + + } beforeEach(async(() => { + initializeVars(); TestBed.configureTestingModule({ imports: [TranslateModule.forRoot(), SharedModule, CommonModule, RouterTestingModule], - declarations: [CreateCommunityPageComponent, CommunityFormComponent], + declarations: [EditCommunityPageComponent], providers: [ { provide: CommunityDataService, useValue: communityDataServiceStub }, { provide: RouteService, useValue: routeServiceStub }, - { provide: Router, useValue: routerStub } - ] + { provide: Router, useValue: routerStub }, + { provide: ActivatedRoute, useValue: routeStub }, + ], + schemas: [NO_ERRORS_SCHEMA] }).compileComponents(); })); beforeEach(() => { - fixture = TestBed.createComponent(CreateCommunityPageComponent); + fixture = TestBed.createComponent(EditCommunityPageComponent); comp = fixture.componentInstance; fixture.detectChanges(); communityDataService = (comp as any).communityDataService; @@ -68,10 +94,15 @@ describe('CreateCommunityPageComponent', () => { }); describe('onSubmit', () => { - const data = { - name: 'test' - }; - + let data; + beforeEach(() => { + data = Object.assign(new Community(), { + metadata: [{ + key: 'dc.title', + value: 'test' + }] + }); + }); it('should navigate when successful', () => { spyOn(router, 'navigate'); comp.onSubmit(data); @@ -81,7 +112,7 @@ describe('CreateCommunityPageComponent', () => { it('should not navigate on failure', () => { spyOn(router, 'navigate'); - spyOn(communityDataService, 'create').and.returnValue(Observable.of(new RemoteData(true, true, false, undefined, newCommunity))); + spyOn(communityDataService, 'update').and.returnValue(observableOf(new RemoteData(true, true, false, undefined, newCommunity))); comp.onSubmit(data); fixture.detectChanges(); expect(router.navigate).not.toHaveBeenCalled(); diff --git a/src/app/+community-page/edit-community-page/edit-community-page.component.ts b/src/app/+community-page/edit-community-page/edit-community-page.component.ts index 58805af80a..1528c9e8d5 100644 --- a/src/app/+community-page/edit-community-page/edit-community-page.component.ts +++ b/src/app/+community-page/edit-community-page/edit-community-page.component.ts @@ -5,11 +5,8 @@ import { Observable } from 'rxjs'; import { RouteService } from '../../shared/services/route.service'; import { ActivatedRoute, Router } from '@angular/router'; import { RemoteData } from '../../core/data/remote-data'; -import { isNotEmpty } from '../../shared/empty.util'; -import { DSpaceObject } from '../../core/shared/dspace-object.model'; -import { first, map, take, tap } from 'rxjs/operators'; -import { ResourceType } from '../../core/shared/resource-type'; -import { NormalizedCommunity } from '../../core/cache/models/normalized-community.model'; +import { isNotUndefined } from '../../shared/empty.util'; +import { first, map } from 'rxjs/operators'; import { getSucceededRemoteData } from '../../core/shared/operators'; @Component({ @@ -39,8 +36,10 @@ export class EditCommunityPageComponent { this.communityDataService.update(community) .pipe(getSucceededRemoteData()) .subscribe((communityRD: RemoteData) => { - const newUUID = communityRD.payload.uuid; - this.router.navigate(['/communities/' + newUUID]); + if (isNotUndefined(communityRD)) { + const newUUID = communityRD.payload.uuid; + this.router.navigate(['/communities/' + newUUID]); + } }); } } diff --git a/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.spec.ts b/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.spec.ts index 0c985e37f9..ace748c7de 100644 --- a/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.spec.ts +++ b/src/app/+community-page/sub-community-list/community-page-sub-community-list.component.spec.ts @@ -17,7 +17,6 @@ describe('SubCommunityList Component', () => { let fixture: ComponentFixture; const subcommunities = [Object.assign(new Community(), { - name: 'SubCommunity 1', id: '123456789-1', metadata: [ { @@ -27,7 +26,6 @@ describe('SubCommunityList Component', () => { }] }), Object.assign(new Community(), { - name: 'SubCommunity 2', id: '123456789-2', metadata: [ { diff --git a/src/app/+search-page/search-results/search-results.component.spec.ts b/src/app/+search-page/search-results/search-results.component.spec.ts index 54463d916d..b7ac11553a 100644 --- a/src/app/+search-page/search-results/search-results.component.spec.ts +++ b/src/app/+search-page/search-results/search-results.component.spec.ts @@ -111,7 +111,6 @@ export const objects = [ id: '7669c72a-3f2a-451f-a3b9-9210e7a4c02f', uuid: '7669c72a-3f2a-451f-a3b9-9210e7a4c02f', type: ResourceType.Community, - name: 'OR2017 - Demonstration', metadata: [ { key: 'dc.description', @@ -161,7 +160,6 @@ export const objects = [ id: '9076bd16-e69a-48d6-9e41-0238cb40d863', uuid: '9076bd16-e69a-48d6-9e41-0238cb40d863', type: ResourceType.Community, - name: 'Sample Community', metadata: [ { key: 'dc.description', diff --git a/src/app/core/config/config.service.spec.ts b/src/app/core/config/config.service.spec.ts index 8e9f7db27a..44cfdee358 100644 --- a/src/app/core/config/config.service.spec.ts +++ b/src/app/core/config/config.service.spec.ts @@ -36,7 +36,6 @@ describe('ConfigService', () => { const scopedEndpoint = `${serviceEndpoint}/${scopeName}`; const searchEndpoint = `${serviceEndpoint}/${BROWSE}?uuid=${scopeID}`; - function initTestService(): TestService { return new TestService( requestService, diff --git a/src/app/core/data/collection-data.service.ts b/src/app/core/data/collection-data.service.ts index ef294c1296..b08b1005b7 100644 --- a/src/app/core/data/collection-data.service.ts +++ b/src/app/core/data/collection-data.service.ts @@ -9,7 +9,6 @@ import { ComColDataService } from './comcol-data.service'; import { CommunityDataService } from './community-data.service'; import { RequestService } from './request.service'; import { HALEndpointService } from '../shared/hal-endpoint.service'; -import { AuthService } from '../auth/auth.service'; import { NotificationsService } from '../../shared/notifications/notifications.service'; import { HttpClient } from '@angular/common/http'; import { DataBuildService } from '../cache/builders/data-build.service'; @@ -27,7 +26,6 @@ export class CollectionDataService extends ComColDataService { protected cds: CommunityDataService, protected objectCache: ObjectCacheService, protected halService: HALEndpointService, - protected authService: AuthService, protected notificationsService: NotificationsService, protected http: HttpClient, protected comparator: DSOUpdateComparator, @@ -56,7 +53,6 @@ describe('ComColDataService', () => { let requestService: RequestService; let cds: CommunityDataService; let objectCache: ObjectCacheService; - let authService: AuthService; let halService: any = {}; const rdbService = {} as RemoteDataBuildService; @@ -106,14 +102,6 @@ describe('ComColDataService', () => { }); } - function initMockAuthService(): AuthService { - return jasmine.createSpyObj('authService', { - buildAuthHeader: cold('c-', { - c: authHeader - }) - }); - } - function initTestService(): TestService { return new TestService( requestService, @@ -124,7 +112,6 @@ describe('ComColDataService', () => { cds, objectCache, halService, - authService, notificationsService, http, comparator, @@ -137,7 +124,6 @@ describe('ComColDataService', () => { requestService = getMockRequestService(); objectCache = initMockObjectCacheService(); halService = mockHalService; - authService = initMockAuthService(); service = initTestService(); }); diff --git a/src/app/core/data/community-data.service.ts b/src/app/core/data/community-data.service.ts index 40d433a245..63fbe3a21a 100644 --- a/src/app/core/data/community-data.service.ts +++ b/src/app/core/data/community-data.service.ts @@ -10,7 +10,6 @@ import { Community } from '../shared/community.model'; import { ComColDataService } from './comcol-data.service'; import { RequestService } from './request.service'; import { HALEndpointService } from '../shared/hal-endpoint.service'; -import { AuthService } from '../auth/auth.service'; import { FindAllOptions, FindAllRequest } from './request.models'; import { RemoteData } from './remote-data'; import { hasValue, isNotEmpty } from '../../shared/empty.util'; @@ -34,7 +33,6 @@ export class CommunityDataService extends ComColDataService, protected objectCache: ObjectCacheService, protected halService: HALEndpointService, - protected authService: AuthService, protected notificationsService: NotificationsService, protected http: HttpClient, protected comparator: DSOUpdateComparator diff --git a/src/app/core/data/config-response-parsing.service.spec.ts b/src/app/core/data/config-response-parsing.service.spec.ts index caf8ef4a19..a33c5cf5b5 100644 --- a/src/app/core/data/config-response-parsing.service.spec.ts +++ b/src/app/core/data/config-response-parsing.service.spec.ts @@ -177,7 +177,7 @@ describe('ConfigResponseParsingService', () => { 'https://rest.api/config/submissionsections/traditionalpagetwo', 'https://rest.api/config/submissionsections/upload', 'https://rest.api/config/submissionsections/license' - ], 'https://rest.api/config/submissiondefinitions/traditional/sections') + ]) }); it('should return a ConfigSuccessResponse if data contains a valid config endpoint response', () => { diff --git a/src/app/core/data/data.service.spec.ts b/src/app/core/data/data.service.spec.ts index 7da709abd5..ad6fb5f096 100644 --- a/src/app/core/data/data.service.spec.ts +++ b/src/app/core/data/data.service.spec.ts @@ -12,6 +12,11 @@ import { of as observableOf } from 'rxjs'; import { ObjectCacheService } from '../cache/object-cache.service'; import { Operation } from '../../../../node_modules/fast-json-patch'; import { DSpaceObject } from '../shared/dspace-object.model'; +import { AuthService } from '../auth/auth.service'; +import { UpdateComparator } from './update-comparator'; +import { HttpClient } from '@angular/common/http'; +import { DataBuildService } from '../cache/builders/data-build.service'; +import { NotificationsService } from '../../shared/notifications/notifications.service'; const endpoint = 'https://rest.api/core'; @@ -23,10 +28,14 @@ class TestService extends DataService { constructor( protected requestService: RequestService, protected rdbService: RemoteDataBuildService, + protected dataBuildService: DataBuildService, protected store: Store, protected linkPath: string, protected halService: HALEndpointService, - protected objectCache: ObjectCacheService + protected objectCache: ObjectCacheService, + protected notificationsService: NotificationsService, + protected http: HttpClient, + protected comparator: UpdateComparator ) { super(); } @@ -42,6 +51,10 @@ describe('DataService', () => { const requestService = {} as RequestService; const halService = {} as HALEndpointService; const rdbService = {} as RemoteDataBuildService; + const notificationsService = {} as NotificationsService; + const http = {} as HttpClient; + const comparator = {} as any; + const dataBuildService = {} as DataBuildService; const objectCache = { addPatch: () => { /* empty */ @@ -56,13 +69,16 @@ describe('DataService', () => { return new TestService( requestService, rdbService, + dataBuildService, store, endpoint, halService, - objectCache + objectCache, + notificationsService, + http, + comparator, ); } - service = initTestService(); describe('getFindAllHref', () => { @@ -134,7 +150,7 @@ describe('DataService', () => { let selfLink; beforeEach(() => { - operations = [{ op: 'replace', path: '/name', value: 'random string' } as Operation]; + operations = [{ op: 'replace', path: '/metadata/dc.title', value: 'random string' } as Operation]; selfLink = 'https://rest.api/endpoint/1698f1d3-be98-4c51-9fd8-6bfedcbd59b7'; spyOn(objectCache, 'addPatch'); }); @@ -153,16 +169,16 @@ describe('DataService', () => { const name1 = 'random string'; const name2 = 'another random string'; beforeEach(() => { - operations = [{ op: 'replace', path: '/name', value: name2 } as Operation]; + operations = [{ op: 'replace', path: '/metadata/dc.title', value: name2 } as Operation]; selfLink = 'https://rest.api/endpoint/1698f1d3-be98-4c51-9fd8-6bfedcbd59b7'; dso = new DSpaceObject(); dso.self = selfLink; - dso.name = name1; + dso.metadata = [{ key: 'dc.title', value: name1 }]; dso2 = new DSpaceObject(); dso2.self = selfLink; - dso2.name = name2; + dso2.metadata = [{ key: 'dc.title', value: name2 }]; spyOn(objectCache, 'getBySelfLink').and.returnValue(dso); spyOn(objectCache, 'addPatch'); diff --git a/src/app/core/data/data.service.ts b/src/app/core/data/data.service.ts index 85d6579176..47be86c296 100644 --- a/src/app/core/data/data.service.ts +++ b/src/app/core/data/data.service.ts @@ -29,7 +29,6 @@ import { NormalizedObject } from '../cache/models/normalized-object.model'; import { compare, Operation } from 'fast-json-patch'; import { ObjectCacheService } from '../cache/object-cache.service'; import { DSpaceObject } from '../shared/dspace-object.model'; -import { AuthService } from '../auth/auth.service'; import { NotificationsService } from '../../shared/notifications/notifications.service'; import { HttpClient } from '@angular/common/http'; import { @@ -53,7 +52,6 @@ export abstract class DataService; @@ -155,7 +153,7 @@ export abstract class DataService parentUUID ? `${endpoint}?parent=${parentUUID}` : endpoint) + map((endpoint: string) => parentUUID ? `${endpoint}?parentCommunity=${parentUUID}` : endpoint) ); const normalizedObject: TNormalized = this.dataBuildService.normalize(dso); diff --git a/src/app/core/data/dspace-object-data.service.spec.ts b/src/app/core/data/dspace-object-data.service.spec.ts index cdddcb7ce6..2d478b8f73 100644 --- a/src/app/core/data/dspace-object-data.service.spec.ts +++ b/src/app/core/data/dspace-object-data.service.spec.ts @@ -7,6 +7,9 @@ import { FindByIDRequest } from './request.models'; import { RequestService } from './request.service'; import { DSpaceObjectDataService } from './dspace-object-data.service'; import { ObjectCacheService } from '../cache/object-cache.service'; +import { NotificationsService } from '../../shared/notifications/notifications.service'; +import { HttpClient } from '@angular/common/http'; +import { DataBuildService } from '../cache/builders/data-build.service'; describe('DSpaceObjectDataService', () => { let scheduler: TestScheduler; @@ -40,12 +43,20 @@ describe('DSpaceObjectDataService', () => { }) }); objectCache = {} as ObjectCacheService; + const notificationsService = {} as NotificationsService; + const http = {} as HttpClient; + const comparator = {} as any; + const dataBuildService = {} as DataBuildService; service = new DSpaceObjectDataService( requestService, rdbService, + dataBuildService, + objectCache, halService, - objectCache + notificationsService, + http, + comparator ) }); diff --git a/src/app/core/data/dspace-object-data.service.ts b/src/app/core/data/dspace-object-data.service.ts index f1d0f21762..9a069c4d61 100644 --- a/src/app/core/data/dspace-object-data.service.ts +++ b/src/app/core/data/dspace-object-data.service.ts @@ -11,7 +11,6 @@ import { RemoteData } from './remote-data'; import { RequestService } from './request.service'; import { FindAllOptions } from './request.models'; import { ObjectCacheService } from '../cache/object-cache.service'; -import { AuthService } from '../auth/auth.service'; import { NotificationsService } from '../../shared/notifications/notifications.service'; import { HttpClient } from '@angular/common/http'; import { DataBuildService } from '../cache/builders/data-build.service'; @@ -28,7 +27,6 @@ class DataServiceImpl extends DataService protected store: Store, protected objectCache: ObjectCacheService, protected halService: HALEndpointService, - protected authService: AuthService, protected notificationsService: NotificationsService, protected http: HttpClient, protected comparator: DSOUpdateComparator) { @@ -55,11 +53,10 @@ export class DSpaceObjectDataService { protected dataBuildService: DataBuildService, protected objectCache: ObjectCacheService, protected halService: HALEndpointService, - protected authService: AuthService, protected notificationsService: NotificationsService, protected http: HttpClient, protected comparator: DSOUpdateComparator) { - this.dataService = new DataServiceImpl(requestService, rdbService, dataBuildService, null, objectCache, halService, authService, notificationsService, http, comparator); + this.dataService = new DataServiceImpl(requestService, rdbService, dataBuildService, null, objectCache, halService, notificationsService, http, comparator); } findById(uuid: string): Observable> { diff --git a/src/app/core/data/item-data.service.spec.ts b/src/app/core/data/item-data.service.spec.ts index bb67fc8412..1be361cb9d 100644 --- a/src/app/core/data/item-data.service.spec.ts +++ b/src/app/core/data/item-data.service.spec.ts @@ -9,6 +9,9 @@ import { RequestService } from './request.service'; import { HALEndpointService } from '../shared/hal-endpoint.service'; import { ObjectCacheService } from '../cache/object-cache.service'; import { FindAllOptions } from './request.models'; +import { NotificationsService } from '../../shared/notifications/notifications.service'; +import { HttpClient } from '@angular/common/http'; +import { DataBuildService } from '../cache/builders/data-build.service'; describe('ItemDataService', () => { let scheduler: TestScheduler; @@ -34,6 +37,10 @@ describe('ItemDataService', () => { const scopedEndpoint = `${itemBrowseEndpoint}?scope=${scopeID}`; const serviceEndpoint = `https://rest.api/core/items`; const browseError = new Error('getBrowseURL failed'); + const notificationsService = {} as NotificationsService; + const http = {} as HttpClient; + const comparator = {} as any; + const dataBuildService = {} as DataBuildService; function initMockBrowseService(isSuccessful: boolean) { const obs = isSuccessful ? @@ -48,10 +55,14 @@ describe('ItemDataService', () => { return new ItemDataService( requestService, rdbService, + dataBuildService, store, bs, + objectCache, halEndpointService, - objectCache + notificationsService, + http, + comparator ); } diff --git a/src/app/core/data/item-data.service.ts b/src/app/core/data/item-data.service.ts index 411daa9b35..2fb2c017dc 100644 --- a/src/app/core/data/item-data.service.ts +++ b/src/app/core/data/item-data.service.ts @@ -17,7 +17,6 @@ import { HALEndpointService } from '../shared/hal-endpoint.service'; import { FindAllOptions } from './request.models'; import { ObjectCacheService } from '../cache/object-cache.service'; import { NotificationsService } from '../../shared/notifications/notifications.service'; -import { AuthService } from '../auth/auth.service'; import { HttpClient } from '@angular/common/http'; import { DataBuildService } from '../cache/builders/data-build.service'; import { DSOUpdateComparator } from './dso-update-comparator'; @@ -34,7 +33,6 @@ export class ItemDataService extends DataService { private bs: BrowseService, protected objectCache: ObjectCacheService, protected halService: HALEndpointService, - protected authService: AuthService, protected notificationsService: NotificationsService, protected http: HttpClient, protected comparator: DSOUpdateComparator) { diff --git a/src/app/core/integration/integration.service.spec.ts b/src/app/core/integration/integration.service.spec.ts index 158f4b0680..152d7ab165 100644 --- a/src/app/core/integration/integration.service.spec.ts +++ b/src/app/core/integration/integration.service.spec.ts @@ -40,7 +40,7 @@ describe('IntegrationService', () => { findOptions = new IntegrationSearchOptions(uuid, name, metadata); - function initTestService(): TestService { + function initTestService(): TestService { return new TestService( requestService, halService diff --git a/src/app/shared/form/form.component.spec.ts b/src/app/shared/form/form.component.spec.ts index 06676d191e..38e95b5c49 100644 --- a/src/app/shared/form/form.component.spec.ts +++ b/src/app/shared/form/form.component.spec.ts @@ -350,13 +350,13 @@ describe('FormComponent test suite', () => { const control = formComp.formGroup.get(['dc_title']); control.setValue('Test Title'); formState.testForm.valid = true; - spyOn(formComp.submit, 'emit'); + spyOn(formComp.submitForm, 'emit'); form.next(formState.testForm); formFixture.detectChanges(); formComp.onSubmit(); - expect(formComp.submit.emit).toHaveBeenCalled(); + expect(formComp.submitForm.emit).toHaveBeenCalled(); }); it('should not emit submit Event on form submit whether the form is not valid', () => { diff --git a/src/app/shared/mocks/mock-item.ts b/src/app/shared/mocks/mock-item.ts index f3db69a0f2..2e5c764ee2 100644 --- a/src/app/shared/mocks/mock-item.ts +++ b/src/app/shared/mocks/mock-item.ts @@ -51,7 +51,6 @@ export const MockItem: Item = Object.assign(new Item(), { id: 'cf9b0c8e-a1eb-4b65-afd0-567366448713', uuid: 'cf9b0c8e-a1eb-4b65-afd0-567366448713', type: 'bitstream', - name: 'test_word.docx', metadata: [ { key: 'dc.title', @@ -86,7 +85,6 @@ export const MockItem: Item = Object.assign(new Item(), { id: '99b00f3c-1cc6-4689-8158-91965bee6b28', uuid: '99b00f3c-1cc6-4689-8158-91965bee6b28', type: 'bitstream', - name: 'test_pdf.pdf', metadata: [ { key: 'dc.title', @@ -102,7 +100,6 @@ export const MockItem: Item = Object.assign(new Item(), { id: '0ec7ff22-f211-40ab-a69e-c819b0b1f357', uuid: '0ec7ff22-f211-40ab-a69e-c819b0b1f357', type: 'item', - name: 'Test PowerPoint Document', metadata: [ { key: 'dc.creator', diff --git a/src/app/shared/search-form/search-form.component.spec.ts b/src/app/shared/search-form/search-form.component.spec.ts index 30f5801cc2..004d0c5b21 100644 --- a/src/app/shared/search-form/search-form.component.spec.ts +++ b/src/app/shared/search-form/search-form.component.spec.ts @@ -121,7 +121,6 @@ export const objects: DSpaceObject[] = [ id: '7669c72a-3f2a-451f-a3b9-9210e7a4c02f', uuid: '7669c72a-3f2a-451f-a3b9-9210e7a4c02f', type: ResourceType.Community, - name: 'OR2017 - Demonstration', metadata: [ { key: 'dc.description', @@ -171,7 +170,6 @@ export const objects: DSpaceObject[] = [ id: '9076bd16-e69a-48d6-9e41-0238cb40d863', uuid: '9076bd16-e69a-48d6-9e41-0238cb40d863', type: ResourceType.Community, - name: 'Sample Community', metadata: [ { key: 'dc.description', diff --git a/src/app/shared/testing/eperson-mock.ts b/src/app/shared/testing/eperson-mock.ts index f163a490b9..ef27f4983d 100644 --- a/src/app/shared/testing/eperson-mock.ts +++ b/src/app/shared/testing/eperson-mock.ts @@ -13,8 +13,12 @@ export const EPersonMock: EPerson = Object.assign(new EPerson(),{ id: 'testid', uuid: 'testid', type: 'eperson', - name: 'User Test', metadata: [ + { + key: 'dc.title', + language: null, + value: 'User Test' + }, { key: 'eperson.firstname', language: null,