Skip to content

Commit

Permalink
Merge pull request #3069 from 4Science/task/main/DURACOM-263
Browse files Browse the repository at this point in the history
#2923 - Fixed redirect on new Item version creation
  • Loading branch information
tdonohue committed May 22, 2024
2 parents 71bc1ad + e20c5d8 commit 659052f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
20 changes: 15 additions & 5 deletions src/app/core/submission/workspaceitem-data.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ import {
HttpClient,
HttpHeaders,
} from '@angular/common/http';
import { waitForAsync } from '@angular/core/testing';
import { Store } from '@ngrx/store';
import {
cold,
getTestScheduler,
hot,
} from 'jasmine-marbles';
import { of as observableOf } from 'rxjs';
import {
of as observableOf,
of,
} from 'rxjs';
import { map } from 'rxjs/operators';
import { TestScheduler } from 'rxjs/testing';

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

describe('findByItem', () => {
it('should proxy the call to UpdateDataServiceImpl.findByHref', () => {
it('should proxy the call to UpdateDataServiceImpl.findByHref', waitForAsync(() => {
scheduler.schedule(() => service.findByItem('1234-1234', true, true, pageInfo));
scheduler.flush();
const searchUrl = service.getIDHref('item', [new RequestParam('uuid', '1234-1234')]);
expect((service as any).findByHref).toHaveBeenCalledWith(searchUrl, true, true);
});
const searchUrl$ =
of('https://rest.api/rest/api/submission/workspaceitems/search/item')
.pipe(map(href => service.buildHrefFromFindOptions(href, { searchParams: [new RequestParam('uuid', '1234-1234')] }, [])));
searchUrl$.subscribe((url) => {
expect(url).toEqual('https://rest.api/rest/api/submission/workspaceitems/search/item?uuid=1234-1234');
});
expect((service as any).findByHref).toHaveBeenCalled();
}));

it('should return a RemoteData<WorkspaceItem> for the search', () => {
const result = service.findByItem('1234-1234', true, true, pageInfo);
Expand Down
4 changes: 2 additions & 2 deletions src/app/core/submission/workspaceitem-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class WorkspaceitemDataService extends IdentifiableDataService<WorkspaceI
protected linkPath = 'workspaceitems';
protected searchByItemLinkPath = 'item';
private deleteData: DeleteData<WorkspaceItem>;
private searchData: SearchData<WorkspaceItem>;
private searchData: SearchDataImpl<WorkspaceItem>;

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

Expand Down

0 comments on commit 659052f

Please sign in to comment.