Skip to content

Commit

Permalink
Merge pull request #3053 from tdonohue/port_2962_to_7x
Browse files Browse the repository at this point in the history
[Port dspace-7_x] Fix submission lost changes after save
  • Loading branch information
tdonohue authored May 15, 2024
2 parents 432692e + 3edb663 commit 8ea7a25
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ describe('SubmissionJsonPatchOperationsService', () => {
const rdbService = {} as RemoteDataBuildService;
const halEndpointService = {} as HALEndpointService;

const uuid = '91ecbeda-99fe-42ac-9430-b9b75af56f78';
const href = 'https://rest.api/some/self/link?with=maybe&a=few&other=parameters';

function initTestService() {
return new SubmissionJsonPatchOperationsService(
requestService,
Expand All @@ -37,4 +40,16 @@ describe('SubmissionJsonPatchOperationsService', () => {
expect((service as any).patchRequestConstructor).toEqual(SubmissionPatchRequest);
});

describe(`getRequestInstance`, () => {
it(`should add a parameter to embed the item to the request URL`, () => {
const result = (service as any).getRequestInstance(uuid, href);
const resultURL = new URL(result.href);
expect(resultURL.searchParams.get('embed')).toEqual('item');

// if we delete the embed item param, it should be identical to the original url
resultURL.searchParams.delete('embed');
expect(href).toEqual(resultURL.toString());
});
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { SubmitDataResponseDefinitionObject } from '../shared/submit-data-respon
import { SubmissionPatchRequest } from '../data/request.models';
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
import { CoreState } from '../core-state.model';
import { URLCombiner } from '../url-combiner/url-combiner';

/**
* A service that provides methods to make JSON Patch requests.
Expand All @@ -27,4 +28,20 @@ export class SubmissionJsonPatchOperationsService extends JsonPatchOperationsSer
super();
}

/**
* Return an instance for RestRequest class
*
* @param uuid
* The request uuid
* @param href
* The request href
* @param body
* The request body
* @return Object<PatchRequestDefinition>
* instance of PatchRequestDefinition
*/
protected getRequestInstance(uuid: string, href: string, body?: any): SubmissionPatchRequest {
return new this.patchRequestConstructor(uuid, new URLCombiner(href, '?embed=item').toString(), body);
}

}

0 comments on commit 8ea7a25

Please sign in to comment.