CST-5249_suggestion test fixes

This commit is contained in:
frabacche
2023-12-22 12:18:58 +01:00
parent e5cf16c489
commit 4106e438d6
5 changed files with 46 additions and 6 deletions

View File

@@ -77,23 +77,26 @@ describe('WorkspaceitemDataService test', () => {
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,
halService,
http,
notificationsService,
requestService,
rdbService,
objectCache,
halService,
notificationsService,
store
);
}
describe('composition', () => {
const initService = () => new WorkspaceitemDataService(null, null, null, null, null);
const initService = () => new WorkspaceitemDataService(null, null,
null, null, null, null, null, null);
testSearchDataImplementation(initService);
testDeleteDataImplementation(initService);
});

View File

@@ -23,15 +23,19 @@ import {hasValue} from '../../shared/empty.util';
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';
/**
* A service that provides methods to make REST requests with workspaceitems endpoint.
*/
@Injectable()
@dataService(WorkspaceItem.type)
export class WorkspaceitemDataService extends IdentifiableDataService<WorkspaceItem> {
export class WorkspaceitemDataService extends IdentifiableDataService<WorkspaceItem> implements SearchData<WorkspaceItem>, DeleteData<WorkspaceItem> {
protected linkPath = 'workspaceitems';
protected searchByItemLinkPath = 'item';
private searchData: SearchDataImpl<WorkspaceItem>;
private deleteData: DeleteData<WorkspaceItem>;
constructor(
@@ -45,6 +49,7 @@ export class WorkspaceitemDataService extends IdentifiableDataService<WorkspaceI
protected store: Store<CoreState>) {
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>> {
@@ -93,4 +98,34 @@ export class WorkspaceitemDataService extends IdentifiableDataService<WorkspaceI
return this.rdbService.buildFromRequestUUID(requestId);
}
/**
* Make a new FindListRequest with given search method
*
* @param searchMethod The search method for the object
* @param options The [[FindListOptions]] object
* @param useCachedVersionIfAvailable If this is true, the request will only be sent if there's
* no valid cached version. Defaults to true
* @param reRequestOnStale Whether or not the request should automatically be re-
* requested after the response becomes stale
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which
* {@link HALLink}s should be automatically resolved
* @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>>> {
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);
}
}

View File

@@ -71,6 +71,7 @@ describe('SuggestionsPopupComponent', () => {
});
it('should show a notification when new publication suggestions are available', () => {
expect((component as any).notificationsService.success).toHaveBeenCalled();
expect(suggestionStateService.dispatchMarkUserSuggestionsAsVisitedAction).toHaveBeenCalled();
});

View File

@@ -4,6 +4,7 @@ import { RestRequestMethod } from '../app/core/data/rest-request-method';
import { NotificationAnimationsType } from '../app/shared/notifications/models/notification-animations-type';
export const environment: BuildConfig = {
suggestion: [],
production: false,
// Angular Universal settings