merge develop and resolve conflicts
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
let ignore = [`**/dist`];
|
||||
let ignore = [`**/dist`]
|
||||
|
||||
// Jest needs to compile this code, but generally we don't want this copied
|
||||
// to output folders
|
||||
if (process.env.NODE_ENV !== `test`) {
|
||||
ignore.push(`**/__tests__`);
|
||||
ignore.push(`**/__tests__`)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
sourceMaps: true,
|
||||
presets: ["babel-preset-medusa-package"],
|
||||
ignore,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -380,5 +380,198 @@ Array [
|
||||
"weight": null,
|
||||
"width": null,
|
||||
},
|
||||
Object {
|
||||
"collection": Any<Object>,
|
||||
"collection_id": "test-collection1",
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"description": "test-product-description",
|
||||
"discountable": true,
|
||||
"handle": "test-product_filtering_3",
|
||||
"height": null,
|
||||
"hs_code": null,
|
||||
"id": StringMatching /\\^test-\\*/,
|
||||
"images": Array [],
|
||||
"is_giftcard": false,
|
||||
"length": null,
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"options": Any<Array>,
|
||||
"origin_country": null,
|
||||
"profile_id": StringMatching /\\^sp_\\*/,
|
||||
"status": "draft",
|
||||
"subtitle": null,
|
||||
"tags": Any<Array>,
|
||||
"thumbnail": null,
|
||||
"title": "Test product filtering 3",
|
||||
"type": Any<Object>,
|
||||
"type_id": "test-type",
|
||||
"updated_at": Any<String>,
|
||||
"variants": Any<Array>,
|
||||
"weight": null,
|
||||
"width": null,
|
||||
},
|
||||
Object {
|
||||
"collection": Any<Object>,
|
||||
"collection_id": "test-collection1",
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"description": "test-product-description",
|
||||
"discountable": true,
|
||||
"handle": "test-product_filtering_1",
|
||||
"height": null,
|
||||
"hs_code": null,
|
||||
"id": StringMatching /\\^test-\\*/,
|
||||
"images": Array [],
|
||||
"is_giftcard": false,
|
||||
"length": null,
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"options": Any<Array>,
|
||||
"origin_country": null,
|
||||
"profile_id": StringMatching /\\^sp_\\*/,
|
||||
"status": "proposed",
|
||||
"subtitle": null,
|
||||
"tags": Any<Array>,
|
||||
"thumbnail": null,
|
||||
"title": "Test product filtering 1",
|
||||
"type": Any<Object>,
|
||||
"type_id": "test-type",
|
||||
"updated_at": Any<String>,
|
||||
"variants": Any<Array>,
|
||||
"weight": null,
|
||||
"width": null,
|
||||
},
|
||||
Object {
|
||||
"collection": Any<Object>,
|
||||
"collection_id": "test-collection2",
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"description": "test-product-description",
|
||||
"discountable": true,
|
||||
"handle": "test-product_filtering_2",
|
||||
"height": null,
|
||||
"hs_code": null,
|
||||
"id": StringMatching /\\^test-\\*/,
|
||||
"images": Array [],
|
||||
"is_giftcard": false,
|
||||
"length": null,
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"options": Any<Array>,
|
||||
"origin_country": null,
|
||||
"profile_id": StringMatching /\\^sp_\\*/,
|
||||
"status": "published",
|
||||
"subtitle": null,
|
||||
"tags": Any<Array>,
|
||||
"thumbnail": null,
|
||||
"title": "Test product filtering 2",
|
||||
"type": Any<Object>,
|
||||
"type_id": "test-type",
|
||||
"updated_at": Any<String>,
|
||||
"variants": Any<Array>,
|
||||
"weight": null,
|
||||
"width": null,
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`/admin/products GET /admin/products returns a list of products with giftcard in list 1`] = `
|
||||
Array [
|
||||
Object {
|
||||
"collection": null,
|
||||
"collection_id": null,
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"description": "test-giftcard-description",
|
||||
"discountable": false,
|
||||
"handle": "test-giftcard",
|
||||
"height": null,
|
||||
"hs_code": null,
|
||||
"id": StringMatching /\\^prod_\\*/,
|
||||
"images": Array [],
|
||||
"is_giftcard": true,
|
||||
"length": null,
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"options": Array [
|
||||
Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"id": StringMatching /\\^opt_\\*/,
|
||||
"metadata": null,
|
||||
"product_id": StringMatching /\\^prod_\\*/,
|
||||
"title": "Denominations",
|
||||
"updated_at": Any<String>,
|
||||
},
|
||||
],
|
||||
"origin_country": null,
|
||||
"profile_id": StringMatching /\\^sp_\\*/,
|
||||
"status": "draft",
|
||||
"subtitle": null,
|
||||
"tags": Array [],
|
||||
"thumbnail": null,
|
||||
"title": "Test Giftcard",
|
||||
"type": null,
|
||||
"type_id": null,
|
||||
"updated_at": Any<String>,
|
||||
"variants": Array [
|
||||
Object {
|
||||
"allow_backorder": false,
|
||||
"barcode": null,
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"ean": null,
|
||||
"height": null,
|
||||
"hs_code": null,
|
||||
"id": StringMatching /\\^variant_\\*/,
|
||||
"inventory_quantity": 0,
|
||||
"length": null,
|
||||
"manage_inventory": true,
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"options": Array [
|
||||
Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"id": StringMatching /\\^opt_\\*/,
|
||||
"metadata": null,
|
||||
"option_id": StringMatching /\\^opt_\\*/,
|
||||
"updated_at": Any<String>,
|
||||
"value": "100",
|
||||
"variant_id": StringMatching /\\^variant_\\*/,
|
||||
},
|
||||
],
|
||||
"origin_country": null,
|
||||
"prices": Array [
|
||||
Object {
|
||||
"amount": 100,
|
||||
"created_at": Any<String>,
|
||||
"currency_code": "usd",
|
||||
"deleted_at": null,
|
||||
"id": Any<String>,
|
||||
"region_id": null,
|
||||
"sale_amount": null,
|
||||
"updated_at": Any<String>,
|
||||
"variant_id": StringMatching /\\^variant_\\*/,
|
||||
},
|
||||
],
|
||||
"product_id": StringMatching /\\^prod_\\*/,
|
||||
"sku": null,
|
||||
"title": "Test variant",
|
||||
"upc": null,
|
||||
"updated_at": Any<String>,
|
||||
"weight": null,
|
||||
"width": null,
|
||||
},
|
||||
],
|
||||
"weight": null,
|
||||
"width": null,
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
@@ -46,7 +46,35 @@ describe("/admin/products", () => {
|
||||
const api = useApi()
|
||||
|
||||
const res = await api
|
||||
.get("/admin/products?status%5B%5D=null", {
|
||||
.get("/admin/products", {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(res.status).toEqual(200)
|
||||
expect(res.data.products).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-product",
|
||||
status: "draft",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-product1",
|
||||
status: "draft",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("returns a list of all products when no query is provided", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const res = await api
|
||||
.get("/admin/products?q=", {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
@@ -89,7 +117,7 @@ describe("/admin/products", () => {
|
||||
})
|
||||
|
||||
const response = await api
|
||||
.get("/admin/products?status%5B%5D=proposed", {
|
||||
.get("/admin/products?status[]=proposed", {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
@@ -109,6 +137,258 @@ describe("/admin/products", () => {
|
||||
)
|
||||
})
|
||||
|
||||
it("returns a list of products where status is proposed or published", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const notExpected = [
|
||||
expect.objectContaining({ status: "draft" }),
|
||||
expect.objectContaining({ status: "rejected" }),
|
||||
]
|
||||
|
||||
const response = await api
|
||||
.get("/admin/products?status[]=published,proposed", {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.products).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_1",
|
||||
status: "proposed",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_2",
|
||||
status: "published",
|
||||
}),
|
||||
])
|
||||
|
||||
for (const notExpect of notExpected) {
|
||||
expect(response.data.products).toEqual(
|
||||
expect.not.arrayContaining([notExpect])
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
it("returns a list of products in collection", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const notExpected = [
|
||||
expect.objectContaining({ collection_id: "test-collection" }),
|
||||
expect.objectContaining({ collection_id: "test-collection2" }),
|
||||
]
|
||||
|
||||
const response = await api
|
||||
.get("/admin/products?collection_id[]=test-collection1", {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.products).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_1",
|
||||
collection_id: "test-collection1",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_3",
|
||||
collection_id: "test-collection1",
|
||||
}),
|
||||
])
|
||||
|
||||
for (const notExpect of notExpected) {
|
||||
expect(response.data.products).toEqual(
|
||||
expect.not.arrayContaining([notExpect])
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
it("returns a list of products with tags", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const notExpected = [
|
||||
expect.objectContaining({ id: "tag1" }),
|
||||
expect.objectContaining({ id: "tag2" }),
|
||||
expect.objectContaining({ id: "tag4" }),
|
||||
]
|
||||
|
||||
const response = await api
|
||||
.get("/admin/products?tags[]=tag3", {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.products).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_1",
|
||||
tags: [expect.objectContaining({ id: "tag3" })],
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_2",
|
||||
tags: [expect.objectContaining({ id: "tag3" })],
|
||||
}),
|
||||
])
|
||||
for (const product of response.data.products) {
|
||||
for (const notExpect of notExpected) {
|
||||
expect(product.tags).toEqual(expect.not.arrayContaining([notExpect]))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
it("returns a list of products with tags in a collection", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const notExpectedTags = [
|
||||
expect.objectContaining({ id: "tag1" }),
|
||||
expect.objectContaining({ id: "tag2" }),
|
||||
expect.objectContaining({ id: "tag3" }),
|
||||
]
|
||||
|
||||
const notExpectedCollections = [
|
||||
expect.objectContaining({ collection_id: "test-collection" }),
|
||||
expect.objectContaining({ collection_id: "test-collection2" }),
|
||||
]
|
||||
|
||||
const response = await api
|
||||
.get("/admin/products?collection_id[]=test-collection1&tags[]=tag4", {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.products).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_3",
|
||||
collection_id: "test-collection1",
|
||||
tags: [expect.objectContaining({ id: "tag4" })],
|
||||
}),
|
||||
])
|
||||
|
||||
for (const notExpect of notExpectedCollections) {
|
||||
expect(response.data.products).toEqual(
|
||||
expect.not.arrayContaining([notExpect])
|
||||
)
|
||||
}
|
||||
|
||||
for (const product of response.data.products) {
|
||||
for (const notExpect of notExpectedTags) {
|
||||
expect(product.tags).toEqual(expect.not.arrayContaining([notExpect]))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
it("returns a list of products with giftcard in list", 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" }],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
await api
|
||||
.post("/admin/products", payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
const response = await api
|
||||
.get("/admin/products?is_giftcard=true", {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.data.products).toEqual(
|
||||
expect.not.arrayContaining([
|
||||
expect.objectContaining({ is_giftcard: false }),
|
||||
])
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.products).toMatchSnapshot([
|
||||
{
|
||||
title: "Test Giftcard",
|
||||
id: expect.stringMatching(/^prod_*/),
|
||||
is_giftcard: true,
|
||||
description: "test-giftcard-description",
|
||||
profile_id: expect.stringMatching(/^sp_*/),
|
||||
options: [
|
||||
{
|
||||
title: "Denominations",
|
||||
id: expect.stringMatching(/^opt_*/),
|
||||
product_id: expect.stringMatching(/^prod_*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
],
|
||||
|
||||
variants: [
|
||||
{
|
||||
title: "Test variant",
|
||||
id: expect.stringMatching(/^variant_*/),
|
||||
product_id: expect.stringMatching(/^prod_*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
prices: [
|
||||
{
|
||||
id: expect.any(String),
|
||||
currency_code: "usd",
|
||||
amount: 100,
|
||||
variant_id: expect.stringMatching(/^variant_*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
],
|
||||
options: [
|
||||
{
|
||||
id: expect.stringMatching(/^opt_*/),
|
||||
option_id: expect.stringMatching(/^opt_*/),
|
||||
created_at: expect.any(String),
|
||||
variant_id: expect.stringMatching(/^variant_*/),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
it("returns a list of products with child entities", async () => {
|
||||
const api = useApi()
|
||||
|
||||
@@ -306,6 +586,42 @@ describe("/admin/products", () => {
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
{
|
||||
id: expect.stringMatching(/^test-*/),
|
||||
profile_id: expect.stringMatching(/^sp_*/),
|
||||
created_at: expect.any(String),
|
||||
type: expect.any(Object),
|
||||
collection: expect.any(Object),
|
||||
options: expect.any(Array),
|
||||
tags: expect.any(Array),
|
||||
variants: expect.any(Array),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
{
|
||||
id: expect.stringMatching(/^test-*/),
|
||||
profile_id: expect.stringMatching(/^sp_*/),
|
||||
created_at: expect.any(String),
|
||||
type: expect.any(Object),
|
||||
collection: expect.any(Object),
|
||||
options: expect.any(Array),
|
||||
tags: expect.any(Array),
|
||||
variants: expect.any(Array),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
{
|
||||
id: expect.stringMatching(/^test-*/),
|
||||
profile_id: expect.stringMatching(/^sp_*/),
|
||||
created_at: expect.any(String),
|
||||
type: expect.any(Object),
|
||||
collection: expect.any(Object),
|
||||
options: expect.any(Array),
|
||||
tags: expect.any(Array),
|
||||
variants: expect.any(Array),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
@@ -592,6 +908,28 @@ describe("/admin/products", () => {
|
||||
)
|
||||
})
|
||||
|
||||
it("updates product (removes images when empty array included)", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
images: [],
|
||||
}
|
||||
|
||||
const response = await api
|
||||
.post("/admin/products/test-product", payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
expect(response.data.product.images.length).toEqual(0)
|
||||
})
|
||||
|
||||
it("fails to update product with invalid status", async () => {
|
||||
const api = useApi()
|
||||
|
||||
@@ -696,6 +1034,7 @@ describe("/admin/products", () => {
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe("testing for soft-deletion + uniqueness on handles, collection and variant properties", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
|
||||
@@ -17,6 +17,18 @@ Object {
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"options": Array [
|
||||
Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"id": "test-variant-option",
|
||||
"metadata": null,
|
||||
"option_id": "test-option",
|
||||
"updated_at": Any<String>,
|
||||
"value": "Default variant",
|
||||
"variant_id": "test-variant",
|
||||
},
|
||||
],
|
||||
"origin_country": null,
|
||||
"prices": Array [
|
||||
Object {
|
||||
@@ -61,6 +73,18 @@ Object {
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"options": Array [
|
||||
Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"id": "test-variant-option",
|
||||
"metadata": null,
|
||||
"option_id": "test-option",
|
||||
"updated_at": Any<String>,
|
||||
"value": "Default variant",
|
||||
"variant_id": "test-variant",
|
||||
},
|
||||
],
|
||||
"origin_country": null,
|
||||
"prices": Array [
|
||||
Object {
|
||||
|
||||
@@ -70,6 +70,24 @@ describe("/store/carts", () => {
|
||||
expect(getRes.status).toEqual(200)
|
||||
})
|
||||
|
||||
it("fails to create a cart when no region exist", async () => {
|
||||
const api = useApi()
|
||||
|
||||
await dbConnection.manager.query(
|
||||
`UPDATE "country" SET region_id=null WHERE iso_2 = 'us'`
|
||||
)
|
||||
await dbConnection.manager.query(`DELETE from region`)
|
||||
|
||||
try {
|
||||
await api.post("/store/carts")
|
||||
} catch (error) {
|
||||
expect(error.response.status).toEqual(400)
|
||||
expect(error.response.data.message).toEqual(
|
||||
"A region is required to create a cart"
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
it("creates a cart with country", async () => {
|
||||
const api = useApi()
|
||||
|
||||
@@ -141,16 +159,16 @@ describe("/store/carts", () => {
|
||||
expect.assertions(2)
|
||||
const api = useApi()
|
||||
|
||||
try {
|
||||
await api.post("/store/carts/test-cart", {
|
||||
discounts: [{ code: "CREATED" }],
|
||||
let response = await api
|
||||
.post("/store/carts/test-cart", {
|
||||
discounts: [{ code: "SPENT" }],
|
||||
})
|
||||
.catch((error) => {
|
||||
expect(error.response.status).toEqual(400)
|
||||
expect(error.response.data.message).toEqual(
|
||||
"Discount has been used maximum allowed times"
|
||||
)
|
||||
})
|
||||
} catch (error) {
|
||||
expect(error.response.status).toEqual(400)
|
||||
expect(error.response.data.message).toEqual(
|
||||
"Discount has been used maximum allowed times"
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
it("fails to apply expired discount", async () => {
|
||||
|
||||
@@ -1,63 +1,63 @@
|
||||
const path = require("path");
|
||||
const path = require("path")
|
||||
|
||||
const setupServer = require("../../../helpers/setup-server");
|
||||
const { useApi } = require("../../../helpers/use-api");
|
||||
const { initDb, useDb } = require("../../../helpers/use-db");
|
||||
const setupServer = require("../../../helpers/setup-server")
|
||||
const { useApi } = require("../../../helpers/use-api")
|
||||
const { initDb, useDb } = require("../../../helpers/use-db")
|
||||
|
||||
const draftOrderSeeder = require("../../helpers/draft-order-seeder");
|
||||
const draftOrderSeeder = require("../../helpers/draft-order-seeder")
|
||||
|
||||
jest.setTimeout(30000);
|
||||
jest.setTimeout(30000)
|
||||
|
||||
describe("/store/carts (draft-orders)", () => {
|
||||
let medusaProcess;
|
||||
let dbConnection;
|
||||
let medusaProcess
|
||||
let dbConnection
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."));
|
||||
dbConnection = await initDb({ cwd });
|
||||
medusaProcess = await setupServer({ cwd });
|
||||
});
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
medusaProcess = await setupServer({ cwd })
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb();
|
||||
await db.shutdown();
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
|
||||
medusaProcess.kill();
|
||||
});
|
||||
medusaProcess.kill()
|
||||
})
|
||||
|
||||
describe("POST /admin/draft-order", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await draftOrderSeeder(dbConnection);
|
||||
await draftOrderSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
throw err;
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb();
|
||||
await db.teardown();
|
||||
});
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("completes a cart for a draft order thereby creating an order for the draft order", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.post("/store/carts/test-cart/complete-cart", {})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
const createdOrder = await api
|
||||
.get(`/store/orders/${response.data.data.id}`, {})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(createdOrder.data.order.cart_id).toEqual("test-cart");
|
||||
});
|
||||
});
|
||||
});
|
||||
expect(createdOrder.data.order.cart_id).toEqual("test-cart")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,63 +1,63 @@
|
||||
const path = require("path");
|
||||
const { Region, GiftCard } = require("@medusajs/medusa");
|
||||
const path = require("path")
|
||||
const { Region, GiftCard } = require("@medusajs/medusa")
|
||||
|
||||
const setupServer = require("../../../helpers/setup-server");
|
||||
const { useApi } = require("../../../helpers/use-api");
|
||||
const { initDb, useDb } = require("../../../helpers/use-db");
|
||||
const setupServer = require("../../../helpers/setup-server")
|
||||
const { useApi } = require("../../../helpers/use-api")
|
||||
const { initDb, useDb } = require("../../../helpers/use-db")
|
||||
|
||||
jest.setTimeout(30000);
|
||||
jest.setTimeout(30000)
|
||||
|
||||
describe("/store/gift-cards", () => {
|
||||
let medusaProcess;
|
||||
let dbConnection;
|
||||
let medusaProcess
|
||||
let dbConnection
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."));
|
||||
dbConnection = await initDb({ cwd });
|
||||
medusaProcess = await setupServer({ cwd });
|
||||
});
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
medusaProcess = await setupServer({ cwd })
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb();
|
||||
await db.shutdown();
|
||||
medusaProcess.kill();
|
||||
});
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
medusaProcess.kill()
|
||||
})
|
||||
|
||||
describe("GET /store/gift-cards/:code", () => {
|
||||
beforeEach(async () => {
|
||||
const manager = dbConnection.manager;
|
||||
const manager = dbConnection.manager
|
||||
await manager.insert(Region, {
|
||||
id: "region",
|
||||
name: "Test Region",
|
||||
currency_code: "usd",
|
||||
tax_rate: 0,
|
||||
});
|
||||
})
|
||||
await manager.insert(GiftCard, {
|
||||
id: "gift_test",
|
||||
code: "GC_TEST",
|
||||
value: 200,
|
||||
balance: 120,
|
||||
region_id: "region",
|
||||
});
|
||||
});
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb();
|
||||
await db.teardown();
|
||||
});
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("retrieves a gift card", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const response = await api.get("/store/gift-cards/GC_TEST");
|
||||
expect(response.status).toEqual(200);
|
||||
const response = await api.get("/store/gift-cards/GC_TEST")
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.gift_card).toEqual({
|
||||
id: "gift_test",
|
||||
code: "GC_TEST",
|
||||
value: 200,
|
||||
balance: 120,
|
||||
region: expect.any(Object),
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -79,6 +79,9 @@ describe("/store/variants", () => {
|
||||
},
|
||||
],
|
||||
product: expect.any(Object),
|
||||
options: [
|
||||
{ created_at: expect.any(String), updated_at: expect.any(String) },
|
||||
],
|
||||
},
|
||||
],
|
||||
})
|
||||
@@ -127,6 +130,9 @@ describe("/store/variants", () => {
|
||||
},
|
||||
],
|
||||
product: expect.any(Object),
|
||||
options: [
|
||||
{ created_at: expect.any(String), updated_at: expect.any(String) },
|
||||
],
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,94 +1,96 @@
|
||||
const path = require("path");
|
||||
const path = require("path")
|
||||
|
||||
const { ReturnReason } = require("@medusajs/medusa");
|
||||
const { ReturnReason } = require("@medusajs/medusa")
|
||||
|
||||
const setupServer = require("../../../helpers/setup-server");
|
||||
const { useApi } = require("../../../helpers/use-api");
|
||||
const { initDb, useDb } = require("../../../helpers/use-db");
|
||||
const setupServer = require("../../../helpers/setup-server")
|
||||
const { useApi } = require("../../../helpers/use-api")
|
||||
const { initDb, useDb } = require("../../../helpers/use-db")
|
||||
|
||||
jest.setTimeout(30000);
|
||||
jest.setTimeout(30000)
|
||||
|
||||
describe("/store/return-reasons", () => {
|
||||
let medusaProcess;
|
||||
let dbConnection;
|
||||
let medusaProcess
|
||||
let dbConnection
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."));
|
||||
dbConnection = await initDb({ cwd });
|
||||
medusaProcess = await setupServer({ cwd });
|
||||
});
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
medusaProcess = await setupServer({ cwd })
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb();
|
||||
await db.shutdown();
|
||||
medusaProcess.kill();
|
||||
});
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
medusaProcess.kill()
|
||||
})
|
||||
|
||||
describe("GET /store/return-reasons", () => {
|
||||
let rrId;
|
||||
let rrId_1;
|
||||
let rrId_2;
|
||||
let rrId
|
||||
let rrId_1
|
||||
let rrId_2
|
||||
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
const created = dbConnection.manager.create(ReturnReason, {
|
||||
value: "wrong_size",
|
||||
label: "Wrong size",
|
||||
});
|
||||
})
|
||||
|
||||
const result = await dbConnection.manager.save(created);
|
||||
rrId = result.id;
|
||||
const result = await dbConnection.manager.save(created)
|
||||
rrId = result.id
|
||||
|
||||
const created_child = dbConnection.manager.create(ReturnReason, {
|
||||
value: "too_big",
|
||||
label: "Too Big",
|
||||
parent_return_reason_id: rrId
|
||||
});
|
||||
parent_return_reason_id: rrId,
|
||||
})
|
||||
|
||||
const result_child = await dbConnection.manager.save(created_child);
|
||||
rrId_1 = result_child.id;
|
||||
const result_child = await dbConnection.manager.save(created_child)
|
||||
rrId_1 = result_child.id
|
||||
|
||||
const created_2 = dbConnection.manager.create(ReturnReason, {
|
||||
value: "too_big_1",
|
||||
label: "Too Big 1",
|
||||
});
|
||||
})
|
||||
|
||||
const result_2 = await dbConnection.manager.save(created_2);
|
||||
rrId_2 = result_2.id;
|
||||
const result_2 = await dbConnection.manager.save(created_2)
|
||||
rrId_2 = result_2.id
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
throw err;
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb();
|
||||
await db.teardown();
|
||||
});
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("list return reasons", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const response = await api.get("/store/return-reasons").catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
expect(response.data.return_reasons).toEqual([
|
||||
expect.objectContaining({
|
||||
id: rrId,
|
||||
value: "wrong_size",
|
||||
return_reason_children:[expect.objectContaining({
|
||||
id: rrId_1,
|
||||
value: "too_big",
|
||||
}),]
|
||||
return_reason_children: [
|
||||
expect.objectContaining({
|
||||
id: rrId_1,
|
||||
value: "too_big",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: rrId_2,
|
||||
value: "too_big_1",
|
||||
}),
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const path = require("path");
|
||||
const path = require("path")
|
||||
const {
|
||||
Region,
|
||||
ReturnReason,
|
||||
@@ -12,56 +12,56 @@ const {
|
||||
LineItem,
|
||||
Discount,
|
||||
DiscountRule,
|
||||
} = require("@medusajs/medusa");
|
||||
} = require("@medusajs/medusa")
|
||||
|
||||
const setupServer = require("../../../helpers/setup-server");
|
||||
const { useApi } = require("../../../helpers/use-api");
|
||||
const { initDb, useDb } = require("../../../helpers/use-db");
|
||||
const setupServer = require("../../../helpers/setup-server")
|
||||
const { useApi } = require("../../../helpers/use-api")
|
||||
const { initDb, useDb } = require("../../../helpers/use-db")
|
||||
|
||||
jest.setTimeout(30000);
|
||||
jest.setTimeout(30000)
|
||||
|
||||
describe("/store/carts", () => {
|
||||
let medusaProcess;
|
||||
let dbConnection;
|
||||
let medusaProcess
|
||||
let dbConnection
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."));
|
||||
dbConnection = await initDb({ cwd });
|
||||
medusaProcess = await setupServer({ cwd });
|
||||
});
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
medusaProcess = await setupServer({ cwd })
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb();
|
||||
await db.shutdown();
|
||||
medusaProcess.kill();
|
||||
});
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
medusaProcess.kill()
|
||||
})
|
||||
|
||||
describe("POST /store/returns", () => {
|
||||
let rrId;
|
||||
let rrId_child;
|
||||
let rrResult;
|
||||
let rrId
|
||||
let rrId_child
|
||||
let rrResult
|
||||
|
||||
beforeEach(async () => {
|
||||
const manager = dbConnection.manager;
|
||||
const manager = dbConnection.manager
|
||||
await manager.query(
|
||||
`ALTER SEQUENCE order_display_id_seq RESTART WITH 111`
|
||||
);
|
||||
)
|
||||
|
||||
const defaultProfile = await manager.findOne(ShippingProfile, {
|
||||
type: "default",
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
await manager.insert(Region, {
|
||||
id: "region",
|
||||
name: "Test Region",
|
||||
currency_code: "usd",
|
||||
tax_rate: 0,
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
await manager.insert(Customer, {
|
||||
id: "cus_1234",
|
||||
email: "test@email.com",
|
||||
});
|
||||
})
|
||||
|
||||
await manager.insert(Order, {
|
||||
id: "order_test",
|
||||
@@ -71,7 +71,7 @@ describe("/store/carts", () => {
|
||||
region_id: "region",
|
||||
tax_rate: 0,
|
||||
currency_code: "usd",
|
||||
});
|
||||
})
|
||||
|
||||
await manager.insert(DiscountRule, {
|
||||
id: "discount_rule_id",
|
||||
@@ -79,7 +79,7 @@ describe("/store/carts", () => {
|
||||
value: 10,
|
||||
allocation: "total",
|
||||
type: "percentage",
|
||||
});
|
||||
})
|
||||
|
||||
const d = manager.create(Discount, {
|
||||
id: "test-discount",
|
||||
@@ -87,9 +87,9 @@ describe("/store/carts", () => {
|
||||
is_dynamic: false,
|
||||
is_disabled: false,
|
||||
rule_id: "discount_rule_id",
|
||||
});
|
||||
})
|
||||
|
||||
await manager.save(d);
|
||||
await manager.save(d)
|
||||
|
||||
const ord = manager.create(Order, {
|
||||
id: "order_with_discount",
|
||||
@@ -99,18 +99,18 @@ describe("/store/carts", () => {
|
||||
region_id: "region",
|
||||
tax_rate: 0,
|
||||
currency_code: "usd",
|
||||
});
|
||||
})
|
||||
|
||||
ord.discounts = [d];
|
||||
ord.discounts = [d]
|
||||
|
||||
await manager.save(ord);
|
||||
await manager.save(ord)
|
||||
|
||||
await manager.insert(Product, {
|
||||
id: "test-product",
|
||||
title: "test product",
|
||||
profile_id: defaultProfile.id,
|
||||
options: [{ id: "test-option", title: "Size" }],
|
||||
});
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariant, {
|
||||
id: "test-variant",
|
||||
@@ -123,7 +123,7 @@ describe("/store/carts", () => {
|
||||
value: "Size",
|
||||
},
|
||||
],
|
||||
});
|
||||
})
|
||||
|
||||
await manager.insert(LineItem, {
|
||||
id: "test-item",
|
||||
@@ -135,7 +135,7 @@ describe("/store/carts", () => {
|
||||
unit_price: 8000,
|
||||
quantity: 1,
|
||||
variant_id: "test-variant",
|
||||
});
|
||||
})
|
||||
|
||||
await manager.insert(ShippingOption, {
|
||||
id: "test-option",
|
||||
@@ -147,35 +147,35 @@ describe("/store/carts", () => {
|
||||
price_type: "flat_rate",
|
||||
amount: 1000,
|
||||
is_return: true,
|
||||
});
|
||||
})
|
||||
|
||||
const created = dbConnection.manager.create(ReturnReason, {
|
||||
value: "wrong_size",
|
||||
label: "Wrong Size",
|
||||
});
|
||||
const result = await dbConnection.manager.save(created);
|
||||
})
|
||||
const result = await dbConnection.manager.save(created)
|
||||
|
||||
rrResult = result
|
||||
rrId = result.id;
|
||||
rrId = result.id
|
||||
|
||||
const created_1 = dbConnection.manager.create(ReturnReason, {
|
||||
value: "too_big",
|
||||
label: "Too Big",
|
||||
parent_return_reason_id: rrId,
|
||||
});
|
||||
})
|
||||
|
||||
const result_1 = await dbConnection.manager.save(created_1);
|
||||
const result_1 = await dbConnection.manager.save(created_1)
|
||||
|
||||
rrId_child = result_1.id;
|
||||
});
|
||||
rrId_child = result_1.id
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb();
|
||||
await db.teardown();
|
||||
});
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("creates a return", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.post("/store/returns", {
|
||||
@@ -188,16 +188,16 @@ describe("/store/carts", () => {
|
||||
],
|
||||
})
|
||||
.catch((err) => {
|
||||
return err.response;
|
||||
});
|
||||
expect(response.status).toEqual(200);
|
||||
return err.response
|
||||
})
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
expect(response.data.return.refund_amount).toEqual(8000);
|
||||
});
|
||||
expect(response.data.return.refund_amount).toEqual(8000)
|
||||
})
|
||||
|
||||
it("failes to create a return with a reason category", async () => {
|
||||
const api = useApi();
|
||||
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.post("/store/returns", {
|
||||
order_id: "order_test",
|
||||
@@ -211,17 +211,18 @@ describe("/store/carts", () => {
|
||||
],
|
||||
})
|
||||
.catch((err) => {
|
||||
return err.response;
|
||||
});
|
||||
return err.response
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(400);
|
||||
expect(response.data.message).toEqual('Cannot apply return reason category')
|
||||
|
||||
});
|
||||
expect(response.status).toEqual(400)
|
||||
expect(response.data.message).toEqual(
|
||||
"Cannot apply return reason category"
|
||||
)
|
||||
})
|
||||
|
||||
it("creates a return with reasons", async () => {
|
||||
const api = useApi();
|
||||
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.post("/store/returns", {
|
||||
order_id: "order_test",
|
||||
@@ -236,28 +237,28 @@ describe("/store/carts", () => {
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err.response)
|
||||
return err.response;
|
||||
});
|
||||
expect(response.status).toEqual(200);
|
||||
return err.response
|
||||
})
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
expect(response.data.return.items).toEqual([
|
||||
expect.objectContaining({
|
||||
reason_id: rrId_child,
|
||||
note: "TOO small",
|
||||
}),
|
||||
]);
|
||||
});
|
||||
])
|
||||
})
|
||||
|
||||
it("creates a return with discount and non-discountable item", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
await dbConnection.manager.query(
|
||||
`UPDATE line_item set allow_discounts=false where id='test-item'`
|
||||
);
|
||||
)
|
||||
|
||||
await dbConnection.manager.query(
|
||||
`UPDATE line_item set order_id='order_with_discount' where id='test-item'`
|
||||
);
|
||||
)
|
||||
|
||||
const response = await api
|
||||
.post("/store/returns", {
|
||||
@@ -270,15 +271,15 @@ describe("/store/carts", () => {
|
||||
],
|
||||
})
|
||||
.catch((err) => {
|
||||
return err.response;
|
||||
});
|
||||
return err.response
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.data.return.refund_amount).toEqual(8000);
|
||||
});
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.return.refund_amount).toEqual(8000)
|
||||
})
|
||||
|
||||
it("creates a return with shipping method", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.post("/store/returns", {
|
||||
@@ -294,12 +295,11 @@ describe("/store/carts", () => {
|
||||
],
|
||||
})
|
||||
.catch((err) => {
|
||||
return err.response;
|
||||
});
|
||||
expect(response.status).toEqual(200);
|
||||
return err.response
|
||||
})
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
expect(response.data.return.refund_amount).toEqual(7000);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
expect(response.data.return.refund_amount).toEqual(7000)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
const { useApi } = require("../../helpers/use-api");
|
||||
const { useApi } = require("../../helpers/use-api")
|
||||
|
||||
const header = {
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const resolveCall = async (path, payload, header) => {
|
||||
const api = useApi();
|
||||
let res;
|
||||
const api = useApi()
|
||||
let res
|
||||
try {
|
||||
const resp = await api.post(path, payload, header);
|
||||
res = resp.status;
|
||||
const resp = await api.post(path, payload, header)
|
||||
res = resp.status
|
||||
} catch (expectedException) {
|
||||
try {
|
||||
res = expectedException.response.status;
|
||||
res = expectedException.response.status
|
||||
} catch (_) {
|
||||
console.error(expectedException);
|
||||
console.error(expectedException)
|
||||
}
|
||||
}
|
||||
return res;
|
||||
};
|
||||
return res
|
||||
}
|
||||
|
||||
const determineFail = (actual, expected, path) => {
|
||||
if (expected !== actual) {
|
||||
console.log(`failed at path : ${path}`);
|
||||
console.log(`failed at path : ${path}`)
|
||||
}
|
||||
expect(actual).toEqual(expected);
|
||||
};
|
||||
expect(actual).toEqual(expected)
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows you to wrap a Call function so that you may reuse some input values.
|
||||
@@ -36,8 +36,8 @@ const determineFail = (actual, expected, path) => {
|
||||
* @returns
|
||||
*/
|
||||
module.exports.partial = function (fun, input = {}) {
|
||||
return async (remaining) => await fun({ ...remaining, ...input });
|
||||
};
|
||||
return async (remaining) => await fun({ ...remaining, ...input })
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows you to assert a specific code result from a POST call.
|
||||
@@ -51,9 +51,9 @@ module.exports.expectPostCallToReturn = async function (
|
||||
payload: {},
|
||||
}
|
||||
) {
|
||||
const res = await resolveCall(input.path, input.payload, header);
|
||||
determineFail(res, input.code, input.path);
|
||||
};
|
||||
const res = await resolveCall(input.path, input.payload, header)
|
||||
determineFail(res, input.code, input.path)
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows you to assert a specific code result from multiple POST
|
||||
@@ -76,10 +76,10 @@ module.exports.expectAllPostCallsToReturn = async function (
|
||||
input.pathf(i),
|
||||
input.payloadf ? input.payloadf(i) : {},
|
||||
header
|
||||
);
|
||||
determineFail(res, input.code, input.pathf(i));
|
||||
)
|
||||
determineFail(res, input.code, input.pathf(i))
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows you to retrieve a specific object the response
|
||||
@@ -92,9 +92,9 @@ module.exports.expectAllPostCallsToReturn = async function (
|
||||
* to the get parameter provided.
|
||||
*/
|
||||
module.exports.callGet = async function ({ path, get }) {
|
||||
const api = useApi();
|
||||
const res = await api.get(path, header);
|
||||
const api = useApi()
|
||||
const res = await api.get(path, header)
|
||||
|
||||
determineFail(res.status, 200, path);
|
||||
return res?.data[get];
|
||||
};
|
||||
determineFail(res.status, 200, path)
|
||||
return res?.data[get]
|
||||
}
|
||||
|
||||
@@ -108,6 +108,28 @@ module.exports = async (connection, data = {}) => {
|
||||
tenPercent.rule = tenPercentRule
|
||||
await manager.save(tenPercent)
|
||||
|
||||
const dUsageLimit = await manager.create(Discount, {
|
||||
id: "test-discount-usage-limit",
|
||||
code: "SPENT",
|
||||
is_dynamic: false,
|
||||
is_disabled: false,
|
||||
usage_limit: 10,
|
||||
usage_count: 10,
|
||||
})
|
||||
|
||||
const drUsage = await manager.create(DiscountRule, {
|
||||
id: "test-discount-rule-usage-limit",
|
||||
description: "Created",
|
||||
type: "fixed",
|
||||
value: 10000,
|
||||
allocation: "total",
|
||||
})
|
||||
|
||||
dUsageLimit.rule = drUsage
|
||||
dUsageLimit.regions = [r]
|
||||
|
||||
await manager.save(dUsageLimit)
|
||||
|
||||
const d = await manager.create(Discount, {
|
||||
id: "test-discount",
|
||||
code: "CREATED",
|
||||
|
||||
@@ -4,10 +4,10 @@ const {
|
||||
LineItem,
|
||||
Fulfillment,
|
||||
Return,
|
||||
} = require("@medusajs/medusa");
|
||||
} = require("@medusajs/medusa")
|
||||
|
||||
module.exports = async (connection, data = {}) => {
|
||||
const manager = connection.manager;
|
||||
const manager = connection.manager
|
||||
|
||||
let orderWithClaim = manager.create(Order, {
|
||||
id: "order-with-claim",
|
||||
@@ -40,9 +40,9 @@ module.exports = async (connection, data = {}) => {
|
||||
],
|
||||
items: [],
|
||||
...data,
|
||||
});
|
||||
})
|
||||
|
||||
await manager.save(orderWithClaim);
|
||||
await manager.save(orderWithClaim)
|
||||
|
||||
const li = manager.create(LineItem, {
|
||||
id: "test-item-co-2",
|
||||
@@ -54,9 +54,9 @@ module.exports = async (connection, data = {}) => {
|
||||
quantity: 1,
|
||||
variant_id: "test-variant",
|
||||
order_id: orderWithClaim.id,
|
||||
});
|
||||
})
|
||||
|
||||
await manager.save(li);
|
||||
await manager.save(li)
|
||||
|
||||
const li2 = manager.create(LineItem, {
|
||||
id: "test-item-co-3",
|
||||
@@ -68,9 +68,9 @@ module.exports = async (connection, data = {}) => {
|
||||
quantity: 4,
|
||||
variant_id: "test-variant",
|
||||
order_id: orderWithClaim.id,
|
||||
});
|
||||
})
|
||||
|
||||
await manager.save(li2);
|
||||
await manager.save(li2)
|
||||
|
||||
const claimWithFulfillment = manager.create(ClaimOrder, {
|
||||
id: "claim-w-f",
|
||||
@@ -79,23 +79,23 @@ module.exports = async (connection, data = {}) => {
|
||||
fulfillment_status: "not_fulfilled",
|
||||
order_id: "order-with-claim",
|
||||
...data,
|
||||
});
|
||||
})
|
||||
|
||||
const ful1 = manager.create(Fulfillment, {
|
||||
id: "fulfillment-co-1",
|
||||
data: {},
|
||||
provider_id: "test-ful",
|
||||
});
|
||||
})
|
||||
|
||||
const ful2 = manager.create(Fulfillment, {
|
||||
id: "fulfillment-co-2",
|
||||
data: {},
|
||||
provider_id: "test-ful",
|
||||
});
|
||||
})
|
||||
|
||||
claimWithFulfillment.fulfillments = [ful1, ful2];
|
||||
claimWithFulfillment.fulfillments = [ful1, ful2]
|
||||
|
||||
await manager.save(claimWithFulfillment);
|
||||
await manager.save(claimWithFulfillment)
|
||||
|
||||
const claimWithReturn = manager.create(ClaimOrder, {
|
||||
id: "claim-w-r",
|
||||
@@ -104,9 +104,9 @@ module.exports = async (connection, data = {}) => {
|
||||
fulfillment_status: "not_fulfilled",
|
||||
order_id: "order-with-claim",
|
||||
...data,
|
||||
});
|
||||
})
|
||||
|
||||
await manager.save(claimWithReturn);
|
||||
await manager.save(claimWithReturn)
|
||||
|
||||
await manager.insert(Return, {
|
||||
id: "return-id-2",
|
||||
@@ -114,5 +114,5 @@ module.exports = async (connection, data = {}) => {
|
||||
status: "requested",
|
||||
refund_amount: 0,
|
||||
data: {},
|
||||
});
|
||||
};
|
||||
})
|
||||
}
|
||||
|
||||
@@ -14,35 +14,35 @@ const {
|
||||
Discount,
|
||||
DiscountRule,
|
||||
Payment,
|
||||
} = require("@medusajs/medusa");
|
||||
} = require("@medusajs/medusa")
|
||||
|
||||
module.exports = async (connection, data = {}) => {
|
||||
const manager = connection.manager;
|
||||
const manager = connection.manager
|
||||
|
||||
const defaultProfile = await manager.findOne(ShippingProfile, {
|
||||
type: "default",
|
||||
});
|
||||
})
|
||||
|
||||
await manager.insert(Product, {
|
||||
id: "test-product",
|
||||
title: "test product",
|
||||
profile_id: defaultProfile.id,
|
||||
options: [{ id: "test-option", title: "Size" }],
|
||||
});
|
||||
})
|
||||
|
||||
await manager.insert(Address, {
|
||||
id: "oli-shipping",
|
||||
first_name: "oli",
|
||||
last_name: "test",
|
||||
country_code: "us",
|
||||
});
|
||||
})
|
||||
|
||||
await manager.insert(Product, {
|
||||
id: "test-product-2",
|
||||
title: "test product 2",
|
||||
profile_id: defaultProfile.id,
|
||||
options: [{ id: "test-option-color", title: "Color" }],
|
||||
});
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariant, {
|
||||
id: "test-variant",
|
||||
@@ -55,7 +55,7 @@ module.exports = async (connection, data = {}) => {
|
||||
value: "Size",
|
||||
},
|
||||
],
|
||||
});
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariant, {
|
||||
id: "test-variant-2",
|
||||
@@ -68,22 +68,22 @@ module.exports = async (connection, data = {}) => {
|
||||
value: "Color",
|
||||
},
|
||||
],
|
||||
});
|
||||
})
|
||||
|
||||
const ma = manager.create(MoneyAmount, {
|
||||
variant_id: "test-variant",
|
||||
currency_code: "usd",
|
||||
amount: 8000,
|
||||
});
|
||||
await manager.save(ma);
|
||||
})
|
||||
await manager.save(ma)
|
||||
|
||||
const ma2 = manager.create(MoneyAmount, {
|
||||
variant_id: "test-variant-2",
|
||||
currency_code: "usd",
|
||||
amount: 10000,
|
||||
});
|
||||
})
|
||||
|
||||
await manager.save(ma2);
|
||||
await manager.save(ma2)
|
||||
|
||||
await manager.insert(Region, {
|
||||
id: "test-region",
|
||||
@@ -96,7 +96,7 @@ module.exports = async (connection, data = {}) => {
|
||||
is_installed: true,
|
||||
},
|
||||
],
|
||||
});
|
||||
})
|
||||
|
||||
await manager.insert(Region, {
|
||||
id: "test-region-2",
|
||||
@@ -109,7 +109,7 @@ module.exports = async (connection, data = {}) => {
|
||||
is_installed: true,
|
||||
},
|
||||
],
|
||||
});
|
||||
})
|
||||
|
||||
await manager.insert(DiscountRule, {
|
||||
id: "discount_rule_id",
|
||||
@@ -117,7 +117,7 @@ module.exports = async (connection, data = {}) => {
|
||||
value: 10,
|
||||
allocation: "total",
|
||||
type: "percentage",
|
||||
});
|
||||
})
|
||||
|
||||
const d = manager.create(Discount, {
|
||||
id: "test-discount",
|
||||
@@ -125,7 +125,7 @@ module.exports = async (connection, data = {}) => {
|
||||
is_dynamic: false,
|
||||
is_disabled: false,
|
||||
rule_id: "discount_rule_id",
|
||||
});
|
||||
})
|
||||
|
||||
d.regions = [
|
||||
{
|
||||
@@ -134,27 +134,27 @@ module.exports = async (connection, data = {}) => {
|
||||
currency_code: "usd",
|
||||
tax_rate: 0,
|
||||
},
|
||||
];
|
||||
]
|
||||
|
||||
await manager.save(d);
|
||||
await manager.save(d)
|
||||
|
||||
await manager.query(
|
||||
`UPDATE "country" SET region_id='test-region' WHERE iso_2 = 'us'`
|
||||
);
|
||||
)
|
||||
|
||||
await manager.query(
|
||||
`UPDATE "country" SET region_id='test-region-2' WHERE iso_2 = 'de'`
|
||||
);
|
||||
)
|
||||
|
||||
await manager.insert(Customer, {
|
||||
id: "oli-test",
|
||||
email: "oli@test.dk",
|
||||
});
|
||||
})
|
||||
|
||||
await manager.insert(Customer, {
|
||||
id: "lebron-james",
|
||||
email: "lebron@james.com",
|
||||
});
|
||||
})
|
||||
|
||||
await manager.insert(ShippingOption, {
|
||||
id: "test-option",
|
||||
@@ -165,7 +165,7 @@ module.exports = async (connection, data = {}) => {
|
||||
price_type: "flat_rate",
|
||||
amount: 1000,
|
||||
data: {},
|
||||
});
|
||||
})
|
||||
|
||||
await manager.insert(ShippingOption, {
|
||||
id: "test-option-req",
|
||||
@@ -176,14 +176,14 @@ module.exports = async (connection, data = {}) => {
|
||||
price_type: "flat_rate",
|
||||
amount: 1000,
|
||||
data: {},
|
||||
});
|
||||
})
|
||||
|
||||
await manager.insert(ShippingOptionRequirement, {
|
||||
id: "option-req",
|
||||
shipping_option_id: "test-option-req",
|
||||
type: "min_subtotal",
|
||||
amount: 10,
|
||||
});
|
||||
})
|
||||
|
||||
const c = manager.create(Cart, {
|
||||
id: "test-cart",
|
||||
@@ -207,7 +207,7 @@ module.exports = async (connection, data = {}) => {
|
||||
],
|
||||
type: "draft_order",
|
||||
metadata: { draft_order_id: "test-draft-order" },
|
||||
});
|
||||
})
|
||||
|
||||
const pay = manager.create(Payment, {
|
||||
id: "test-payment",
|
||||
@@ -216,13 +216,13 @@ module.exports = async (connection, data = {}) => {
|
||||
amount_refunded: 0,
|
||||
provider_id: "test-pay",
|
||||
data: {},
|
||||
});
|
||||
})
|
||||
|
||||
await manager.save(pay);
|
||||
await manager.save(pay)
|
||||
|
||||
c.payment = pay;
|
||||
c.payment = pay
|
||||
|
||||
await manager.save(c);
|
||||
await manager.save(c)
|
||||
|
||||
await manager.insert(PaymentSession, {
|
||||
id: "test-session",
|
||||
@@ -231,7 +231,7 @@ module.exports = async (connection, data = {}) => {
|
||||
is_selected: true,
|
||||
data: {},
|
||||
status: "authorized",
|
||||
});
|
||||
})
|
||||
|
||||
const draftOrder = manager.create(DraftOrder, {
|
||||
id: "test-draft-order",
|
||||
@@ -255,7 +255,7 @@ module.exports = async (connection, data = {}) => {
|
||||
region_id: "test-region",
|
||||
discounts: [],
|
||||
...data,
|
||||
});
|
||||
})
|
||||
|
||||
await manager.save(draftOrder);
|
||||
};
|
||||
await manager.save(draftOrder)
|
||||
}
|
||||
|
||||
@@ -12,21 +12,21 @@ const {
|
||||
Payment,
|
||||
Order,
|
||||
Swap,
|
||||
} = require("@medusajs/medusa");
|
||||
} = require("@medusajs/medusa")
|
||||
|
||||
module.exports = async (connection, data = {}) => {
|
||||
const manager = connection.manager;
|
||||
const manager = connection.manager
|
||||
|
||||
const defaultProfile = await manager.findOne(ShippingProfile, {
|
||||
type: "default",
|
||||
});
|
||||
})
|
||||
|
||||
await manager.insert(Product, {
|
||||
id: "test-product",
|
||||
title: "test product",
|
||||
profile_id: defaultProfile.id,
|
||||
options: [{ id: "test-option", title: "Size" }],
|
||||
});
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariant, {
|
||||
id: "test-variant",
|
||||
@@ -39,7 +39,7 @@ module.exports = async (connection, data = {}) => {
|
||||
value: "Size",
|
||||
},
|
||||
],
|
||||
});
|
||||
})
|
||||
|
||||
await manager.insert(ProductVariant, {
|
||||
id: "test-variant-2",
|
||||
@@ -52,37 +52,37 @@ module.exports = async (connection, data = {}) => {
|
||||
value: "Large",
|
||||
},
|
||||
],
|
||||
});
|
||||
})
|
||||
|
||||
const ma2 = manager.create(MoneyAmount, {
|
||||
variant_id: "test-variant-2",
|
||||
currency_code: "usd",
|
||||
amount: 8000,
|
||||
});
|
||||
await manager.save(ma2);
|
||||
})
|
||||
await manager.save(ma2)
|
||||
|
||||
const ma = manager.create(MoneyAmount, {
|
||||
variant_id: "test-variant",
|
||||
currency_code: "usd",
|
||||
amount: 8000,
|
||||
});
|
||||
await manager.save(ma);
|
||||
})
|
||||
await manager.save(ma)
|
||||
|
||||
await manager.insert(Region, {
|
||||
id: "test-region",
|
||||
name: "Test Region",
|
||||
currency_code: "usd",
|
||||
tax_rate: 0,
|
||||
});
|
||||
})
|
||||
|
||||
await manager.query(
|
||||
`UPDATE "country" SET region_id='test-region' WHERE iso_2 = 'us'`
|
||||
);
|
||||
)
|
||||
|
||||
await manager.insert(Customer, {
|
||||
id: "test-customer",
|
||||
email: "test@email.com",
|
||||
});
|
||||
})
|
||||
|
||||
await manager.insert(ShippingOption, {
|
||||
id: "test-option",
|
||||
@@ -93,7 +93,7 @@ module.exports = async (connection, data = {}) => {
|
||||
price_type: "flat_rate",
|
||||
amount: 1000,
|
||||
data: {},
|
||||
});
|
||||
})
|
||||
|
||||
await manager.insert(ShippingOption, {
|
||||
id: "test-return-option",
|
||||
@@ -105,7 +105,7 @@ module.exports = async (connection, data = {}) => {
|
||||
price_type: "flat_rate",
|
||||
amount: 1000,
|
||||
is_return: true,
|
||||
});
|
||||
})
|
||||
|
||||
const order = manager.create(Order, {
|
||||
id: "test-order",
|
||||
@@ -157,9 +157,9 @@ module.exports = async (connection, data = {}) => {
|
||||
],
|
||||
items: [],
|
||||
...data,
|
||||
});
|
||||
})
|
||||
|
||||
await manager.save(order);
|
||||
await manager.save(order)
|
||||
|
||||
const li = manager.create(LineItem, {
|
||||
id: "test-item",
|
||||
@@ -172,9 +172,9 @@ module.exports = async (connection, data = {}) => {
|
||||
quantity: 1,
|
||||
variant_id: "test-variant",
|
||||
order_id: "test-order",
|
||||
});
|
||||
})
|
||||
|
||||
await manager.save(li);
|
||||
await manager.save(li)
|
||||
|
||||
await manager.insert(ShippingMethod, {
|
||||
id: "test-method",
|
||||
@@ -183,7 +183,7 @@ module.exports = async (connection, data = {}) => {
|
||||
order_id: "test-order",
|
||||
price: 1000,
|
||||
data: {},
|
||||
});
|
||||
})
|
||||
|
||||
const orderTemplate = () => {
|
||||
return {
|
||||
@@ -195,8 +195,8 @@ module.exports = async (connection, data = {}) => {
|
||||
currency_code: "usd",
|
||||
tax_rate: 0,
|
||||
...data,
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const paymentTemplate = () => {
|
||||
return {
|
||||
@@ -204,8 +204,8 @@ module.exports = async (connection, data = {}) => {
|
||||
currency_code: "usd",
|
||||
provider_id: "test-pay",
|
||||
data: {},
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const orderWithClaim = manager.create(Order, {
|
||||
id: "test-order-w-c",
|
||||
@@ -219,59 +219,59 @@ module.exports = async (connection, data = {}) => {
|
||||
},
|
||||
],
|
||||
...orderTemplate(),
|
||||
});
|
||||
})
|
||||
|
||||
await manager.save(orderWithClaim);
|
||||
await manager.save(orderWithClaim)
|
||||
|
||||
await manager.insert(Payment, {
|
||||
order_id: "test-order-w-c",
|
||||
id: "o-pay1",
|
||||
...paymentTemplate(),
|
||||
});
|
||||
})
|
||||
|
||||
const orderWithSwap = manager.create(Order, {
|
||||
id: "test-order-w-s",
|
||||
...orderTemplate(),
|
||||
});
|
||||
})
|
||||
|
||||
await manager.save(orderWithSwap);
|
||||
await manager.save(orderWithSwap)
|
||||
|
||||
await manager.insert(Payment, {
|
||||
order_id: "test-order-w-s",
|
||||
id: "o-pay2",
|
||||
...paymentTemplate(),
|
||||
});
|
||||
})
|
||||
|
||||
const swap1 = manager.create(Swap, {
|
||||
id: "swap-1",
|
||||
order_id: "test-order-w-s",
|
||||
fulfillment_status: "not_fulfilled",
|
||||
payment_status: "not_paid",
|
||||
});
|
||||
})
|
||||
|
||||
const pay1 = manager.create(Payment, {
|
||||
id: "pay1",
|
||||
...paymentTemplate(),
|
||||
});
|
||||
})
|
||||
|
||||
swap1.payment = pay1;
|
||||
swap1.payment = pay1
|
||||
|
||||
const swap2 = manager.create(Swap, {
|
||||
id: "swap-2",
|
||||
order_id: "test-order-w-s",
|
||||
fulfillment_status: "not_fulfilled",
|
||||
payment_status: "not_paid",
|
||||
});
|
||||
})
|
||||
|
||||
const pay2 = manager.create(Payment, {
|
||||
id: "pay2",
|
||||
...paymentTemplate(),
|
||||
});
|
||||
})
|
||||
|
||||
swap2.payment = pay2;
|
||||
swap2.payment = pay2
|
||||
|
||||
await manager.save(swap1);
|
||||
await manager.save(swap2);
|
||||
await manager.save(swap1)
|
||||
await manager.save(swap2)
|
||||
|
||||
const orderWithFulfillment = manager.create(Order, {
|
||||
id: "test-order-w-f",
|
||||
@@ -288,15 +288,15 @@ module.exports = async (connection, data = {}) => {
|
||||
},
|
||||
],
|
||||
...orderTemplate(),
|
||||
});
|
||||
})
|
||||
|
||||
await manager.save(orderWithFulfillment);
|
||||
await manager.save(orderWithFulfillment)
|
||||
|
||||
await manager.insert(Payment, {
|
||||
order_id: "test-order-w-f",
|
||||
id: "o-pay3",
|
||||
...paymentTemplate(),
|
||||
});
|
||||
})
|
||||
|
||||
const orderWithReturn = manager.create(Order, {
|
||||
id: "test-order-w-r",
|
||||
@@ -311,13 +311,13 @@ module.exports = async (connection, data = {}) => {
|
||||
},
|
||||
],
|
||||
...orderTemplate(),
|
||||
});
|
||||
})
|
||||
|
||||
await manager.save(orderWithReturn);
|
||||
await manager.save(orderWithReturn)
|
||||
|
||||
await manager.insert(Payment, {
|
||||
order_id: "test-order-w-r",
|
||||
id: "o-pay4",
|
||||
...paymentTemplate(),
|
||||
});
|
||||
};
|
||||
})
|
||||
}
|
||||
|
||||
@@ -25,6 +25,22 @@ module.exports = async (connection, data = {}) => {
|
||||
|
||||
await manager.save(coll)
|
||||
|
||||
const coll1 = manager.create(ProductCollection, {
|
||||
id: "test-collection1",
|
||||
handle: "test-collection1",
|
||||
title: "Test collection 1",
|
||||
})
|
||||
|
||||
await manager.save(coll1)
|
||||
|
||||
const coll2 = manager.create(ProductCollection, {
|
||||
id: "test-collection2",
|
||||
handle: "test-collection2",
|
||||
title: "Test collection 2",
|
||||
})
|
||||
|
||||
await manager.save(coll2)
|
||||
|
||||
const tag = manager.create(ProductTag, {
|
||||
id: "tag1",
|
||||
value: "123",
|
||||
@@ -32,6 +48,20 @@ module.exports = async (connection, data = {}) => {
|
||||
|
||||
await manager.save(tag)
|
||||
|
||||
const tag3 = manager.create(ProductTag, {
|
||||
id: "tag3",
|
||||
value: "123",
|
||||
})
|
||||
|
||||
await manager.save(tag3)
|
||||
|
||||
const tag4 = manager.create(ProductTag, {
|
||||
id: "tag4",
|
||||
value: "123",
|
||||
})
|
||||
|
||||
await manager.save(tag4)
|
||||
|
||||
const type = manager.create(ProductType, {
|
||||
id: "test-type",
|
||||
value: "test-type",
|
||||
@@ -199,4 +229,46 @@ module.exports = async (connection, data = {}) => {
|
||||
})
|
||||
|
||||
await manager.save(variant5)
|
||||
|
||||
const product1 = manager.create(Product, {
|
||||
id: "test-product_filtering_1",
|
||||
handle: "test-product_filtering_1",
|
||||
title: "Test product filtering 1",
|
||||
profile_id: defaultProfile.id,
|
||||
description: "test-product-description",
|
||||
type: { id: "test-type", value: "test-type" },
|
||||
collection_id: "test-collection1",
|
||||
status: "proposed",
|
||||
tags: [{ id: "tag3", value: "123" }],
|
||||
})
|
||||
|
||||
await manager.save(product1)
|
||||
|
||||
const product2 = manager.create(Product, {
|
||||
id: "test-product_filtering_2",
|
||||
handle: "test-product_filtering_2",
|
||||
title: "Test product filtering 2",
|
||||
profile_id: defaultProfile.id,
|
||||
description: "test-product-description",
|
||||
type: { id: "test-type", value: "test-type" },
|
||||
collection_id: "test-collection2",
|
||||
status: "published",
|
||||
tags: [{ id: "tag3", value: "123" }],
|
||||
})
|
||||
|
||||
await manager.save(product2)
|
||||
|
||||
const product3 = manager.create(Product, {
|
||||
id: "test-product_filtering_3",
|
||||
handle: "test-product_filtering_3",
|
||||
title: "Test product filtering 3",
|
||||
profile_id: defaultProfile.id,
|
||||
description: "test-product-description",
|
||||
type: { id: "test-type", value: "test-type" },
|
||||
collection_id: "test-collection1",
|
||||
status: "draft",
|
||||
tags: [{ id: "tag4", value: "1234" }],
|
||||
})
|
||||
|
||||
await manager.save(product3)
|
||||
}
|
||||
|
||||
@@ -13,4 +13,4 @@ module.exports = {
|
||||
],
|
||||
transform: { "^.+\\.[jt]s$": `../../jest-transformer.js` },
|
||||
setupFilesAfterEnv: ["../setup.js"],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -8,15 +8,15 @@
|
||||
"build": "babel src -d dist --extensions \".ts,.js\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/medusa": "1.1.41-dev-1634206968632",
|
||||
"medusa-interfaces": "1.1.23-dev-1634206968632",
|
||||
"@medusajs/medusa": "1.1.41-dev-1634220658423",
|
||||
"medusa-interfaces": "1.1.23-dev-1634220658423",
|
||||
"typeorm": "^0.2.31"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.12.10",
|
||||
"@babel/core": "^7.12.10",
|
||||
"@babel/node": "^7.12.10",
|
||||
"babel-preset-medusa-package": "1.1.15-dev-1634206968632",
|
||||
"babel-preset-medusa-package": "1.1.15-dev-1634220658423",
|
||||
"jest": "^26.6.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { FulfillmentService } from "medusa-interfaces";
|
||||
import { FulfillmentService } from "medusa-interfaces"
|
||||
|
||||
class TestFulService extends FulfillmentService {
|
||||
static identifier = "test-ful";
|
||||
static identifier = "test-ful"
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
super()
|
||||
}
|
||||
|
||||
getFulfillmentOptions() {
|
||||
@@ -12,42 +12,42 @@ class TestFulService extends FulfillmentService {
|
||||
{
|
||||
id: "manual-fulfillment",
|
||||
},
|
||||
];
|
||||
]
|
||||
}
|
||||
|
||||
validateFulfillmentData(data, cart) {
|
||||
return data;
|
||||
return data
|
||||
}
|
||||
|
||||
validateOption(data) {
|
||||
return true;
|
||||
return true
|
||||
}
|
||||
|
||||
canCalculate() {
|
||||
return false;
|
||||
return false
|
||||
}
|
||||
|
||||
calculatePrice() {
|
||||
throw Error("Manual Fulfillment service cannot calculatePrice");
|
||||
throw Error("Manual Fulfillment service cannot calculatePrice")
|
||||
}
|
||||
|
||||
createOrder() {
|
||||
// No data is being sent anywhere
|
||||
return Promise.resolve({});
|
||||
return Promise.resolve({})
|
||||
}
|
||||
|
||||
createReturn() {
|
||||
return Promise.resolve({});
|
||||
return Promise.resolve({})
|
||||
}
|
||||
|
||||
createFulfillment() {
|
||||
// No data is being sent anywhere
|
||||
return Promise.resolve({});
|
||||
return Promise.resolve({})
|
||||
}
|
||||
|
||||
cancelFulfillment() {
|
||||
return Promise.resolve({});
|
||||
return Promise.resolve({})
|
||||
}
|
||||
}
|
||||
|
||||
export default TestFulService;
|
||||
export default TestFulService
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import { NotificationService } from "medusa-interfaces";
|
||||
import { NotificationService } from "medusa-interfaces"
|
||||
|
||||
class TestNotiService extends NotificationService {
|
||||
static identifier = "test-not";
|
||||
static identifier = "test-not"
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
super()
|
||||
}
|
||||
|
||||
async sendNotification() {
|
||||
return Promise.resolve();
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
||||
async resendNotification() {
|
||||
return Promise.resolve();
|
||||
return Promise.resolve()
|
||||
}
|
||||
}
|
||||
|
||||
export default TestNotiService;
|
||||
export default TestNotiService
|
||||
|
||||
@@ -1,59 +1,59 @@
|
||||
import { PaymentService } from "medusa-interfaces";
|
||||
import { PaymentService } from "medusa-interfaces"
|
||||
|
||||
class TestPayService extends PaymentService {
|
||||
static identifier = "test-pay";
|
||||
static identifier = "test-pay"
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
super()
|
||||
}
|
||||
|
||||
async getStatus(paymentData) {
|
||||
return "authorized";
|
||||
return "authorized"
|
||||
}
|
||||
|
||||
async retrieveSavedMethods(customer) {
|
||||
return Promise.resolve([]);
|
||||
return Promise.resolve([])
|
||||
}
|
||||
|
||||
async createPayment() {
|
||||
return {};
|
||||
return {}
|
||||
}
|
||||
|
||||
async retrievePayment(data) {
|
||||
return {};
|
||||
return {}
|
||||
}
|
||||
|
||||
async getPaymentData(sessionData) {
|
||||
return {};
|
||||
return {}
|
||||
}
|
||||
|
||||
async authorizePayment(sessionData, context = {}) {
|
||||
return { data: {}, status: "authorized" };
|
||||
return { data: {}, status: "authorized" }
|
||||
}
|
||||
|
||||
async updatePaymentData(sessionData, update) {
|
||||
return {};
|
||||
return {}
|
||||
}
|
||||
|
||||
async updatePayment(sessionData, cart) {
|
||||
return {};
|
||||
return {}
|
||||
}
|
||||
|
||||
async deletePayment(payment) {
|
||||
return {};
|
||||
return {}
|
||||
}
|
||||
|
||||
async capturePayment(payment) {
|
||||
return {};
|
||||
return {}
|
||||
}
|
||||
|
||||
async refundPayment(payment, amountToRefund) {
|
||||
return {};
|
||||
return {}
|
||||
}
|
||||
|
||||
async cancelPayment(payment) {
|
||||
return {};
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
export default TestPayService;
|
||||
export default TestPayService
|
||||
|
||||
@@ -1223,10 +1223,10 @@
|
||||
"@types/yargs" "^15.0.0"
|
||||
chalk "^4.0.0"
|
||||
|
||||
"@medusajs/medusa-cli@1.1.18-dev-1634206968632":
|
||||
version "1.1.18-dev-1634206968632"
|
||||
resolved "http://localhost:4873/@medusajs%2fmedusa-cli/-/medusa-cli-1.1.18-dev-1634206968632.tgz#26c12ed689f9d0485c14eccdd377b67bff505f90"
|
||||
integrity sha512-oQwdVu2M2v5JRC+gwNXoL/fyGkH6nRaEBDG1rJk0YAmMawMxOIAAd/t1tMK16P69xK4eIUb4fkwX7BpC7kWKiA==
|
||||
"@medusajs/medusa-cli@1.1.18-dev-1634220658423":
|
||||
version "1.1.18-dev-1634220658423"
|
||||
resolved "http://localhost:4873/@medusajs%2fmedusa-cli/-/medusa-cli-1.1.18-dev-1634220658423.tgz#e72313f7749bf0a2c3b8930716f9b84ad09fc939"
|
||||
integrity sha512-EGNKYTXX4JNHrsP8HAuK7XBQ4irL9jLTB5Fr1jS+XH2gx5xNTj1zJpyahNROI8wWIBEu1MmFNdKh4hJm1RfGMQ==
|
||||
dependencies:
|
||||
"@babel/polyfill" "^7.8.7"
|
||||
"@babel/runtime" "^7.9.6"
|
||||
@@ -1244,8 +1244,8 @@
|
||||
is-valid-path "^0.1.1"
|
||||
joi-objectid "^3.0.1"
|
||||
meant "^1.0.1"
|
||||
medusa-core-utils "1.1.22-dev-1634206968632"
|
||||
medusa-telemetry "0.0.5-dev-1634206968632"
|
||||
medusa-core-utils "1.1.22-dev-1634220658423"
|
||||
medusa-telemetry "0.0.5-dev-1634220658423"
|
||||
netrc-parser "^3.1.6"
|
||||
open "^8.0.6"
|
||||
ora "^5.4.1"
|
||||
@@ -1259,13 +1259,13 @@
|
||||
winston "^3.3.3"
|
||||
yargs "^15.3.1"
|
||||
|
||||
"@medusajs/medusa@1.1.41-dev-1634206968632":
|
||||
version "1.1.41-dev-1634206968632"
|
||||
resolved "http://localhost:4873/@medusajs%2fmedusa/-/medusa-1.1.41-dev-1634206968632.tgz#f4fb24416aab594401d4a8de91f2bcd63f4078d9"
|
||||
integrity sha512-3nbKX3vcB1sDCkt9FUs611ZxBrGGWBGArEXwtwHpJ/PScesPE1Gl9y+q8lfnu8NInYD3hw1Tpp4JMaOrfpifgw==
|
||||
"@medusajs/medusa@1.1.41-dev-1634220658423":
|
||||
version "1.1.41-dev-1634220658423"
|
||||
resolved "http://localhost:4873/@medusajs%2fmedusa/-/medusa-1.1.41-dev-1634220658423.tgz#b3b251d0d97734b7c3806253bd49d5b62eef8324"
|
||||
integrity sha512-oqM2vaSoc/k5nID3k32sslIkl1yXwCf4GTGrlywZ/x8BgmYFfTMgPJ8Lr3WrAuh7hwsXrOR2Rj9Bq22cFeKZZQ==
|
||||
dependencies:
|
||||
"@hapi/joi" "^16.1.8"
|
||||
"@medusajs/medusa-cli" "1.1.18-dev-1634206968632"
|
||||
"@medusajs/medusa-cli" "1.1.18-dev-1634220658423"
|
||||
"@types/lodash" "^4.14.168"
|
||||
awilix "^4.2.3"
|
||||
body-parser "^1.19.0"
|
||||
@@ -1287,8 +1287,8 @@
|
||||
joi "^17.3.0"
|
||||
joi-objectid "^3.0.1"
|
||||
jsonwebtoken "^8.5.1"
|
||||
medusa-core-utils "1.1.22-dev-1634206968632"
|
||||
medusa-test-utils "1.1.25-dev-1634206968632"
|
||||
medusa-core-utils "1.1.22-dev-1634220658423"
|
||||
medusa-test-utils "1.1.25-dev-1634220658423"
|
||||
morgan "^1.9.1"
|
||||
multer "^1.4.2"
|
||||
passport "^0.4.0"
|
||||
@@ -1933,10 +1933,10 @@ babel-preset-jest@^26.6.2:
|
||||
babel-plugin-jest-hoist "^26.6.2"
|
||||
babel-preset-current-node-syntax "^1.0.0"
|
||||
|
||||
babel-preset-medusa-package@1.1.15-dev-1634206968632:
|
||||
version "1.1.15-dev-1634206968632"
|
||||
resolved "http://localhost:4873/babel-preset-medusa-package/-/babel-preset-medusa-package-1.1.15-dev-1634206968632.tgz#752d6b645d0d09ad53d955bc823572b8d05ecda6"
|
||||
integrity sha512-AvhdeUwC2uUnMFN9qA4oPDyZ+P0IO+rmiG/Udl7mssh43o3thDATllZSNbRBIwr4jy9M67oj+dbtrO6o8vJoBQ==
|
||||
babel-preset-medusa-package@1.1.15-dev-1634220658423:
|
||||
version "1.1.15-dev-1634220658423"
|
||||
resolved "http://localhost:4873/babel-preset-medusa-package/-/babel-preset-medusa-package-1.1.15-dev-1634220658423.tgz#c8c1251e93d0f1e012acc720a3d60d112ddbbbb1"
|
||||
integrity sha512-1CcmDubw9VByN/flg7NQ+rHu0Vt4RjBycgeXE7s7A9IcMYh1CC7HoHTFYPFpisUE6vU/axiNmbq+43bEbVCdyg==
|
||||
dependencies:
|
||||
"@babel/plugin-proposal-class-properties" "^7.12.1"
|
||||
"@babel/plugin-proposal-decorators" "^7.12.1"
|
||||
@@ -5110,25 +5110,25 @@ media-typer@0.3.0:
|
||||
resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748"
|
||||
integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=
|
||||
|
||||
medusa-core-utils@1.1.22-dev-1634206968632:
|
||||
version "1.1.22-dev-1634206968632"
|
||||
resolved "http://localhost:4873/medusa-core-utils/-/medusa-core-utils-1.1.22-dev-1634206968632.tgz#7eb0e6f95d8bd494aec706aa081ffbba8825e4ba"
|
||||
integrity sha512-htkx9927dyEWdfOXw2xj58O7GPtPaTY5p9JO/Sja6LuN9QaotMPVrOkqy7drHiGtdn3IzjIMq4i7iub2DgJy0w==
|
||||
medusa-core-utils@1.1.22-dev-1634220658423:
|
||||
version "1.1.22-dev-1634220658423"
|
||||
resolved "http://localhost:4873/medusa-core-utils/-/medusa-core-utils-1.1.22-dev-1634220658423.tgz#44457d84f8817c1680426573f43c6c0019be40f3"
|
||||
integrity sha512-fvHEUaHc41li90neDjqUvq5oCvuVbgYhEv2PbtwbpNBIalFnnhB8iFReFEunZZeLq12catBZmAXEW3QkaI2ltA==
|
||||
dependencies:
|
||||
joi "^17.3.0"
|
||||
joi-objectid "^3.0.1"
|
||||
|
||||
medusa-interfaces@1.1.23-dev-1634206968632:
|
||||
version "1.1.23-dev-1634206968632"
|
||||
resolved "http://localhost:4873/medusa-interfaces/-/medusa-interfaces-1.1.23-dev-1634206968632.tgz#1b9de0742daf85ddeacb11424857f5d6cc75e8f0"
|
||||
integrity sha512-8KsXxuMF+jFczyGa088DLVHzfejwD0X74g/AuXhCTkHbc52cbCZr9o7GMok7hfOCz7wp2kKUDBACL0y6PzxHrQ==
|
||||
medusa-interfaces@1.1.23-dev-1634220658423:
|
||||
version "1.1.23-dev-1634220658423"
|
||||
resolved "http://localhost:4873/medusa-interfaces/-/medusa-interfaces-1.1.23-dev-1634220658423.tgz#5e498e92f26999d0dc3850404fb3a25c34644f16"
|
||||
integrity sha512-N0qAn5Hwv+w5flejeH4zF5EI8d9X7CjwXuYBt37MTwmdsh4XZU/dhnt49S3iLwJUGvw9oinzII6N15e5LljxWQ==
|
||||
dependencies:
|
||||
medusa-core-utils "1.1.22-dev-1634206968632"
|
||||
medusa-core-utils "1.1.22-dev-1634220658423"
|
||||
|
||||
medusa-telemetry@0.0.5-dev-1634206968632:
|
||||
version "0.0.5-dev-1634206968632"
|
||||
resolved "http://localhost:4873/medusa-telemetry/-/medusa-telemetry-0.0.5-dev-1634206968632.tgz#a9a1161aacfe0aaa476ba3ce3c15cb199c201cef"
|
||||
integrity sha512-z3a5mXplM+XxkY3vJ8t159odgmkdMUHAWBZEM9PGaltkCh9Ew3RWkNXZeC60nW7tc85sfn1/nRxWpLgIywbruQ==
|
||||
medusa-telemetry@0.0.5-dev-1634220658423:
|
||||
version "0.0.5-dev-1634220658423"
|
||||
resolved "http://localhost:4873/medusa-telemetry/-/medusa-telemetry-0.0.5-dev-1634220658423.tgz#ebebe8b53601412a3d6501adba710098948abcad"
|
||||
integrity sha512-qr6LubLeXSIARlGc+M8vFxMKI/rAORDJxmTNYv9Ykrg22yPd+1bIy1sTNxtxz2Q9Q90uwJcTeOO8oY/uYUCM8g==
|
||||
dependencies:
|
||||
axios "^0.21.1"
|
||||
axios-retry "^3.1.9"
|
||||
@@ -5140,13 +5140,13 @@ medusa-telemetry@0.0.5-dev-1634206968632:
|
||||
remove-trailing-slash "^0.1.1"
|
||||
uuid "^8.3.2"
|
||||
|
||||
medusa-test-utils@1.1.25-dev-1634206968632:
|
||||
version "1.1.25-dev-1634206968632"
|
||||
resolved "http://localhost:4873/medusa-test-utils/-/medusa-test-utils-1.1.25-dev-1634206968632.tgz#7306ff294c23bc2f229ae3112e8fc5b5ea362500"
|
||||
integrity sha512-P+aa/Z7qywZt7z+6vj/owZhX8bHJCPsn1/Ak/9cGM0oJM/QGPzrQ00auikE13XyD95/53fPMh5G5mB8cJ+QbNg==
|
||||
medusa-test-utils@1.1.25-dev-1634220658423:
|
||||
version "1.1.25-dev-1634220658423"
|
||||
resolved "http://localhost:4873/medusa-test-utils/-/medusa-test-utils-1.1.25-dev-1634220658423.tgz#1ce959fa2456d6e1a2653ac596d371b3dc05936b"
|
||||
integrity sha512-irOZiSM9EeJdjUawUCi9IDjg+RlsQkfwbO9SHvABwmlXGA8BZ6hS2qUWuSK0tg0+oEKIojf+9VSG7dCkcTue2Q==
|
||||
dependencies:
|
||||
"@babel/plugin-transform-classes" "^7.9.5"
|
||||
medusa-core-utils "1.1.22-dev-1634206968632"
|
||||
medusa-core-utils "1.1.22-dev-1634220658423"
|
||||
randomatic "^3.1.1"
|
||||
|
||||
merge-descriptors@1.0.1:
|
||||
|
||||
Reference in New Issue
Block a user