From eb9b99cf3f3833fba1fc68f036ec69ef6c086182 Mon Sep 17 00:00:00 2001 From: Alexandre Vryghem Date: Mon, 27 May 2024 16:09:35 +0200 Subject: [PATCH] 115427: Fixed delete item not redirecting when having some virtual metadata that needs to be copied --- src/app/core/data/base/delete-data.spec.ts | 7 ++++++- src/app/core/data/base/delete-data.ts | 5 +++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/app/core/data/base/delete-data.spec.ts b/src/app/core/data/base/delete-data.spec.ts index a076473b0fe..4564b2ce413 100644 --- a/src/app/core/data/base/delete-data.spec.ts +++ b/src/app/core/data/base/delete-data.spec.ts @@ -190,7 +190,7 @@ describe('DeleteDataImpl', () => { }); }); - it('should include the virtual metadata to be copied in the DELETE request', (done) => { + fit('should include the virtual metadata to be copied in the DELETE request', (done) => { buildFromRequestUUIDAndAwaitSpy.and.returnValue(observableOf(MOCK_SUCCEEDED_RD)); service.deleteByHref('some-href', ['a', 'b', 'c']).subscribe(() => { @@ -198,6 +198,11 @@ describe('DeleteDataImpl', () => { method: RestRequestMethod.DELETE, href: 'some-href?copyVirtualMetadata=a©VirtualMetadata=b©VirtualMetadata=c', })); + + const callback = (rdbService.buildFromRequestUUIDAndAwait as jasmine.Spy).calls.argsFor(0)[1]; + callback(); + expect(service.invalidateByHref).toHaveBeenCalledWith('some-href'); + done(); }); }); diff --git a/src/app/core/data/base/delete-data.ts b/src/app/core/data/base/delete-data.ts index 807d9d838e9..26f9d1cc532 100644 --- a/src/app/core/data/base/delete-data.ts +++ b/src/app/core/data/base/delete-data.ts @@ -68,15 +68,16 @@ export class DeleteDataImpl extends IdentifiableDataS deleteByHref(href: string, copyVirtualMetadata?: string[]): Observable> { const requestId = this.requestService.generateRequestId(); + let deleteHref: string = href; if (copyVirtualMetadata) { copyVirtualMetadata.forEach((id) => - href += (href.includes('?') ? '&' : '?') + deleteHref += (deleteHref.includes('?') ? '&' : '?') + 'copyVirtualMetadata=' + id, ); } - const request = new DeleteRequest(requestId, href); + const request = new DeleteRequest(requestId, deleteHref); if (hasValue(this.responseMsToLive)) { request.responseMsToLive = this.responseMsToLive; }