Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Port dspace-7_x] Fix submission lost changes after save #3053

Merged
merged 3 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}

}
Loading