From 36eff7f10a81f00a0a5f4c13993ef6528d04451a Mon Sep 17 00:00:00 2001 From: adrien2p Date: Mon, 6 May 2024 13:52:30 +0200 Subject: [PATCH] wip --- .../__tests__/services/product-category/index.ts | 6 +++--- .../modules/product/src/repositories/product-category.ts | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/modules/product/integration-tests/__tests__/services/product-category/index.ts b/packages/modules/product/integration-tests/__tests__/services/product-category/index.ts index 4cb7c75ec5..9df1555c26 100644 --- a/packages/modules/product/integration-tests/__tests__/services/product-category/index.ts +++ b/packages/modules/product/integration-tests/__tests__/services/product-category/index.ts @@ -2,7 +2,7 @@ import { ProductCategoryService } from "@services" import { Modules } from "@medusajs/modules-sdk" import { IProductModuleService } from "@medusajs/types" -import { SuiteOptions, moduleIntegrationTestRunner } from "medusa-test-utils" +import { moduleIntegrationTestRunner, SuiteOptions } from "medusa-test-utils" import { createProductCategories } from "../../../__fixtures__/product-category" import { eletronicsCategoriesData, @@ -199,13 +199,13 @@ moduleIntegrationTestRunner({ mpath: "category-0.category-1.category-1-b.", parent_category_id: "category-1", category_children: [ - { + expect.objectContaining({ id: "category-1-b-1", handle: "category-1-b-1", mpath: "category-0.category-1.category-1-b.category-1-b-1.", parent_category_id: "category-1-b", category_children: [], - }, + }), ], }, ]) diff --git a/packages/modules/product/src/repositories/product-category.ts b/packages/modules/product/src/repositories/product-category.ts index e9217688a5..ba25e4ccfb 100644 --- a/packages/modules/product/src/repositories/product-category.ts +++ b/packages/modules/product/src/repositories/product-category.ts @@ -51,7 +51,7 @@ export class ProductCategoryRepository extends DALUtils.MikroOrmBaseTreeReposito } const shouldExpandParent = - familyOptions.includeAncestorsTree || fields.includes("parent_category") + familyOptions.includeAncestorsTree || populate.includes("parent_category") || fields.some(field => field.startsWith('parent_category')) if (shouldExpandParent) { populate.indexOf("parent_category") === -1 && @@ -59,8 +59,7 @@ export class ProductCategoryRepository extends DALUtils.MikroOrmBaseTreeReposito } const shouldExpandChildren = - familyOptions.includeDescendantsTree || - fields.includes("category_children") + familyOptions.includeDescendantsTree || populate.includes("category_children") || fields.some(field => field.startsWith('category_children')) if (shouldExpandChildren) { populate.indexOf("category_children") === -1 &&