fix: ILIKE operator not supported in sqlite (#393)

* fix: replace ILIKE operator with ILike function where possible

* remove: unused import

* fix: remove alias from test case as it is not needed

* fix: product variant query

* add: integration tests + fallback to original query for all queries searching on the display_id field

* remove: console.log
This commit is contained in:
Zakaria El Asri
2021-09-21 11:15:33 +02:00
committed by GitHub
parent 00ab03f3a2
commit 49a132976d
12 changed files with 793 additions and 448 deletions
@@ -24,6 +24,67 @@ describe("/admin/discounts", () => {
medusaProcess.kill()
})
describe("GET /admin/discounts", () => {
beforeEach(async () => {
const manager = dbConnection.manager
try {
await adminSeeder(dbConnection)
await manager.insert(DiscountRule, {
id: "test-discount-rule",
description: "Test discount rule",
type: "percentage",
value: 10,
allocation: "total",
})
await manager.insert(Discount, {
id: "test-discount",
code: "TESTING",
rule_id: "test-discount-rule",
is_dynamic: false,
is_disabled: false,
})
await manager.insert(Discount, {
id: "messi-discount",
code: "BARCA100",
rule_id: "test-discount-rule",
is_dynamic: false,
is_disabled: false,
})
} catch (err) {
throw err
}
})
afterEach(async () => {
const db = useDb()
await db.teardown()
})
it("should list discounts that match a specific query in a case insensitive manner", async () => {
const api = useApi()
const response = await api
.get("/admin/discounts?q=barca", {
headers: {
Authorization: "Bearer test_token",
},
})
.catch((err) => {
console.log(err)
})
expect(response.status).toEqual(200)
expect(response.data.count).toEqual(1)
expect(response.data.discounts).toEqual(
expect.arrayContaining([
expect.objectContaining({
id: "messi-discount",
code: "BARCA100",
}),
])
)
})
})
describe("POST /admin/discounts", () => {
beforeEach(async () => {
try {