From cb0d805f2b41d866d2488f78466ec63ae1da896e Mon Sep 17 00:00:00 2001 From: asafMasa Date: Thu, 28 Aug 2025 15:59:27 +0300 Subject: [PATCH 1/3] fix: fix update metadata with same product name --- src/validator/validationManager.ts | 3 ++- .../metadata/metadataController.spec.ts | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/validator/validationManager.ts b/src/validator/validationManager.ts index b76ce41..99ce8cd 100644 --- a/src/validator/validationManager.ts +++ b/src/validator/validationManager.ts @@ -199,7 +199,8 @@ export class ValidationManager { if (payload.productName != undefined) { const records = await this.catalog.findRecords({ productName: payload.productName }); - if (records.length > 0) { + const differentRecordsWithSameName = records.filter((recordWithSameName) => recordWithSameName.id !== identifier); + if (differentRecordsWithSameName.length > 0) { refReason.outFailedReason = ERROR_METADATA_PRODUCT_NAME_UNIQUE!; return false; } diff --git a/tests/integration/metadata/metadataController.spec.ts b/tests/integration/metadata/metadataController.spec.ts index 616da6f..c738d7f 100644 --- a/tests/integration/metadata/metadataController.spec.ts +++ b/tests/integration/metadata/metadataController.spec.ts @@ -71,6 +71,25 @@ describe('MetadataController', function () { expect(response).toSatisfyApiSpec(); }); + it(`Should return 200 status code if record product name is my name (unique)`, async function () { + const identifier = faker.string.uuid(); + const payload = createUpdatePayload(); + const expected = createRecord(); + const record = createRecord(); + record.id = identifier; + const linkUrl = extractLink(record.links); + await s3Helper.createFile(linkUrl, true); + mockAxios.get.mockResolvedValueOnce({ status: StatusCodes.OK, data: record }); + mockAxios.get.mockResolvedValueOnce({ data: [{ value: payload.classification }] as ILookupOption[] }); + mockAxios.post.mockResolvedValueOnce({ status: StatusCodes.OK, data: [record] }); + mockAxios.patch.mockResolvedValueOnce({ status: StatusCodes.OK, data: expected }); + + const response = await requestSender.updateMetadata(identifier, payload); + + expect(response.status).toBe(StatusCodes.OK); + expect(response).toSatisfyApiSpec(); + }); + it(`Should return 200 status code and metadata if payload is valid and footprint is 3D and pass footprint 2D to catalog`, async function () { const identifier = faker.string.uuid(); const payload = createUpdatePayload('Sphere'); From 1629f10afe495b9ee3b56866b07f2c77757da3ff Mon Sep 17 00:00:00 2001 From: asafMasa Date: Thu, 28 Aug 2025 16:26:28 +0300 Subject: [PATCH 2/3] chore: update workflow --- .github/workflows/pull_request.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 5b80e12..40a5ef9 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -4,7 +4,7 @@ on: [pull_request] jobs: pull_request: - uses: MapColonies/shared-workflows/.github/workflows/pull_request.yaml@v5 + uses: MapColonies/shared-workflows/.github/workflows/pull_request.yaml@v4 secrets: inherit with: openApiFilePath: './bundledApi.yaml' From e02f42514c620d8bbb73a3e28406006f402ba983 Mon Sep 17 00:00:00 2001 From: asafMasa Date: Thu, 28 Aug 2025 16:29:46 +0300 Subject: [PATCH 3/3] chore: fix cr comments --- src/validator/validationManager.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/validator/validationManager.ts b/src/validator/validationManager.ts index 99ce8cd..f3740c2 100644 --- a/src/validator/validationManager.ts +++ b/src/validator/validationManager.ts @@ -199,8 +199,8 @@ export class ValidationManager { if (payload.productName != undefined) { const records = await this.catalog.findRecords({ productName: payload.productName }); - const differentRecordsWithSameName = records.filter((recordWithSameName) => recordWithSameName.id !== identifier); - if (differentRecordsWithSameName.length > 0) { + const differentRecordsWithSameNameExists = records.some((recordWithSameName) => recordWithSameName.id !== identifier); + if (differentRecordsWithSameNameExists) { refReason.outFailedReason = ERROR_METADATA_PRODUCT_NAME_UNIQUE!; return false; }