Commits

Tim Donohue authored and GitHub committed 288a9180aac Merge
Merge pull request #2962 from atmire/fix-submission-lost-changes-after-save-8.0.0-next

Fix submission lost changes after save
No tags
gidlmaster

src/app/core/submission/submission-json-patch-operations.service.spec.ts

Modified
10 10 import { SubmissionJsonPatchOperationsService } from './submission-json-patch-operations.service';
11 11
12 12 describe('SubmissionJsonPatchOperationsService', () => {
13 13 let scheduler: TestScheduler;
14 14 let service: SubmissionJsonPatchOperationsService;
15 15 const requestService = {} as RequestService;
16 16 const store = {} as Store<CoreState>;
17 17 const rdbService = {} as RemoteDataBuildService;
18 18 const halEndpointService = {} as HALEndpointService;
19 19
20 + const uuid = '91ecbeda-99fe-42ac-9430-b9b75af56f78';
21 + const href = 'https://rest.api/some/self/link?with=maybe&a=few&other=parameters';
22 +
20 23 function initTestService() {
21 24 return new SubmissionJsonPatchOperationsService(
22 25 requestService,
23 26 store,
24 27 rdbService,
25 28 halEndpointService,
26 29 );
27 30 }
28 31
29 32 beforeEach(() => {
30 33 scheduler = getTestScheduler();
31 34 service = initTestService();
32 35 });
33 36
34 37 it('should instantiate SubmissionJsonPatchOperationsService properly', () => {
35 38 expect(service).toBeDefined();
36 39 expect((service as any).patchRequestConstructor).toEqual(SubmissionPatchRequest);
37 40 });
38 41
42 + describe(`getRequestInstance`, () => {
43 + it(`should add a parameter to embed the item to the request URL`, () => {
44 + const result = (service as any).getRequestInstance(uuid, href);
45 + const resultURL = new URL(result.href);
46 + expect(resultURL.searchParams.get('embed')).toEqual('item');
47 +
48 + // if we delete the embed item param, it should be identical to the original url
49 + resultURL.searchParams.delete('embed', 'item');
50 + expect(href).toEqual(resultURL.toString());
51 + });
52 + });
53 +
39 54 });

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut