feat(medusa): allow category list api to be filtered by handle (#3825)
what: - Introduce a filter to the list endpoint to query by handle why: - Storefronts mostly interact through handles and not IDs for readability and seo purposes - Take an example of a url `site.com/category/mens-wear` RESOLVES CORE-1325
This commit is contained in:
@@ -305,6 +305,19 @@ describe("/admin/product-categories", () => {
|
||||
expect(response.data.product_categories[0].id).toEqual(productCategory.id)
|
||||
})
|
||||
|
||||
it("filters based on handle attribute of the data model", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api.get(
|
||||
`/admin/product-categories?handle=${productCategory.handle}`,
|
||||
adminHeaders,
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.count).toEqual(1)
|
||||
expect(response.data.product_categories[0].id).toEqual(productCategory.id)
|
||||
})
|
||||
|
||||
it("filters based on free text on name and handle columns", async () => {
|
||||
const api = useApi()
|
||||
|
||||
|
||||
@@ -300,6 +300,18 @@ describe("/store/product-categories", () => {
|
||||
expect(response.data.product_categories[0].id).toEqual(productCategoryParent.id)
|
||||
})
|
||||
|
||||
it("filters based on handle attribute of the data model", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api.get(
|
||||
`/store/product-categories?handle=${productCategory.handle}`,
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.count).toEqual(1)
|
||||
expect(response.data.product_categories[0].id).toEqual(productCategory.id)
|
||||
})
|
||||
|
||||
it("filters based on parent category", async () => {
|
||||
const api = useApi()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user