mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
merge from github
This commit is contained in:
@@ -21,6 +21,9 @@ import { RequestEntry } from '../data/request-entry.model';
|
||||
import { CoreState } from '../core-state.model';
|
||||
import { testSearchDataImplementation } from '../data/base/search-data.spec';
|
||||
import { testDeleteDataImplementation } from '../data/base/delete-data.spec';
|
||||
import { SearchData } from '../data/base/search-data';
|
||||
import { DeleteData } from '../data/base/delete-data';
|
||||
import { RequestParam } from '../cache/models/request-param.model';
|
||||
|
||||
describe('WorkspaceitemDataService test', () => {
|
||||
let scheduler: TestScheduler;
|
||||
@@ -68,22 +71,20 @@ describe('WorkspaceitemDataService test', () => {
|
||||
const wsiRD = createSuccessfulRemoteDataObject(wsi);
|
||||
|
||||
const endpointURL = `https://rest.api/rest/api/submission/workspaceitems`;
|
||||
const searchRequestURL = `https://rest.api/rest/api/submission/workspaceitems/search/item?uuid=1234-1234`;
|
||||
const searchRequestURL$ = observableOf(searchRequestURL);
|
||||
|
||||
const requestUUID = '8b3c613a-5a4b-438b-9686-be1d5b4a1c5a';
|
||||
|
||||
objectCache = {} as ObjectCacheService;
|
||||
const notificationsService = {} as NotificationsService;
|
||||
const http = {} as HttpClient;
|
||||
const comparator = {} as any;
|
||||
const comparatorEntry = {} as any;
|
||||
const store = {} as Store<CoreState>;
|
||||
const pageInfo = new PageInfo();
|
||||
|
||||
function initTestService() {
|
||||
hrefOnlyDataService = getMockHrefOnlyDataService();
|
||||
return new WorkspaceitemDataService(
|
||||
comparator,
|
||||
comparatorEntry,
|
||||
halService,
|
||||
http,
|
||||
notificationsService,
|
||||
@@ -95,10 +96,11 @@ describe('WorkspaceitemDataService test', () => {
|
||||
}
|
||||
|
||||
describe('composition', () => {
|
||||
const initService = () => new WorkspaceitemDataService(null, null,
|
||||
null, null, null, null, null, null);
|
||||
testSearchDataImplementation(initService);
|
||||
testDeleteDataImplementation(initService);
|
||||
const initSearchService = () => new WorkspaceitemDataService(null, null, null, null, null, null, null, null) as unknown as SearchData<any>;
|
||||
const initDeleteService = () => new WorkspaceitemDataService(null, null, null, null, null, null, null, null) as unknown as DeleteData<any>;
|
||||
|
||||
testSearchDataImplementation(initSearchService);
|
||||
testDeleteDataImplementation(initDeleteService);
|
||||
});
|
||||
|
||||
describe('', () => {
|
||||
@@ -129,7 +131,6 @@ describe('WorkspaceitemDataService test', () => {
|
||||
service = initTestService();
|
||||
|
||||
spyOn((service as any), 'findByHref').and.callThrough();
|
||||
spyOn((service as any), 'getSearchByHref').and.returnValue(searchRequestURL$);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -140,8 +141,8 @@ describe('WorkspaceitemDataService test', () => {
|
||||
it('should proxy the call to DataService.findByHref', () => {
|
||||
scheduler.schedule(() => service.findByItem('1234-1234', true, true, pageInfo));
|
||||
scheduler.flush();
|
||||
|
||||
expect((service as any).findByHref).toHaveBeenCalledWith(searchRequestURL$, true, true);
|
||||
const searchUrl = service.getIDHref('item', [new RequestParam('uuid', encodeURIComponent('1234-1234'))]);
|
||||
expect((service as any).findByHref).toHaveBeenCalledWith(searchUrl, true, true);
|
||||
});
|
||||
|
||||
it('should return a RemoteData<WorkspaceItem> for the search', () => {
|
||||
|
@@ -24,7 +24,6 @@ import { IdentifiableDataService } from '../data/base/identifiable-data.service'
|
||||
import { NoContent } from '../shared/NoContent.model';
|
||||
import { DeleteData, DeleteDataImpl } from '../data/base/delete-data';
|
||||
import { SearchData, SearchDataImpl } from '../data/base/search-data';
|
||||
import { Bitstream } from '../shared/bitstream.model';
|
||||
import { PaginatedList } from '../data/paginated-list.model';
|
||||
|
||||
/**
|
||||
@@ -32,11 +31,11 @@ import { PaginatedList } from '../data/paginated-list.model';
|
||||
*/
|
||||
@Injectable()
|
||||
@dataService(WorkspaceItem.type)
|
||||
export class WorkspaceitemDataService extends IdentifiableDataService<WorkspaceItem> implements SearchData<WorkspaceItem>, DeleteData<WorkspaceItem> {
|
||||
export class WorkspaceitemDataService extends IdentifiableDataService<WorkspaceItem> implements DeleteData<WorkspaceItem>, SearchData<WorkspaceItem>{
|
||||
protected linkPath = 'workspaceitems';
|
||||
protected searchByItemLinkPath = 'item';
|
||||
private searchData: SearchDataImpl<WorkspaceItem>;
|
||||
private deleteData: DeleteData<WorkspaceItem>;
|
||||
private searchData: SearchData<WorkspaceItem>;
|
||||
|
||||
constructor(
|
||||
protected comparator: DSOChangeAnalyzer<WorkspaceItem>,
|
||||
@@ -50,7 +49,6 @@ export class WorkspaceitemDataService extends IdentifiableDataService<WorkspaceI
|
||||
super('workspaceitems', requestService, rdbService, objectCache, halService);
|
||||
this.deleteData = new DeleteDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, notificationsService, this.responseMsToLive, this.constructIdEndpoint);
|
||||
this.searchData = new SearchDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive);
|
||||
|
||||
}
|
||||
public delete(objectId: string, copyVirtualMetadata?: string[]): Observable<RemoteData<NoContent>> {
|
||||
return this.deleteData.delete(objectId, copyVirtualMetadata);
|
||||
@@ -98,6 +96,19 @@ export class WorkspaceitemDataService extends IdentifiableDataService<WorkspaceI
|
||||
return this.rdbService.buildFromRequestUUID(requestId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an existing object on the server
|
||||
* @param href The self link of the object to be removed
|
||||
* @param copyVirtualMetadata (optional parameter) the identifiers of the relationship types for which the virtual
|
||||
* metadata should be saved as real metadata
|
||||
* @return A RemoteData observable with an empty payload, but still representing the state of the request: statusCode,
|
||||
* errorMessage, timeCompleted, etc
|
||||
* Only emits once all request related to the DSO has been invalidated.
|
||||
*/
|
||||
deleteByHref(href: string, copyVirtualMetadata?: string[]): Observable<RemoteData<NoContent>> {
|
||||
return this.deleteData.deleteByHref(href, copyVirtualMetadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a new FindListRequest with given search method
|
||||
*
|
||||
@@ -112,20 +123,7 @@ export class WorkspaceitemDataService extends IdentifiableDataService<WorkspaceI
|
||||
* @return {Observable<RemoteData<PaginatedList<T>>}
|
||||
* Return an observable that emits response from the server
|
||||
*/
|
||||
public searchBy(searchMethod: string, options?: FindListOptions, useCachedVersionIfAvailable?: boolean, reRequestOnStale?: boolean, ...linksToFollow: FollowLinkConfig<WorkspaceItem>[]): Observable<RemoteData<PaginatedList<WorkspaceItem>>> {
|
||||
searchBy(searchMethod: string, options?: FindListOptions, useCachedVersionIfAvailable?: boolean, reRequestOnStale?: boolean, ...linksToFollow: FollowLinkConfig<WorkspaceItem>[]): Observable<RemoteData<PaginatedList<WorkspaceItem>>> {
|
||||
return this.searchData.searchBy(searchMethod, options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an existing object on the server
|
||||
* @param href The self link of the object to be removed
|
||||
* @param copyVirtualMetadata (optional parameter) the identifiers of the relationship types for which the virtual
|
||||
* metadata should be saved as real metadata
|
||||
* @return A RemoteData observable with an empty payload, but still representing the state of the request: statusCode,
|
||||
* errorMessage, timeCompleted, etc
|
||||
* Only emits once all request related to the DSO has been invalidated.
|
||||
*/
|
||||
deleteByHref(href: string, copyVirtualMetadata?: string[]): Observable<RemoteData<NoContent>> {
|
||||
return this.deleteData.deleteByHref(href, copyVirtualMetadata);
|
||||
}
|
||||
}
|
||||
|
@@ -13,11 +13,13 @@ import { SuggestionsService } from '../suggestions.service';
|
||||
describe('SuggestionsPopupComponent', () => {
|
||||
let component: SuggestionsPopupComponent;
|
||||
let fixture: ComponentFixture<SuggestionsPopupComponent>;
|
||||
let notificationsService: NotificationsService;
|
||||
|
||||
const suggestionStateService = jasmine.createSpyObj('SuggestionTargetsStateService', {
|
||||
hasUserVisitedSuggestions: jasmine.createSpy('hasUserVisitedSuggestions'),
|
||||
getCurrentUserSuggestionTargets: jasmine.createSpy('getCurrentUserSuggestionTargets'),
|
||||
dispatchMarkUserSuggestionsAsVisitedAction: jasmine.createSpy('dispatchMarkUserSuggestionsAsVisitedAction')
|
||||
dispatchMarkUserSuggestionsAsVisitedAction: jasmine.createSpy('dispatchMarkUserSuggestionsAsVisitedAction'),
|
||||
dispatchRefreshUserSuggestionsAction: jasmine.createSpy('dispatchRefreshUserSuggestionsAction')
|
||||
});
|
||||
|
||||
const mockNotificationInterpolation = { count: 12, source: 'source', suggestionId: 'id', displayName: 'displayName' };
|
||||
@@ -60,19 +62,20 @@ describe('SuggestionsPopupComponent', () => {
|
||||
describe('when there are publication suggestions', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
suggestionStateService.hasUserVisitedSuggestions.and.returnValue(observableOf(false));
|
||||
suggestionStateService.getCurrentUserSuggestionTargets.and.returnValue(observableOf([mockSuggestionTargetsObjectOne]));
|
||||
suggestionStateService.dispatchMarkUserSuggestionsAsVisitedAction.and.returnValue(observableOf(null));
|
||||
suggestionStateService.dispatchRefreshUserSuggestionsAction.and.returnValue(observableOf(null));
|
||||
|
||||
fixture = TestBed.createComponent(SuggestionsPopupComponent);
|
||||
component = fixture.componentInstance;
|
||||
notificationsService = (component as any).notificationsService;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should show a notification when new publication suggestions are available', () => {
|
||||
|
||||
expect((component as any).notificationsService.success).toHaveBeenCalled();
|
||||
expect(notificationsService.success).toHaveBeenCalled();
|
||||
expect(suggestionStateService.dispatchRefreshUserSuggestionsAction).toHaveBeenCalled();
|
||||
expect(suggestionStateService.dispatchMarkUserSuggestionsAsVisitedAction).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user