small fixes + test fix

This commit is contained in:
lotte
2019-11-28 15:10:48 +01:00
parent f72343bd8e
commit 23cbc98208
14 changed files with 178 additions and 113 deletions

View File

@@ -7,12 +7,11 @@
(submitSuggestion)="selectCustom($event)"></ds-org-unit-input-suggestions> (submitSuggestion)="selectCustom($event)"></ds-org-unit-input-suggestions>
<span class="text-muted"> <span class="text-muted">
<span *ngIf="dso.allMetadata('organization.address.addressLocality').length > 0" <span *ngIf="dso.allMetadata('organization.address.addressLocality').length > 0"
class="item-list-job-title"> class="item-list-address-locality">
<span [innerHTML]="firstMetadataValue(['organization.address.addressLocality'])"><span [innerHTML]="firstMetadataValue(['organization.address.addressLocality'])"></span></span> <span [innerHTML]="firstMetadataValue(['organization.address.addressLocality'])"><span [innerHTML]="firstMetadataValue(['organization.address.addressLocality'])"></span></span><span *ngIf="dso.allMetadata('organization.address.addressCountry').length > 0">, </span>
<span *ngIf="dso.allMetadata('organization.address.addressCountry').length > 0">, </span>
</span> </span>
<span *ngIf="dso.allMetadata('organization.address.addressCountry').length > 0" <span *ngIf="dso.allMetadata('organization.address.addressCountry').length > 0"
class="item-list-job-title"> class="item-list-address-country">
<span [innerHTML]="firstMetadataValue(['organization.address.addressCountry'])"><span [innerHTML]="firstMetadataValue(['organization.address.addressCountry'])"></span></span> <span [innerHTML]="firstMetadataValue(['organization.address.addressCountry'])"><span [innerHTML]="firstMetadataValue(['organization.address.addressCountry'])"></span></span>
</span> </span>
</span> </span>

View File

