You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…destroy operations
- Implement CustomerProductAddOrchestration and CustomerProductDestroyOrchestration
- Update mocks to reflect changes in product add and destroy orchestrations
- Remove unnecessary request parameter from CustomerProductControllerUpdate
- Adjust updateArticle to accept customerId instead of user object
- Add new tests for destroy-product orchestration
- Remove redundant shopifyAdmin requests from product destroy service and tests
3, because the PR involves multiple files and significant changes including orchestration logic, service updates, and test modifications. The complexity of the orchestration and the interactions between components require a thorough review to ensure that the logic is correct and that there are no side effects.
🧪 Relevant tests
Yes
⚡ Possible issues
Possible Bug: The CustomerProductDestroyOrchestration might attempt to use product details after the product has been deleted, as indicated by the comment in src/functions/customer/controllers/product/destroy.ts. This could lead to errors if the product details are required after the deletion.
🔒 Security concerns
No
Code feedback:
relevant file
src/functions/customer-product.function.ts
suggestion
Consider validating the extraInputs parameter in the customerProductDestroy function to ensure it contains expected values and types. This validation can prevent potential issues with unexpected inputs and improve the robustness of the function. [important]
It's important to handle potential errors from CustomerProductServiceGet and CustomerProductDestroyOrchestration calls with try-catch blocks to prevent the function from crashing on exceptions. This will improve the reliability of the product destruction process. [important]
Ensure that the destroyProductOption activity is properly handling cases where product.options might be undefined or empty. This can prevent runtime errors in the orchestration process. [important]
Consider adding error handling for the orchestration steps in CustomerProductAddOrchestration. This could involve using try-catch blocks around each yield statement to manage exceptions from the activities and ensure the orchestration can handle errors gracefully. [important]
Ensure that error handling is implemented for the orchestration process to manage failures in any of the activity functions called within the orchestrator.
-const productUpdated: Awaited<ReturnType<typeof updateProduct>> =- yield context.df.callActivity(+let productUpdated;+try {+ productUpdated = yield context.df.callActivity(
updateProductName,
activityType<typeof updateProduct>(input)
);
+} catch (error) {+ context.log.error(`Error updating product: ${error}`);+ throw new Error(`Failed to update product with ID ${input.productId}`);+}
Suggestion importance[1-10]: 9
Why: Implementing error handling for the orchestration process is crucial for managing failures in any of the activity functions called within the orchestrator. This improves the robustness and reliability of the code.
9
Add input validation for df.input.durableClient()
Consider validating the input from df.input.durableClient() to ensure it meets expected criteria before using it in the extraInputs array. This can prevent potential issues with unexpected input types or values.
Why: Adding input validation is a good practice to ensure that the input meets expected criteria, which can prevent potential issues with unexpected input types or values. However, the suggestion does not specify how to implement the validateInput function, which is crucial for this change.
7
Best practice
Use a factory function for mocking to prevent state leakage between tests
Replace the direct mocking of CustomerProductAddOrchestration with a factory function that returns a new instance each time it's called. This ensures that each test has a clean instance and prevents state leakage between tests.
Why: Using a factory function for mocking ensures that each test has a clean instance, preventing state leakage between tests. This is a best practice for writing reliable and maintainable tests.
8
Maintainability
Refactor to separate product retrieval into its own function
Refactor the CustomerProductControllerDestroy function to separate concerns by moving the product retrieval logic to a separate function. This enhances readability and maintainability.
Why: Separating the product retrieval logic into its own function enhances readability and maintainability. However, the improvement is minor and does not address any critical issues.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
…destroy operations
PR Type
Enhancement, Tests
Description
CustomerProductAddOrchestration
andCustomerProductDestroyOrchestration
.request
parameter fromCustomerProductControllerUpdate
.updateArticle
to acceptcustomerId
instead ofuser
object.shopifyAdmin
requests from product destroy service and tests.Changes walkthrough 📝
10 files
customer-product.function.ts
Add extraInputs parameter to customerProductDestroy function.
src/functions/customer-product.function.ts
extraInputs
parameter tocustomerProductDestroy
function.add.ts
Replace CustomerProductUpdateOrchestration with
CustomerProductAddOrchestration.
src/functions/customer/controllers/product/add.ts
CustomerProductUpdateOrchestration
withCustomerProductAddOrchestration
.destroy.ts
Integrate CustomerProductDestroyOrchestration in destroy controller.
src/functions/customer/controllers/product/destroy.ts
CustomerProductDestroyOrchestration
andCustomerProductServiceGet
imports.CustomerProductDestroyOrchestration
.update.ts
Remove request parameter from update controller.
src/functions/customer/controllers/product/update.ts
request
parameter fromCustomerProductControllerUpdate
.update.ts
Replace user with customerId in updateArticle call.
src/functions/customer/orchestrations/customer/update.ts
user
withcustomerId
inupdateArticle
call.update-article.ts
Replace user parameter with customerId in updateArticle.
src/functions/customer/orchestrations/customer/update/update-article.ts
user
parameter withcustomerId
.CustomerServiceGet
to fetch user details.add.ts
Implement CustomerProductAddOrchestration.
src/functions/customer/orchestrations/product/add.ts
CustomerProductAddOrchestration
.destroy.ts
Implement CustomerProductDestroyOrchestration.
src/functions/customer/orchestrations/product/destroy.ts
CustomerProductDestroyOrchestration
.destroy-product.ts
Implement destroyProduct function and PRODUCT_DESTROY mutation.
src/functions/customer/orchestrations/product/destroy/destroy-product.ts
destroyProduct
function andPRODUCT_DESTROY
mutation.destroy.ts
Remove shopifyAdmin request from destroy service.
src/functions/customer/services/product/destroy.ts
shopifyAdmin
request fromCustomerProductServiceDestroy
.6 files
add.spec.ts
Update mock to use CustomerProductAddOrchestration.
src/functions/customer/controllers/product/add.spec.ts
CustomerProductAddOrchestration
instead ofCustomerProductUpdateOrchestration
.destroy.spec.ts
Update destroy product controller tests and mocks.
src/functions/customer/controllers/product/destroy.spec.ts
shopifyAdmin
and added mock forCustomerProductDestroyOrchestration
.shopifyAdmin
request.update.spec.ts
Remove unnecessary request parameter from update controller test.
src/functions/customer/controllers/product/update.spec.ts
request
parameter fromCustomerProductControllerUpdate
test.destroy-product.spec.ts
Add tests for destroyProduct function.
src/functions/customer/orchestrations/product/destroy/destroy-product.spec.ts
destroyProduct
function.update-product.spec.ts
Add handle to variables in update product test.
src/functions/customer/orchestrations/product/update/update-product.spec.ts
handle
to variables inCustomerProductUpdateOrchestration
test.destroy.spec.ts
Remove redundant shopifyAdmin requests from destroy service tests.
src/functions/customer/services/product/destroy.spec.ts
shopifyAdmin
and updated test to remove redundantshopifyAdmin
request.