From 81dd656c9e53edfe521b79f6c886c3b4ff2e84b9 Mon Sep 17 00:00:00 2001 From: Joshua Kitenge Date: Wed, 24 Apr 2024 16:02:24 +0000 Subject: [PATCH] fix e2e tests --- .github/workflows/ci-build.yml | 2 +- src/api/catalogueItems.tsx | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index ed3a72efb..604c8866e 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -82,7 +82,7 @@ jobs: MONGO_INITDB_ROOT_PASSWORD: example ims-api: - image: harbor.stfc.ac.uk/inventory-management-system/ims-api:develop + image: harbor.stfc.ac.uk/inventory-management-system/ims-api:pr-240 ports: - 8000:8000 env: diff --git a/src/api/catalogueItems.tsx b/src/api/catalogueItems.tsx index 3c898df32..039364b72 100644 --- a/src/api/catalogueItems.tsx +++ b/src/api/catalogueItems.tsx @@ -253,16 +253,25 @@ export const useCopyToCatalogueItem = (): UseMutationResult< // Information to post (backend will just ignore the extra here - only id and code) // Also use Object.assign to copy the data otherwise will modify in place causing issues // in tests + + const targetProperties = + copyToCatalogueItem.targetCatalogueCategory + ?.catalogue_item_properties; + // eslint-disable-next-line @typescript-eslint/no-unused-vars - const properties = catalogueItem.properties.map( - ({ name, unit, ...rest }) => rest - ); + const properties = catalogueItem.properties.map((property) => { + const targetPropertyId = targetProperties?.find( + (targetProperty) => property.name === targetProperty.name + )?.id; + return { id: targetPropertyId, value: property.value }; + }); + const catalogueItemAdd: AddCatalogueItem = Object.assign( {}, { ...catalogueItem, properties: properties } ) as AddCatalogueItem; - // Assing new parent + // Assign new parent catalogueItemAdd.catalogue_category_id = copyToCatalogueItem.targetCatalogueCategory?.id ?? '';