Skip to content

Commit 659052f

Browse files
authored
Merge pull request DSpace#3069 from 4Science/task/main/DURACOM-263
DSpace#2923 - Fixed redirect on new Item version creation
2 parents 71bc1ad + e20c5d8 commit 659052f

2 files changed

Lines changed: 17 additions & 7 deletions

File tree

src/app/core/submission/workspaceitem-data.service.spec.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@ import {
22
HttpClient,
33
HttpHeaders,
44
} from '@angular/common/http';
5+
import { waitForAsync } from '@angular/core/testing';
56
import { Store } from '@ngrx/store';
67
import {
78
cold,
89
getTestScheduler,
910
hot,
1011
} from 'jasmine-marbles';
11-
import { of as observableOf } from 'rxjs';
12+
import {
13+
of as observableOf,
14+
of,
15+
} from 'rxjs';
16+
import { map } from 'rxjs/operators';
1217
import { TestScheduler } from 'rxjs/testing';
1318

1419
import { getMockHrefOnlyDataService } from '../../shared/mocks/href-only-data.service.mock';
@@ -151,12 +156,17 @@ describe('WorkspaceitemDataService test', () => {
151156
});
152157

153158
describe('findByItem', () => {
154-
it('should proxy the call to UpdateDataServiceImpl.findByHref', () => {
159+
it('should proxy the call to UpdateDataServiceImpl.findByHref', waitForAsync(() => {
155160
scheduler.schedule(() => service.findByItem('1234-1234', true, true, pageInfo));
156161
scheduler.flush();
157-
const searchUrl = service.getIDHref('item', [new RequestParam('uuid', '1234-1234')]);
158-
expect((service as any).findByHref).toHaveBeenCalledWith(searchUrl, true, true);
159-
});
162+
const searchUrl$ =
163+
of('https://rest.api/rest/api/submission/workspaceitems/search/item')
164+
.pipe(map(href => service.buildHrefFromFindOptions(href, { searchParams: [new RequestParam('uuid', '1234-1234')] }, [])));
165+
searchUrl$.subscribe((url) => {
166+
expect(url).toEqual('https://rest.api/rest/api/submission/workspaceitems/search/item?uuid=1234-1234');
167+
});
168+
expect((service as any).findByHref).toHaveBeenCalled();
169+
}));
160170

161171
it('should return a RemoteData<WorkspaceItem> for the search', () => {
162172
const result = service.findByItem('1234-1234', true, true, pageInfo);

src/app/core/submission/workspaceitem-data.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class WorkspaceitemDataService extends IdentifiableDataService<WorkspaceI
4545
protected linkPath = 'workspaceitems';
4646
protected searchByItemLinkPath = 'item';
4747
private deleteData: DeleteData<WorkspaceItem>;
48-
private searchData: SearchData<WorkspaceItem>;
48+
private searchData: SearchDataImpl<WorkspaceItem>;
4949

5050
constructor(
5151
protected comparator: DSOChangeAnalyzer<WorkspaceItem>,
@@ -91,7 +91,7 @@ export class WorkspaceitemDataService extends IdentifiableDataService<WorkspaceI
9191
public findByItem(uuid: string, useCachedVersionIfAvailable = false, reRequestOnStale = true, options: FindListOptions = {}, ...linksToFollow: FollowLinkConfig<WorkspaceItem>[]): Observable<RemoteData<WorkspaceItem>> {
9292
const findListOptions = new FindListOptions();
9393
findListOptions.searchParams = [new RequestParam('uuid', uuid)];
94-
const href$ = this.getIDHref(this.searchByItemLinkPath, findListOptions, ...linksToFollow);
94+
const href$ = this.searchData.getSearchByHref(this.searchByItemLinkPath, findListOptions, ...linksToFollow);
9595
return this.findByHref(href$, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow);
9696
}
9797

0 commit comments

Comments
 (0)