fix(medusa,product): fix ordering product categories (#13487)
CLOSES CORE-1191 cc @SteelRazor47
This commit is contained in:
@@ -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", () => {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user