Fix after master rebase and tests updated for chevron rendering changes (AoT ok)

This commit is contained in:
Marie Verdonck
2019-11-26 18:02:45 +01:00
parent 9bd1933548
commit 69a99e9381
6 changed files with 40 additions and 34 deletions

View File

@@ -4,7 +4,7 @@ import { Observable } from 'rxjs/internal/Observable';
import { RemoteData } from '../../../core/data/remote-data';
import { PaginatedList } from '../../../core/data/paginated-list';
import { RelationshipService } from '../../../core/data/relationship.service';
import { FindAllOptions } from '../../../core/data/request.models';
import { FindListOptions } from '../../../core/data/request.models';
import { Subscription } from 'rxjs/internal/Subscription';
import { ViewMode } from '../../../core/shared/view-mode.model';
@@ -33,7 +33,7 @@ export class RelatedItemsComponent implements OnInit, OnDestroy {
* Default options to start a search request with
* Optional input, should you wish a different page size (or other options)
*/
@Input() options = Object.assign(new FindAllOptions(), { elementsPerPage: 5 });
@Input() options = Object.assign(new FindListOptions(), { elementsPerPage: 5 });
/**
* An i18n label to use as a title for the list (usually describes the relation)
@@ -53,7 +53,7 @@ export class RelatedItemsComponent implements OnInit, OnDestroy {
/**
* Search options for displaying all elements in a list
*/
allOptions = Object.assign(new FindAllOptions(), { elementsPerPage: 9999 });
allOptions = Object.assign(new FindListOptions(), { elementsPerPage: 9999 });
/**
* The view-mode we're currently on

View File

@@ -1,4 +1,8 @@
import { TestBed, inject, async, fakeAsync } from '@angular/core/testing';
import { of as observableOf } from 'rxjs';
import { TestBed, inject, async } from '@angular/core/testing';
import { Store } from '@ngrx/store';
import { AppState } from '../app.reducer';
import { MockStore } from '../shared/testing/mock-store';
import { CommunityListService, FlatNode, toFlatNode } from './community-list-service';
import { CollectionDataService } from '../core/data/collection-data.service';
import { PaginatedList } from '../core/data/paginated-list';
@@ -10,10 +14,11 @@ import {
} from '../shared/testing/utils';
import { Community } from '../core/shared/community.model';
import { Collection } from '../core/shared/collection.model';
import { map, take } from 'rxjs/operators';
import { take } from 'rxjs/operators';
import { FindListOptions } from '../core/data/request.models';
describe('CommunityListService', () => {
let store: MockStore<AppState>;
const standardElementsPerPage = 2;
let collectionDataServiceStub: any;
let communityDataServiceStub: any;
@@ -179,10 +184,11 @@ describe('CommunityListService', () => {
{ provide: CollectionDataService, useValue: collectionDataServiceStub },
{ provide: CommunityDataService, useValue: communityDataServiceStub },],
});
service = new CommunityListService(communityDataServiceStub, collectionDataServiceStub);
store = TestBed.get(Store);
service = new CommunityListService(communityDataServiceStub, collectionDataServiceStub, store);
}));
afterAll(() => service = new CommunityListService(communityDataServiceStub, collectionDataServiceStub));
afterAll(() => service = new CommunityListService(communityDataServiceStub, collectionDataServiceStub, store));
it('should create', inject([CommunityListService], (serviceIn: CommunityListService) => {
expect(serviceIn).toBeTruthy();
@@ -242,7 +248,7 @@ describe('CommunityListService', () => {
beforeEach(() => {
const expandedNodes = [];
mockListOfTopCommunitiesPage1.map((community: Community) => {
const communityFlatNode = toFlatNode(community, true, 0, true, null);
const communityFlatNode = toFlatNode(community, observableOf(true), 0, true, null);
communityFlatNode.currentCollectionPage = 1;
communityFlatNode.currentCommunityPage = 1;
expandedNodes.push(communityFlatNode);
@@ -265,7 +271,7 @@ describe('CommunityListService', () => {
});
describe('Just first top comm expanded, all page 1: should return list containing flatnodes of the communities in the test list and all its possible page-limited children (subcommunities and collections)', () => {
beforeEach(() => {
const communityFlatNode = toFlatNode(mockListOfTopCommunitiesPage1[0], true, 0, true, null);
const communityFlatNode = toFlatNode(mockListOfTopCommunitiesPage1[0], observableOf(true), 0, true, null);
communityFlatNode.currentCollectionPage = 1;
communityFlatNode.currentCommunityPage = 1;
const expandedNodes = [communityFlatNode];
@@ -284,7 +290,7 @@ describe('CommunityListService', () => {
});
describe('Just second top comm expanded, collections at page 2: should return list containing flatnodes of the communities in the test list and all its possible page-limited children (subcommunities and collections)', () => {
beforeEach(() => {
const communityFlatNode = toFlatNode(mockListOfTopCommunitiesPage1[1], true, 0, true, null);
const communityFlatNode = toFlatNode(mockListOfTopCommunitiesPage1[1], observableOf(true), 0, true, null);
communityFlatNode.currentCollectionPage = 2;
communityFlatNode.currentCommunityPage = 1;
const expandedNodes = [communityFlatNode];
@@ -336,7 +342,7 @@ describe('CommunityListService', () => {
beforeEach(() => {
const expandedNodes = [];
listOfCommunities.map((community: Community) => {
const communityFlatNode = toFlatNode(community, true, 0, true, null);
const communityFlatNode = toFlatNode(community, observableOf(true), 0, true, null);
communityFlatNode.currentCollectionPage = 1;
communityFlatNode.currentCommunityPage = 1;
expandedNodes.push(communityFlatNode);
@@ -436,7 +442,7 @@ describe('CommunityListService', () => {
});
let flatNodeList;
beforeEach(() => {
const communityFlatNode = toFlatNode(communityWithSubcoms, true, 0, true, null);
const communityFlatNode = toFlatNode(communityWithSubcoms, observableOf(true), 0, true, null);
communityFlatNode.currentCollectionPage = 1;
communityFlatNode.currentCommunityPage = 1;
const expandedNodes = [communityFlatNode];
@@ -475,7 +481,7 @@ describe('CommunityListService', () => {
});
let flatNodeList;
beforeEach(() => {
const communityFlatNode = toFlatNode(communityWithCollections, true, 0, true, null);
const communityFlatNode = toFlatNode(communityWithCollections, observableOf(true), 0, true, null);
communityFlatNode.currentCollectionPage = 2;
communityFlatNode.currentCommunityPage = 1;
const expandedNodes = [communityFlatNode];
@@ -523,7 +529,7 @@ describe('CommunityListService', () => {
'dc.title': [{ language: 'en_US', value: 'Community 1' }]
}
});
expect(service.getIsExpandable(communityWithSubcoms)).toEqual(true);
expect(service.getIsExpandable(communityWithSubcoms)).toEqual(observableOf(true));
});
it('if community has collections', () => {
const communityWithCollections = Object.assign(new Community(), {
@@ -536,7 +542,7 @@ describe('CommunityListService', () => {
'dc.title': [{ language: 'en_US', value: 'Community 2' }]
}
});
expect(service.getIsExpandable(communityWithCollections)).toEqual(true);
expect(service.getIsExpandable(communityWithCollections)).toEqual(observableOf(true));
});
});
describe('should return false', () => {
@@ -551,7 +557,7 @@ describe('CommunityListService', () => {
'dc.title': [{ language: 'en_US', value: 'Community 3' }]
}
});
expect(service.getIsExpandable(communityWithNoSubcomsOrColls)).toEqual(false);
expect(service.getIsExpandable(communityWithNoSubcomsOrColls)).toEqual(observableOf(false));
});
});

View File

@@ -17,7 +17,7 @@ import { createSuccessfulRemoteDataObject$ } from '../../shared/testing/utils';
import { PaginatedList } from '../../core/data/paginated-list';
import { PageInfo } from '../../core/shared/page-info.model';
import { Collection } from '../../core/shared/collection.model';
import { Observable, of as observableOf } from 'rxjs';
import { of as observableOf } from 'rxjs';
import { By } from '@angular/platform-browser';
import { isEmpty, isNotEmpty } from '../../shared/empty.util';
@@ -89,7 +89,7 @@ describe('CommunityListComponent', () => {
subcommunities: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), mockSubcommunities1Page1)),
collections: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])),
name: 'community1',
}), true, 0, false, null
}), observableOf(true), 0, false, null
),
toFlatNode(
Object.assign(new Community(), {
@@ -98,7 +98,7 @@ describe('CommunityListComponent', () => {
subcommunities: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])),
collections: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [...mockCollectionsPage1, ...mockCollectionsPage2])),
name: 'community2',
}), true, 0, false, null
}), observableOf(true), 0, false, null
),
toFlatNode(
Object.assign(new Community(), {
@@ -107,7 +107,7 @@ describe('CommunityListComponent', () => {
subcommunities: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])),
collections: createSuccessfulRemoteDataObject$(new PaginatedList(new PageInfo(), [])),
name: 'community3',
}), false, 0, false, null
}), observableOf(false), 0, false, null
),
];
let communityListServiceStub;
@@ -143,7 +143,7 @@ describe('CommunityListComponent', () => {
flatnodes = [];
const topFlatnodes = mockTopFlatnodesUnexpanded.slice(0, endPageIndex);
topFlatnodes.map((topNode: FlatNode) => {
flatnodes = [...flatnodes, topNode]
flatnodes = [...flatnodes, topNode];
const expandedParent: FlatNode = expandedNodes.find((expandedNode: FlatNode) => expandedNode.id === topNode.id);
if (isNotEmpty(expandedParent)) {
const matchingTopComWithArrays = mockTopCommunitiesWithChildrenArrays.find((topcom) => topcom.id === topNode.id);
@@ -151,12 +151,12 @@ describe('CommunityListComponent', () => {
const possibleSubcoms: Community[] = matchingTopComWithArrays.subcommunities;
let subComFlatnodes = [];
possibleSubcoms.map((subcom: Community) => {
subComFlatnodes = [...subComFlatnodes, toFlatNode(subcom, false, topNode.level + 1, false, topNode)];
subComFlatnodes = [...subComFlatnodes, toFlatNode(subcom, observableOf(false), topNode.level + 1, false, topNode)];
});
const possibleColls: Collection[] = matchingTopComWithArrays.collections;
let collFlatnodes = [];
possibleColls.map((coll: Collection) => {
collFlatnodes = [...collFlatnodes, toFlatNode(coll, false, topNode.level + 1, false, topNode)];
collFlatnodes = [...collFlatnodes, toFlatNode(coll, observableOf(false), topNode.level + 1, false, topNode)];
});
if (isNotEmpty(subComFlatnodes)) {
const endSubComIndex = this.subcommunityPageSize * expandedParent.currentCommunityPage;
@@ -313,7 +313,7 @@ describe('CommunityListComponent', () => {
expect(allNodes.find((foundEl) => {
return (foundEl.nativeElement.textContent.trim() === coll.name);
})).toBeTruthy();
})
});
expect(allNodes.length).toEqual(4);
const showMoreEl = fixture.debugElement.queryAll(By.css('.show-more-node'));
expect(showMoreEl.length).toEqual(2);

View File

@@ -11,7 +11,7 @@ import { HALEndpointService } from '../shared/hal-endpoint.service';
import { NotificationsService } from '../../shared/notifications/notifications.service';
import { HttpClient } from '@angular/common/http';
import { DefaultChangeAnalyzer } from './default-change-analyzer.service';
import { FindAllOptions } from './request.models';
import { FindListOptions } from './request.models';
import { Observable } from 'rxjs/internal/Observable';
/**
@@ -40,7 +40,7 @@ export class BundleDataService extends DataService<Bundle> {
* @param {FindAllOptions} options
* @returns {Observable<string>}
*/
getBrowseEndpoint(options: FindAllOptions = {}, linkPath?: string): Observable<string> {
getBrowseEndpoint(options: FindListOptions = {}, linkPath?: string): Observable<string> {
return this.halService.getEndpoint(this.linkPath);
}
}

View File

@@ -8,7 +8,7 @@ import { RemoteDataBuildService } from '../cache/builders/remote-data-build.serv
import { RequestService } from './request.service';
import { Store } from '@ngrx/store';
import { CoreState } from '../core.reducers';
import { FindAllOptions, FindByIDRequest, IdentifierType } from './request.models';
import { FindListOptions, FindByIDRequest, IdentifierType } from './request.models';
import { Observable } from 'rxjs';
import { RemoteData } from './remote-data';
import { DSOChangeAnalyzer } from './dso-change-analyzer.service';
@@ -40,7 +40,7 @@ export class DsoRedirectDataService extends DataService<any> {
super();
}
getBrowseEndpoint(options: FindAllOptions = {}, linkPath: string = this.linkPath): Observable<string> {
getBrowseEndpoint(options: FindListOptions = {}, linkPath: string = this.linkPath): Observable<string> {
return this.halService.getEndpoint(linkPath);
}

View File

@@ -10,7 +10,7 @@ import {
getRemoteDataPayload, getResponseFromEntry,
getSucceededRemoteData
} from '../shared/operators';
import { DeleteRequest, FindAllOptions, RestRequest } from './request.models';
import { DeleteRequest, FindListOptions, RestRequest } from './request.models';
import { Observable } from 'rxjs/internal/Observable';
import { RestResponse } from '../cache/response.models';
import { Item } from '../shared/item.model';
@@ -56,7 +56,7 @@ export class RelationshipService extends DataService<Relationship> {
super();
}
getBrowseEndpoint(options: FindAllOptions = {}, linkPath: string = this.linkPath): Observable<string> {
getBrowseEndpoint(options: FindListOptions = {}, linkPath: string = this.linkPath): Observable<string> {
return this.halService.getEndpoint(linkPath);
}
@@ -228,7 +228,7 @@ export class RelationshipService extends DataService<Relationship> {
* @param label
* @param options
*/
getRelatedItemsByLabel(item: Item, label: string, options?: FindAllOptions): Observable<RemoteData<PaginatedList<Item>>> {
getRelatedItemsByLabel(item: Item, label: string, options?: FindListOptions): Observable<RemoteData<PaginatedList<Item>>> {
return this.getItemRelationshipsByLabel(item, label, options).pipe(paginatedRelationsToItems(item.uuid));
}
@@ -239,10 +239,10 @@ export class RelationshipService extends DataService<Relationship> {
* @param label
* @param options
*/
getItemRelationshipsByLabel(item: Item, label: string, options?: FindAllOptions): Observable<RemoteData<PaginatedList<Relationship>>> {
let findAllOptions = new FindAllOptions();
getItemRelationshipsByLabel(item: Item, label: string, options?: FindListOptions): Observable<RemoteData<PaginatedList<Relationship>>> {
let findAllOptions = new FindListOptions();
if (options) {
findAllOptions = Object.assign(new FindAllOptions(), options);
findAllOptions = Object.assign(new FindListOptions(), options);
}
const searchParams = [ new SearchParam('label', label), new SearchParam('dso', item.id) ];
if (findAllOptions.searchParams) {