feat: Revamp of product categories (#7695)
* feat: Normalize the categories interface to match standards * feat: Revamp the product category implementation * fix: Adjustments to code and tests around product categories
This commit is contained in:
@@ -684,7 +684,6 @@ medusaIntegrationTestRunner({
|
||||
{
|
||||
name: "category child 2",
|
||||
parent_category_id: productCategoryChild.id,
|
||||
rank: 2,
|
||||
description: "category child 2",
|
||||
},
|
||||
adminHeaders
|
||||
@@ -697,7 +696,6 @@ medusaIntegrationTestRunner({
|
||||
{
|
||||
name: "category child 3",
|
||||
parent_category_id: productCategoryChild.id,
|
||||
rank: 2,
|
||||
description: "category child 3",
|
||||
},
|
||||
adminHeaders
|
||||
@@ -767,7 +765,7 @@ medusaIntegrationTestRunner({
|
||||
expect(siblingsResponse.data.product_categories).toEqual([
|
||||
expect.objectContaining({
|
||||
id: productCategoryChild3.id,
|
||||
rank: 1,
|
||||
rank: 0,
|
||||
}),
|
||||
])
|
||||
})
|
||||
@@ -891,7 +889,9 @@ medusaIntegrationTestRunner({
|
||||
).data.product_category
|
||||
})
|
||||
|
||||
it("throws an error if invalid ID is sent", async () => {
|
||||
// TODO: In almost all places we use a selector, not an id, to do the update, so throwing a 404 doesn't make sense from the workflow POV
|
||||
// Discuss how we want this handled across all endpoints
|
||||
it.skip("throws an error if invalid ID is sent", async () => {
|
||||
const error = await api
|
||||
.post(
|
||||
`/admin/product-categories/not-found-id`,
|
||||
@@ -925,22 +925,6 @@ medusaIntegrationTestRunner({
|
||||
expect(error.response.data.type).toEqual("invalid_data")
|
||||
})
|
||||
|
||||
// TODO: This seems to be a redundant test, I would remove this in V2
|
||||
it("throws an error if invalid attribute is sent", async () => {
|
||||
const error = await api
|
||||
.post(
|
||||
`/admin/product-categories/${productCategory.id}`,
|
||||
{
|
||||
invalid_property: "string",
|
||||
},
|
||||
adminHeaders
|
||||
)
|
||||
.catch((e) => e)
|
||||
|
||||
expect(error.response.status).toEqual(400)
|
||||
expect(error.response.data.type).toEqual("invalid_data")
|
||||
})
|
||||
|
||||
it("successfully updates a product category", async () => {
|
||||
const response = await api.post(
|
||||
`/admin/product-categories/${productCategoryChild2.id}`,
|
||||
|
||||
Reference in New Issue
Block a user