chore(integration-tests): Fixed merge conflict
This commit is contained in:
@@ -331,12 +331,15 @@ describe("/admin/discounts", () => {
|
||||
})
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.count).toEqual(1)
|
||||
expect(response.data.discounts).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "fixed-discount",
|
||||
code: "fixed100",
|
||||
}),
|
||||
])
|
||||
expect(response.data.discounts).toHaveLength(1)
|
||||
expect(response.data.discounts).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "fixed-discount",
|
||||
code: "fixed100",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("fails when listing invalid discount types", async () => {
|
||||
@@ -394,12 +397,15 @@ describe("/admin/discounts", () => {
|
||||
})
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.count).toEqual(1)
|
||||
expect(response.data.discounts).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "dynamic-discount",
|
||||
code: "Dyn100",
|
||||
}),
|
||||
])
|
||||
expect(response.data.discounts).toHaveLength(1)
|
||||
expect(response.data.discounts).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "dynamic-discount",
|
||||
code: "Dyn100",
|
||||
})
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("lists disabled discounts ", async () => {
|
||||
@@ -416,12 +422,15 @@ describe("/admin/discounts", () => {
|
||||
})
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.count).toEqual(1)
|
||||
expect(response.data.discounts).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "disabled-discount",
|
||||
code: "Dis100",
|
||||
}),
|
||||
])
|
||||
expect(response.data.discounts).toHaveLength(1)
|
||||
expect(response.data.discounts).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "disabled-discount",
|
||||
code: "Dis100",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -609,16 +618,19 @@ describe("/admin/discounts", () => {
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.discount.rule.conditions).toEqual([
|
||||
expect.objectContaining({
|
||||
type: "products",
|
||||
operator: "in",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
type: "product_types",
|
||||
operator: "not_in",
|
||||
}),
|
||||
])
|
||||
expect(response.data.discount.rule.conditions).toHaveLength(2)
|
||||
expect(response.data.discount.rule.conditions).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
type: "products",
|
||||
operator: "in",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
type: "product_types",
|
||||
operator: "not_in",
|
||||
}),
|
||||
])
|
||||
)
|
||||
|
||||
const createdRule = response.data.discount.rule
|
||||
const condsToUpdate = createdRule.conditions[0]
|
||||
@@ -1468,6 +1480,70 @@ describe("/admin/discounts", () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe("POST /admin/discounts/:id", () => {
|
||||
beforeEach(async () => {
|
||||
await adminSeeder(dbConnection)
|
||||
await dbConnection.manager.insert(DiscountRule, {
|
||||
id: "test-discount-rule",
|
||||
description: "Test discount rule",
|
||||
type: "percentage",
|
||||
value: 10,
|
||||
allocation: "total",
|
||||
})
|
||||
await dbConnection.manager.insert(Discount, {
|
||||
id: "test-discount",
|
||||
code: "TESTING",
|
||||
rule_id: "test-discount-rule",
|
||||
is_dynamic: false,
|
||||
is_disabled: false,
|
||||
ends_at: new Date(),
|
||||
usage_limit: 10,
|
||||
valid_duration: "P1D",
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("Removes ends_at, valid_duration and usage_limit when fields are updated with null", async () => {
|
||||
const api = useApi()
|
||||
|
||||
await api
|
||||
.post(
|
||||
"/admin/discounts/test-discount",
|
||||
{
|
||||
ends_at: null,
|
||||
valid_duration: null,
|
||||
usage_limit: null,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
const resultingDiscount = await api.get(
|
||||
"/admin/discounts/test-discount",
|
||||
{ headers: { Authorization: "Bearer test_token" } }
|
||||
)
|
||||
|
||||
expect(resultingDiscount.status).toEqual(200)
|
||||
expect(resultingDiscount.data.discount).toEqual(
|
||||
expect.objectContaining({
|
||||
ends_at: null,
|
||||
valid_duration: null,
|
||||
usage_limit: null,
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe("testing for soft-deletion + uniqueness on discount codes", () => {
|
||||
let manager
|
||||
beforeEach(async () => {
|
||||
|
||||
Reference in New Issue
Block a user