feat: Add discountable flag to product (#329)
This commit is contained in:
committed by
GitHub
parent
821d8be733
commit
6053c4a8dd
@@ -28,7 +28,6 @@ describe("/admin/discounts", () => {
|
||||
|
||||
describe("POST /admin/discounts", () => {
|
||||
beforeEach(async () => {
|
||||
const manager = dbConnection.manager;
|
||||
try {
|
||||
await adminSeeder(dbConnection);
|
||||
} catch (err) {
|
||||
@@ -105,8 +104,9 @@ describe("/admin/discounts", () => {
|
||||
});
|
||||
|
||||
describe("testing for soft-deletion + uniqueness on discount codes", () => {
|
||||
const manager = dbConnection.manager;
|
||||
let manager;
|
||||
beforeEach(async () => {
|
||||
manager = dbConnection.manager;
|
||||
try {
|
||||
await adminSeeder(dbConnection);
|
||||
await manager.insert(DiscountRule, {
|
||||
@@ -120,6 +120,8 @@ describe("/admin/discounts", () => {
|
||||
id: "test-discount",
|
||||
code: "TESTING",
|
||||
rule_id: "test-discount-rule",
|
||||
is_dynamic: false,
|
||||
is_disabled: false,
|
||||
});
|
||||
} catch (err) {
|
||||
throw err;
|
||||
@@ -127,6 +129,7 @@ describe("/admin/discounts", () => {
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
manager = dbConnection.manager;
|
||||
await manager.query(`DELETE FROM "discount"`);
|
||||
await manager.query(`DELETE FROM "discount_rule"`);
|
||||
await manager.query(`DELETE FROM "user"`);
|
||||
@@ -173,7 +176,7 @@ describe("/admin/discounts", () => {
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.data.discount).toEqual(
|
||||
expect.objectContaining({
|
||||
code: "HELLOWORLD",
|
||||
code: "TESTING",
|
||||
usage_limit: 10,
|
||||
})
|
||||
);
|
||||
|
||||
@@ -92,6 +92,8 @@ describe("/admin/products", () => {
|
||||
expect(response.data.product).toEqual(
|
||||
expect.objectContaining({
|
||||
title: "Test product",
|
||||
discountable: true,
|
||||
is_giftcard: false,
|
||||
handle: "test-product",
|
||||
images: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
@@ -148,6 +150,43 @@ describe("/admin/products", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("creates a giftcard", async () => {
|
||||
const api = useApi();
|
||||
|
||||
const payload = {
|
||||
title: "Test Giftcard",
|
||||
is_giftcard: true,
|
||||
description: "test-giftcard-description",
|
||||
options: [{ title: "Denominations" }],
|
||||
variants: [
|
||||
{
|
||||
title: "Test variant",
|
||||
prices: [{ currency_code: "usd", amount: 100 }],
|
||||
options: [{ value: "100" }],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const response = await api
|
||||
.post("/admin/products", payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
|
||||
expect(response.data.product).toEqual(
|
||||
expect.objectContaining({
|
||||
title: "Test Giftcard",
|
||||
discountable: false,
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it("updates a product (update tags, delete collection, delete type, replaces images)", async () => {
|
||||
const api = useApi();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user