@@ -39,10 +39,16 @@ function init() {
value: 'This is just another title' value: 'This is just another title'
} }
], ],
'person.jobTitle': [ 'organization.address.addressLocality': [
{ {
language: 'en_US', language: 'en_US',
value: 'Developer' value: 'Europe'
}
],
'organization.address.addressCountry': [
{
language: 'en_US',
value: 'Belgium'
} }
] ]
} }
@@ -70,7 +76,7 @@ function init() {
}; };
} }
describe('PersonSearchResultListElementSubmissionComponent', () => { describe('OrgUnitSearchResultListSubmissionElementComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
init(); init();
TestBed.configureTestingModule({ TestBed.configureTestingModule({
@@ -83,7 +89,7 @@ describe('PersonSearchResultListElementSubmissionComponent', () => {
{ provide: NgbModal, useValue: {} }, { provide: NgbModal, useValue: {} },
{ provide: ItemDataService, useValue: {} }, { provide: ItemDataService, useValue: {} },
{ provide: SelectableListService, useValue: {} }, { provide: SelectableListService, useValue: {} },
{ provide: Store, useValue: {}} { provide: Store, useValue: {} }
], ],
schemas: [NO_ERRORS_SCHEMA] schemas: [NO_ERRORS_SCHEMA]
@@ -98,26 +104,50 @@ describe('PersonSearchResultListElementSubmissionComponent', () => {
})); }));
describe('When the item has a job title', () => { describe('When the item has a address locality span', () => {
beforeEach(() => { beforeEach(() => {
personListElementComponent.object = mockItemWithMetadata; personListElementComponent.object = mockItemWithMetadata;
fixture.detectChanges(); fixture.detectChanges();
}); });
it('should show the job title span', () => { it('should show the address locality span', () => {
const jobTitleField = fixture.debugElement.query(By.css('span.item-list-job-title')); const jobTitleField = fixture.debugElement.query(By.css('span.item-list-address-locality'));
expect(jobTitleField).not.toBeNull(); expect(jobTitleField).not.toBeNull();
}); });
}); });
describe('When the item has no job title', () => { describe('When the item has no address locality', () => {
beforeEach(() => { beforeEach(() => {
personListElementComponent.object = mockItemWithoutMetadata; personListElementComponent.object = mockItemWithoutMetadata;
fixture.detectChanges(); fixture.detectChanges();
}); });
it('should not show the job title span', () => { it('should not show the address locality span', () => {
const jobTitleField = fixture.debugElement.query(By.css('span.item-list-job-title')); const jobTitleField = fixture.debugElement.query(By.css('span.item-list-address-locality'));
expect(jobTitleField).toBeNull();
});
});
describe('When the item has a address country span', () => {
beforeEach(() => {
personListElementComponent.object = mockItemWithMetadata;
fixture.detectChanges();
});
it('should show the address country span', () => {
const jobTitleField = fixture.debugElement.query(By.css('span.item-list-address-country'));
expect(jobTitleField).not.toBeNull();
});
});
describe('When the item has no address country', () => {
beforeEach(() => {
personListElementComponent.object = mockItemWithoutMetadata;
fixture.detectChanges();
});
it('should not show the address country span', () => {
const jobTitleField = fixture.debugElement.query(By.css('span.item-list-address-country'));
expect(jobTitleField).toBeNull(); expect(jobTitleField).toBeNull();
}); });
}); });

View File

@@ -16,7 +16,7 @@ import { ItemDataService } from '../../../../../core/data/item-data.service';
import { SelectableListService } from '../../../../../shared/object-list/selectable-list/selectable-list.service'; import { SelectableListService } from '../../../../../shared/object-list/selectable-list/selectable-list.service';
import { NameVariantModalComponent } from '../../name-variant-modal/name-variant-modal.component'; import { NameVariantModalComponent } from '../../name-variant-modal/name-variant-modal.component';
@listableObjectComponent('OrgUnitSearchResult', ViewMode.ListElement, Context.Workspace) @listableObjectComponent('OrgUnitSearchResult', ViewMode.ListElement, Context.SubmissionModal)
@Component({ @Component({
selector: 'ds-person-search-result-list-submission-element', selector: 'ds-person-search-result-list-submission-element',
styleUrls: ['./org-unit-search-result-list-submission-element.component.scss'], styleUrls: ['./org-unit-search-result-list-submission-element.component.scss'],

View File

@@ -105,7 +105,7 @@ describe('PersonSearchResultListElementSubmissionComponent', () => {
}); });
it('should show the job title span', () => { it('should show the job title span', () => {
const jobTitleField = fixture.debugElement.query(By.css('span.item-list-job-title')); const jobTitleField = fixture.debugElement.query(By.css('span.item-list-job-title'));
expect(jobTitleField).not.toBeNull(); expect(jobTitleField).not.toBeNull();
}); });
}); });

View File

@@ -16,7 +16,7 @@ import { MetadataValue } from '../../../../../core/shared/metadata.models';
import { ItemDataService } from '../../../../../core/data/item-data.service'; import { ItemDataService } from '../../../../../core/data/item-data.service';
import { SelectableListService } from '../../../../../shared/object-list/selectable-list/selectable-list.service'; import { SelectableListService } from '../../../../../shared/object-list/selectable-list/selectable-list.service';
@listableObjectComponent('PersonSearchResult', ViewMode.ListElement, Context.Workspace) @listableObjectComponent('PersonSearchResult', ViewMode.ListElement, Context.SubmissionModal)
@Component({ @Component({
selector: 'ds-person-search-result-list-submission-element', selector: 'ds-person-search-result-list-submission-element',
styleUrls: ['./person-search-result-list-submission-element.component.scss'], styleUrls: ['./person-search-result-list-submission-element.component.scss'],

View File

@@ -298,7 +298,7 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
} }
openLookup() { openLookup() {
this.modalRef = this.modalService.open(DsDynamicLookupRelationModalComponent, { size: 'lg', centered: true }); this.modalRef = this.modalService.open(DsDynamicLookupRelationModalComponent, { size: 'lg'});
const modalComp = this.modalRef.componentInstance; const modalComp = this.modalRef.componentInstance;
modalComp.repeatable = this.model.repeatable; modalComp.repeatable = this.model.repeatable;
modalComp.listId = this.listId; modalComp.listId = this.listId;

View File

@@ -64,7 +64,7 @@ export class DsDynamicLookupRelationModalComponent implements OnInit, OnDestroy
selection.map((s: SearchResult<Item>) => this.addNameVariantSubscription(s)) selection.map((s: SearchResult<Item>) => this.addNameVariantSubscription(s))
); );
if (this.relationshipOptions.nameVariants) { if (this.relationshipOptions.nameVariants) {
this.context = Context.Workspace; this.context = Context.SubmissionModal;
} }
// this.setExistingNameVariants(); // this.setExistingNameVariants();

View File

@@ -14,6 +14,7 @@ import { cold, hot } from 'jasmine-marbles';
import * as operators from 'rxjs/operators'; import * as operators from 'rxjs/operators';
import { last } from 'rxjs/operators'; import { last } from 'rxjs/operators';
import { ItemType } from '../../../../../core/shared/item-relationships/item-type.model'; import { ItemType } from '../../../../../core/shared/item-relationships/item-type.model';
import { RestResponse } from '../../../../../core/cache/response.models';
describe('RelationshipEffects', () => { describe('RelationshipEffects', () => {
let relationEffects: RelationshipEffects; let relationEffects: RelationshipEffects;
@@ -71,19 +72,18 @@ describe('RelationshipEffects', () => {
relationship = Object.assign(new Relationship(), relationship = Object.assign(new Relationship(),
{ {
uuid: relationshipID, uuid: relationshipID,
id: relationshipID,
leftItem: createSuccessfulRemoteDataObject$(leftItem), leftItem: createSuccessfulRemoteDataObject$(leftItem),
rightItem: createSuccessfulRemoteDataObject$(rightItem), rightItem: createSuccessfulRemoteDataObject$(rightItem),
relationshipType: createSuccessfulRemoteDataObject$(relationshipType) relationshipType: createSuccessfulRemoteDataObject$(relationshipType)
}); });
mockRelationshipService = { mockRelationshipService = {
getRelationshipByItemsAndLabel: getRelationshipByItemsAndLabel:
() => observableOf(relationship), () => observableOf(relationship),
deleteRelationship: () => { deleteRelationship: () => observableOf(new RestResponse(true, 200, 'OK')),
/* Do nothing */ addRelationship: () => observableOf(new RestResponse(true, 200, 'OK'))
},
addRelationship: () => {
/* Do nothing */
}
}; };
mockRelationshipTypeService = { mockRelationshipTypeService = {
getRelationshipTypeByLabelAndTypes: getRelationshipTypeByLabelAndTypes:

View File

@@ -381,6 +381,7 @@ describe('FormComponent test suite', () => {
}); });
describe('', () => { describe('', () => {
init();
beforeEach(() => { beforeEach(() => {
formFixture = TestBed.createComponent(FormComponent); formFixture = TestBed.createComponent(FormComponent);
store = TestBed.get(Store); store = TestBed.get(Store);

View File

@@ -281,6 +281,7 @@ describe('InputSuggestionsComponent', () => {
expect(autocomplete.nativeElement.classList).not.toContain('show'); expect(autocomplete.nativeElement.classList).not.toContain('show');
}); });
}); });
describe('when the variable \'show\' is set to true and close() is called', () => { describe('when the variable \'show\' is set to true and close() is called', () => {
beforeEach(() => { beforeEach(() => {
comp.show.next(true); comp.show.next(true);
@@ -304,5 +305,4 @@ describe('InputSuggestionsComponent', () => {
expect(comp.onClickSuggestion).toHaveBeenCalledWith(suggestions[clickedIndex].value); expect(comp.onClickSuggestion).toHaveBeenCalledWith(suggestions[clickedIndex].value);
}); });
}); });
}); });

View File

@@ -10,15 +10,23 @@ describe('LinkMenuItemComponent', () => {
let component: LinkMenuItemComponent; let component: LinkMenuItemComponent;
let fixture: ComponentFixture<LinkMenuItemComponent>; let fixture: ComponentFixture<LinkMenuItemComponent>;
let debugElement: DebugElement; let debugElement: DebugElement;
const text = 'HELLO'; let text;
const link = 'http://google.com'; let link;
const nameSpace = 'dspace.com/'; let nameSpace;
const globalConfig = { let globalConfig;
ui: {
nameSpace: nameSpace function init() {
} text = 'HELLO';
} as any; link = 'http://google.com';
nameSpace = 'dspace.com/';
globalConfig = {
ui: {
nameSpace: nameSpace
}
} as any;
}
beforeEach(async(() => { beforeEach(async(() => {
init();
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [TranslateModule.forRoot()], imports: [TranslateModule.forRoot()],
declarations: [LinkMenuItemComponent, RouterLinkDirectiveStub], declarations: [LinkMenuItemComponent, RouterLinkDirectiveStub],

View File

@@ -13,13 +13,14 @@ describe('MenuSectionComponent', () => {
let comp: MenuSectionComponent; let comp: MenuSectionComponent;
let fixture: ComponentFixture<MenuSectionComponent>; let fixture: ComponentFixture<MenuSectionComponent>;
let menuService: MenuService; let menuService: MenuService;
const dummySection = { let dummySection;
id: 'section',
visible: true,
active: false
} as any;
beforeEach(async(() => { beforeEach(async(() => {
dummySection = {
id: 'section',
visible: true,
active: false
} as any;
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [TranslateModule.forRoot(), NoopAnimationsModule], imports: [TranslateModule.forRoot(), NoopAnimationsModule],
declarations: [MenuSectionComponent], declarations: [MenuSectionComponent],

View File

@@ -16,43 +16,54 @@ import {
describe('MenuService', () => { describe('MenuService', () => {
let service: MenuService; let service: MenuService;
let selectSpy; let selectSpy;
const store = Object.assign(observableOf({}), { let store;
dispatch: () => {/***/ let fakeMenu;
} let visibleSection1;
}) as any; let visibleSection2;
const fakeMenu = { let hiddenSection3;
id: MenuID.ADMIN, let subSection4;
collapsed: true, let topSections;
visible: false,
previewCollapsed: true
} as any;
const visibleSection1 = {
id: 'section',
visible: true,
active: false
};
const visibleSection2 = {
id: 'section_2',
visible: true
};
const hiddenSection3 = {
id: 'section_3',
visible: false
};
const subSection4 = {
id: 'section_4',
visible: true,
parentID: 'section1'
};
const topSections = { function init() {
section: visibleSection1, store = Object.assign(observableOf({}), {
section_2: visibleSection2, dispatch: () => {/***/
section_3: hiddenSection3, }
section_4: subSection4 }) as any;
}; fakeMenu = {
id: MenuID.ADMIN,
collapsed: true,
visible: false,
previewCollapsed: true
} as any;
visibleSection1 = {
id: 'section',
visible: true,
active: false
};
visibleSection2 = {
id: 'section_2',
visible: true
};
hiddenSection3 = {
id: 'section_3',
visible: false
};
subSection4 = {
id: 'section_4',
visible: true,
parentID: 'section1'
};
topSections = {
section: visibleSection1,
section_2: visibleSection2,
section_3: hiddenSection3,
section_4: subSection4
};
}
beforeEach(async(() => { beforeEach(async(() => {
init();
TestBed.configureTestingModule({ TestBed.configureTestingModule({
providers: [ providers: [
{ provide: Store, useValue: store }, { provide: Store, useValue: store },

View File

@@ -29,52 +29,67 @@ let mockObject: ClaimedTask;
let notificationsServiceStub: NotificationsServiceStub; let notificationsServiceStub: NotificationsServiceStub;
let router: RouterStub; let router: RouterStub;
const mockDataService = jasmine.createSpyObj('ClaimedTaskDataService', { let mockDataService;
approveTask: jasmine.createSpy('approveTask'),
rejectTask: jasmine.createSpy('rejectTask'),
returnToPoolTask: jasmine.createSpy('returnToPoolTask'),
});
const searchService = getMockSearchService(); let searchService;
const requestServce = getMockRequestService(); let requestServce;
const item = Object.assign(new Item(), { let item;
bundles: observableOf({}), let rdItem;
metadata: { let workflowitem;
'dc.title': [ let rdWorkflowitem;
{
language: 'en_US', function init() {
value: 'This is just another title' mockDataService = jasmine.createSpyObj('ClaimedTaskDataService', {
} approveTask: jasmine.createSpy('approveTask'),
], rejectTask: jasmine.createSpy('rejectTask'),
'dc.type': [ returnToPoolTask: jasmine.createSpy('returnToPoolTask'),
{ });
language: null,
value: 'Article' searchService = getMockSearchService();
}
], requestServce = getMockRequestService();
'dc.contributor.author': [
{ item = Object.assign(new Item(), {
language: 'en_US', bundles: observableOf({}),
value: 'Smith, Donald' metadata: {
} 'dc.title': [
], {
'dc.date.issued': [ language: 'en_US',
{ value: 'This is just another title'
language: null, }
value: '2015-06-26' ],
} 'dc.type': [
] {
} language: null,
}); value: 'Article'
const rdItem = createSuccessfulRemoteDataObject(item); }
const workflowitem = Object.assign(new WorkflowItem(), { item: observableOf(rdItem) }); ],
const rdWorkflowitem = createSuccessfulRemoteDataObject(workflowitem); 'dc.contributor.author': [
mockObject = Object.assign(new ClaimedTask(), { workflowitem: observableOf(rdWorkflowitem), id: '1234' }); {
language: 'en_US',
value: 'Smith, Donald'
}
],
'dc.date.issued': [
{
language: null,
value: '2015-06-26'
}
]
}
});
rdItem = createSuccessfulRemoteDataObject(item);
workflowitem = Object.assign(new WorkflowItem(), { item: observableOf(rdItem) });
rdWorkflowitem = createSuccessfulRemoteDataObject(workflowitem);
mockObject = Object.assign(new ClaimedTask(), { workflowitem: observableOf(rdWorkflowitem), id: '1234' });
}
describe('ClaimedTaskActionsComponent', () => { describe('ClaimedTaskActionsComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
init();
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ imports: [
TranslateModule.forRoot({ TranslateModule.forRoot({