fix(product): Always add q if defined (#9505)
This commit is contained in:
1 parent
e23d2b9ed7
commit
853187410e
2 files changed
+17
-13
No files matched your search
@@ -4,7 +4,7 @@ import {
|
|||||||
createAdminUser,
|
createAdminUser,
|
||||||
} from "../../../../helpers/create-admin-user"
|
} from "../../../../helpers/create-admin-user"
|
||||||
|
|
||||||
jest.setTimeout(30000)
|
jest.setTimeout(50000)
|
||||||
|
|
||||||
medusaIntegrationTestRunner({
|
medusaIntegrationTestRunner({
|
||||||
testSuite: ({ dbConnection, getContainer, api }) => {
|
testSuite: ({ dbConnection, getContainer, api }) => {
|
||||||
@@ -310,6 +310,14 @@ medusaIntegrationTestRunner({
|
|||||||
)
|
)
|
||||||
).data.product_category
|
).data.product_category
|
||||||
|
|
||||||
|
await api.post(
|
||||||
|
"/admin/product-categories",
|
||||||
|
{
|
||||||
|
name: "Something different",
|
||||||
|
},
|
||||||
|
adminHeaders
|
||||||
|
)
|
||||||
|
|
||||||
const response = await api.get(
|
const response = await api.get(
|
||||||
"/admin/product-categories?q=Category",
|
"/admin/product-categories?q=Category",
|
||||||
adminHeaders
|
adminHeaders
|
||||||
@@ -333,20 +341,16 @@ medusaIntegrationTestRunner({
|
|||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
|
})
|
||||||
|
|
||||||
const responseTwo = await api.get(
|
it("should query all categories if q is empty", async () => {
|
||||||
"/admin/product-categories?q=three",
|
const response = await api.get(
|
||||||
|
"/admin/product-categories?q=",
|
||||||
adminHeaders
|
adminHeaders
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(responseTwo.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(responseTwo.data.product_categories).toHaveLength(1)
|
expect(response.data.product_categories).toHaveLength(7) // created in beforeEach
|
||||||
expect(responseTwo.data.product_categories).toEqual([
|
|
||||||
expect.objectContaining({
|
|
||||||
id: categoryThree.id,
|
|
||||||
name: "Category Three",
|
|
||||||
}),
|
|
||||||
])
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("gets list of product category with immediate children and parents", async () => {
|
it("gets list of product category with immediate children and parents", async () => {
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ export default class ProductCategoryService {
|
|||||||
delete filters.include_ancestors_tree
|
delete filters.include_ancestors_tree
|
||||||
|
|
||||||
// Apply free text search filter
|
// Apply free text search filter
|
||||||
if (filters?.q) {
|
if (isDefined(filters?.q)) {
|
||||||
config.filters ??= {}
|
config.filters ??= {}
|
||||||
config.filters[FreeTextSearchFilterKey] = {
|
config.filters[FreeTextSearchFilterKey] = {
|
||||||
value: filters.q,
|
value: filters.q,
|
||||||
@@ -121,7 +121,7 @@ export default class ProductCategoryService {
|
|||||||
delete filters.include_ancestors_tree
|
delete filters.include_ancestors_tree
|
||||||
|
|
||||||
// Apply free text search filter
|
// Apply free text search filter
|
||||||
if (filters?.q) {
|
if (isDefined(filters?.q)) {
|
||||||
config.filters ??= {}
|
config.filters ??= {}
|
||||||
config.filters[FreeTextSearchFilterKey] = {
|
config.filters[FreeTextSearchFilterKey] = {
|
||||||
value: filters.q,
|
value: filters.q,
|
||||||
|
|||||||
Reference in new issue
Block a user