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({
@@ -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

@@ -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;
function init() {
text = 'HELLO';
link = 'http://google.com';
nameSpace = 'dspace.com/';
globalConfig = {
ui: { ui: {
nameSpace: nameSpace nameSpace: nameSpace
} }
} as any; } 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;
beforeEach(async(() => {
dummySection = {
id: 'section', id: 'section',
visible: true, visible: true,
active: false active: false
} as any; } as any;
beforeEach(async(() => {
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;
let fakeMenu;
let visibleSection1;
let visibleSection2;
let hiddenSection3;
let subSection4;
let topSections;
function init() {
store = Object.assign(observableOf({}), {
dispatch: () => {/***/ dispatch: () => {/***/
} }
}) as any; }) as any;
const fakeMenu = { fakeMenu = {
id: MenuID.ADMIN, id: MenuID.ADMIN,
collapsed: true, collapsed: true,
visible: false, visible: false,
previewCollapsed: true previewCollapsed: true
} as any; } as any;
const visibleSection1 = { visibleSection1 = {
id: 'section', id: 'section',
visible: true, visible: true,
active: false active: false
}; };
const visibleSection2 = { visibleSection2 = {
id: 'section_2', id: 'section_2',
visible: true visible: true
}; };
const hiddenSection3 = { hiddenSection3 = {
id: 'section_3', id: 'section_3',
visible: false visible: false
}; };
const subSection4 = { subSection4 = {
id: 'section_4', id: 'section_4',
visible: true, visible: true,
parentID: 'section1' parentID: 'section1'
}; };
const topSections = { topSections = {
section: visibleSection1, section: visibleSection1,
section_2: visibleSection2, section_2: visibleSection2,
section_3: hiddenSection3, section_3: hiddenSection3,
section_4: subSection4 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,17 +29,29 @@ let mockObject: ClaimedTask;
let notificationsServiceStub: NotificationsServiceStub; let notificationsServiceStub: NotificationsServiceStub;
let router: RouterStub; let router: RouterStub;
const mockDataService = jasmine.createSpyObj('ClaimedTaskDataService', { let mockDataService;
let searchService;
let requestServce;
let item;
let rdItem;
let workflowitem;
let rdWorkflowitem;
function init() {
mockDataService = jasmine.createSpyObj('ClaimedTaskDataService', {
approveTask: jasmine.createSpy('approveTask'), approveTask: jasmine.createSpy('approveTask'),
rejectTask: jasmine.createSpy('rejectTask'), rejectTask: jasmine.createSpy('rejectTask'),
returnToPoolTask: jasmine.createSpy('returnToPoolTask'), returnToPoolTask: jasmine.createSpy('returnToPoolTask'),
}); });
const searchService = getMockSearchService(); searchService = getMockSearchService();
const requestServce = getMockRequestService(); requestServce = getMockRequestService();
const item = Object.assign(new Item(), { item = Object.assign(new Item(), {
bundles: observableOf({}), bundles: observableOf({}),
metadata: { metadata: {
'dc.title': [ 'dc.title': [
@@ -68,13 +80,16 @@ const item = Object.assign(new Item(), {
] ]
} }
}); });
const rdItem = createSuccessfulRemoteDataObject(item); rdItem = createSuccessfulRemoteDataObject(item);
const workflowitem = Object.assign(new WorkflowItem(), { item: observableOf(rdItem) }); workflowitem = Object.assign(new WorkflowItem(), { item: observableOf(rdItem) });
const rdWorkflowitem = createSuccessfulRemoteDataObject(workflowitem); rdWorkflowitem = createSuccessfulRemoteDataObject(workflowitem);
mockObject = Object.assign(new ClaimedTask(), { workflowitem: observableOf(rdWorkflowitem), id: '1234' }); 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({