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:
Riqwan Thamir
2023-04-13 19:57:30 +02:00
committed by GitHub
parent 3bd4bf0b8d
commit 95d338262b
7 changed files with 50 additions and 2 deletions

View File

@@ -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()

View File

@@ -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()