From 1cab68442aab488d4d5aae2c3881de9769942fed Mon Sep 17 00:00:00 2001 From: Roberto Taglioni Date: Fri, 17 Jan 2025 15:08:22 +0100 Subject: [PATCH 1/2] Fix --- .../src/services/catalogService.ts | 4 +- .../test/updateEServiceName.test.ts | 41 +++++++++---------- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/packages/catalog-process/src/services/catalogService.ts b/packages/catalog-process/src/services/catalogService.ts index 20077e117b..f8d96a8b4d 100644 --- a/packages/catalog-process/src/services/catalogService.ts +++ b/packages/catalog-process/src/services/catalogService.ts @@ -1693,9 +1693,7 @@ export function catalogServiceBuilder( if ( eservice.data.descriptors.every( - (descriptor) => - descriptor.state === descriptorState.draft || - descriptor.state === descriptorState.archived + (descriptor) => descriptor.state === descriptorState.draft ) ) { throw eserviceWithoutValidDescriptors(eserviceId); diff --git a/packages/catalog-process/test/updateEServiceName.test.ts b/packages/catalog-process/test/updateEServiceName.test.ts index ce233e0af3..582f452311 100644 --- a/packages/catalog-process/test/updateEServiceName.test.ts +++ b/packages/catalog-process/test/updateEServiceName.test.ts @@ -168,28 +168,25 @@ describe("update eService name on published eservice", () => { }) ).rejects.toThrowError(eserviceWithoutValidDescriptors(eservice.id)); }); - it.each([descriptorState.draft, descriptorState.archived])( - "should throw eserviceWithoutValidDescriptors if the eservice has only draft or archived descriptors", - async (state) => { - const descriptor: Descriptor = { - ...getMockDescriptor(state), - interface: getMockDocument(), - }; - const eservice: EService = { - ...getMockEService(), - descriptors: [descriptor], - }; - await addOneEService(eservice); - expect( - catalogService.updateEServiceName(eservice.id, "eservice new name", { - authData: getMockAuthData(eservice.producerId), - correlationId: generateId(), - serviceName: "", - logger: genericLogger, - }) - ).rejects.toThrowError(eserviceWithoutValidDescriptors(eservice.id)); - } - ); + it("should throw eserviceWithoutValidDescriptors if the eservice has only a draft descriptor", async () => { + const descriptor: Descriptor = { + ...getMockDescriptor(descriptorState.draft), + interface: getMockDocument(), + }; + const eservice: EService = { + ...getMockEService(), + descriptors: [descriptor], + }; + await addOneEService(eservice); + expect( + catalogService.updateEServiceName(eservice.id, "eservice new name", { + authData: getMockAuthData(eservice.producerId), + correlationId: generateId(), + serviceName: "", + logger: genericLogger, + }) + ).rejects.toThrowError(eserviceWithoutValidDescriptors(eservice.id)); + }); it("should throw eserviceDuplicate is there is another eservice with the same name by the same producer", async () => { const producerId = generateId(); const descriptor: Descriptor = { From 19f2997553efa8dc8891cb43f4660853f5d006ea Mon Sep 17 00:00:00 2001 From: Roberto Taglioni Date: Fri, 17 Jan 2025 15:12:51 +0100 Subject: [PATCH 2/2] Minor change in test --- packages/catalog-process/test/updateEServiceName.test.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/catalog-process/test/updateEServiceName.test.ts b/packages/catalog-process/test/updateEServiceName.test.ts index 582f452311..82be48a336 100644 --- a/packages/catalog-process/test/updateEServiceName.test.ts +++ b/packages/catalog-process/test/updateEServiceName.test.ts @@ -169,10 +169,7 @@ describe("update eService name on published eservice", () => { ).rejects.toThrowError(eserviceWithoutValidDescriptors(eservice.id)); }); it("should throw eserviceWithoutValidDescriptors if the eservice has only a draft descriptor", async () => { - const descriptor: Descriptor = { - ...getMockDescriptor(descriptorState.draft), - interface: getMockDocument(), - }; + const descriptor = getMockDescriptor(descriptorState.draft); const eservice: EService = { ...getMockEService(), descriptors: [descriptor],