feat: Add support for search to all endpoints (#7149)

* feat: Add search capability to api keys

* feat: Add support for searching to currency and customer endpoints

* fix: Clean up product search filters

* feat: Add search support to regions

* feat: Add search support to sales channels

* feat: Add search support to store module

* feat: Add search support to user module

* fix: Clean up inventory search

* feat: Add search support for payments

* fix: Add searchable attributes to stock location models

* feat: Add search support to tax

* feat: Add search support to promotions

* feat: Add search support for pricing, filtering cleanup

* fix: Further cleanups around search
This commit is contained in:
Stevche Radevski
2024-04-25 17:36:59 +02:00
committed by GitHub
parent d02905cefa
commit f03a822253
52 changed files with 640 additions and 64 deletions
@@ -92,6 +92,53 @@ medusaIntegrationTestRunner({
])
)
})
it("should support searching through the addresses", async () => {
const [customer] = await customerModuleService.create([
{
first_name: "Test",
last_name: "Test",
email: "test@me.com",
addresses: [
{
first_name: "John",
last_name: "Doe",
address_1: "Huntingdon 123",
},
{
first_name: "Jane",
last_name: "Doe",
address_1: "Horseshoe 555",
},
{
first_name: "Jack",
last_name: "Doe",
address_1: "Hawkins 12",
},
],
},
])
const response = await api.get(
`/admin/customers/${customer.id}/addresses?q=12`,
adminHeaders
)
expect(response.status).toEqual(200)
expect(response.data.addresses).toHaveLength(2)
expect(response.data.addresses).toEqual(
expect.arrayContaining([
expect.objectContaining({
id: expect.any(String),
address_1: "Huntingdon 123",
}),
expect.objectContaining({
id: expect.any(String),
address_1: "Hawkins 12",
}),
])
)
})
})
},
})
@@ -141,6 +141,43 @@ medusaIntegrationTestRunner({
})
)
})
it("should support searching of customers", async () => {
await customerModuleService.create([
{
first_name: "Jane",
last_name: "Doe",
email: "jane@me.com",
},
{
first_name: "John",
last_name: "Doe",
email: "john@me.com",
},
{
first_name: "LeBron",
last_name: "James",
email: "lebron@me.com",
},
])
const response = await api.get(`/admin/customers?q=do`, adminHeaders)
expect(response.status).toEqual(200)
expect(response.data.customers).toHaveLength(2)
expect(response.data.customers).toEqual(
expect.arrayContaining([
expect.objectContaining({
first_name: "Jane",
last_name: "Doe",
}),
expect.objectContaining({
first_name: "John",
last_name: "Doe",
}),
])
)
})
})
},
})