fix(medusa,product): fix ordering product categories (#13487)

CLOSES CORE-1191

cc @SteelRazor47
This commit is contained in:
William Bouchard
2025-09-11 17:18:40 -04:00
committed by GitHub
parent 75e85414cc
commit 4fded2602b
5 changed files with 40 additions and 27 deletions

View File

@@ -717,6 +717,28 @@ medusaIntegrationTestRunner({
})
)
})
it("gets categories sorted by name", async () => {
const response = await api.get(
`/admin/product-categories?order=name`,
adminHeaders
)
const names = response.data.product_categories.map(pc => pc.name)
const sortedNames = [...names].sort((a: string, b: string) => a.localeCompare(b))
expect(names).toEqual(sortedNames)
})
it("gets categories sorted by name descending", async () => {
const response = await api.get(
`/admin/product-categories?order=-name`,
adminHeaders
)
const names = response.data.product_categories.map(pc => pc.name)
const sortedNames = [...names].sort((a: string, b: string) => b.localeCompare(a))
expect(names).toEqual(sortedNames)
})
})
describe("POST /admin/product-categories", () => {

View File

@@ -29,15 +29,8 @@ import {
IRegionModuleService,
ISalesChannelModuleService,
IStockLocationService,
PricingContext,
} from "@medusajs/types"
import {
ContainerRegistrationKeys,
Modules,
PriceListStatus,
PriceListType,
RuleOperator,
} from "@medusajs/utils"
import { ContainerRegistrationKeys, Modules, PriceListStatus, PriceListType, RuleOperator, } from "@medusajs/utils"
import {
adminHeaders,
createAdminUser,