feat(medusa, inventory): Search inventory items by title and description (#4154)
* initial filtering based on query * add changeset * add expect clause to ensure other items are not inluded
This commit is contained in:
@@ -538,6 +538,49 @@ describe("Inventory Items endpoints", () => {
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it("Lists inventory items searching by title, description and sku", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const inventoryService = appContainer.resolve("inventoryService")
|
||||
|
||||
await Promise.all([
|
||||
inventoryService.createInventoryItem({
|
||||
title: "Test Item",
|
||||
}),
|
||||
inventoryService.createInventoryItem({
|
||||
description: "Test Desc",
|
||||
}),
|
||||
inventoryService.createInventoryItem({
|
||||
sku: "Test Sku",
|
||||
}),
|
||||
])
|
||||
|
||||
const response = await api.get(
|
||||
`/admin/inventory-items?q=test`,
|
||||
adminHeaders
|
||||
)
|
||||
|
||||
expect(response.data.inventory_items).not.toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
sku: "MY_SKU",
|
||||
}),
|
||||
])
|
||||
)
|
||||
expect(response.data.inventory_items).toHaveLength(3)
|
||||
expect(response.data.inventory_items).toEqual([
|
||||
expect.objectContaining({
|
||||
sku: "Test Sku",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
description: "Test Desc",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
title: "Test Item",
|
||||
}),
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
it("When deleting an inventory item it removes associated levels and reservations", async () => {
|
||||
|
||||
Reference in New Issue
Block a user