chore(feature-flags): Sales Channels enabled by default (#2966)
This commit is contained in:
1 parent
cac81749ea
commit
3308766389
34 files changed
+372
-498
No files matched your search
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
---
|
||||||
|
|
||||||
|
chore(feature-flags): Sales Channels enabled by default
|
||||||
@@ -47,7 +47,7 @@ Object {
|
|||||||
"status": "draft",
|
"status": "draft",
|
||||||
"subtitle": null,
|
"subtitle": null,
|
||||||
"thumbnail": null,
|
"thumbnail": null,
|
||||||
"title": "Practical Frozen Fish",
|
"title": "Handmade Frozen Chair",
|
||||||
"type_id": Any<String>,
|
"type_id": Any<String>,
|
||||||
"updated_at": Any<String>,
|
"updated_at": Any<String>,
|
||||||
"weight": null,
|
"weight": null,
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ Array [
|
|||||||
],
|
],
|
||||||
"origin_country": null,
|
"origin_country": null,
|
||||||
"profile_id": StringMatching /\\^sp_\\*/,
|
"profile_id": StringMatching /\\^sp_\\*/,
|
||||||
|
"sales_channels": Array [],
|
||||||
"status": "draft",
|
"status": "draft",
|
||||||
"subtitle": null,
|
"subtitle": null,
|
||||||
"tags": Array [],
|
"tags": Array [],
|
||||||
@@ -174,6 +175,7 @@ Object {
|
|||||||
],
|
],
|
||||||
"origin_country": null,
|
"origin_country": null,
|
||||||
"profile_id": StringMatching /\\^sp_\\*/,
|
"profile_id": StringMatching /\\^sp_\\*/,
|
||||||
|
"sales_channels": Array [],
|
||||||
"status": "draft",
|
"status": "draft",
|
||||||
"subtitle": null,
|
"subtitle": null,
|
||||||
"tags": Array [
|
"tags": Array [
|
||||||
@@ -351,6 +353,7 @@ Object {
|
|||||||
],
|
],
|
||||||
"origin_country": null,
|
"origin_country": null,
|
||||||
"profile_id": StringMatching /\\^sp_\\*/,
|
"profile_id": StringMatching /\\^sp_\\*/,
|
||||||
|
"sales_channels": Array [],
|
||||||
"status": "published",
|
"status": "published",
|
||||||
"subtitle": null,
|
"subtitle": null,
|
||||||
"tags": Array [
|
"tags": Array [
|
||||||
|
|||||||
@@ -32,34 +32,6 @@ Object {
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`sales channels GET /admin/sales-channels should list the sales channel 1`] = `
|
|
||||||
Object {
|
|
||||||
"count": 2,
|
|
||||||
"limit": 20,
|
|
||||||
"offset": 0,
|
|
||||||
"sales_channels": ArrayContaining [
|
|
||||||
Object {
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"deleted_at": null,
|
|
||||||
"description": "test description",
|
|
||||||
"id": Any<String>,
|
|
||||||
"is_disabled": false,
|
|
||||||
"name": "test name",
|
|
||||||
"updated_at": Any<String>,
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"deleted_at": null,
|
|
||||||
"description": "test description 2",
|
|
||||||
"id": Any<String>,
|
|
||||||
"is_disabled": false,
|
|
||||||
"name": "test name 2",
|
|
||||||
"updated_at": Any<String>,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`sales channels GET /admin/sales-channels should list the sales channel using free text search 1`] = `
|
exports[`sales channels GET /admin/sales-channels should list the sales channel using free text search 1`] = `
|
||||||
Object {
|
Object {
|
||||||
"count": 1,
|
"count": 1,
|
||||||
|
|||||||
@@ -6,145 +6,3 @@ Object {
|
|||||||
"type": "invalid_data",
|
"type": "invalid_data",
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`/admin/store POST /admin/store successfully updates and store currencies 1`] = `
|
|
||||||
Object {
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"currencies": Array [
|
|
||||||
Object {
|
|
||||||
"code": "jpy",
|
|
||||||
"name": "Japanese Yen",
|
|
||||||
"symbol": "¥",
|
|
||||||
"symbol_native": "¥",
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"code": "usd",
|
|
||||||
"name": "US Dollar",
|
|
||||||
"symbol": "$",
|
|
||||||
"symbol_native": "$",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"default_currency_code": "usd",
|
|
||||||
"default_location_id": null,
|
|
||||||
"id": Any<String>,
|
|
||||||
"invite_link_template": null,
|
|
||||||
"metadata": null,
|
|
||||||
"name": "Medusa Store",
|
|
||||||
"payment_link_template": null,
|
|
||||||
"swap_link_template": null,
|
|
||||||
"updated_at": Any<String>,
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`/admin/store POST /admin/store successfully updates default currency and store currencies 1`] = `
|
|
||||||
Object {
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"currencies": Array [
|
|
||||||
Object {
|
|
||||||
"code": "jpy",
|
|
||||||
"name": "Japanese Yen",
|
|
||||||
"symbol": "¥",
|
|
||||||
"symbol_native": "¥",
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"code": "usd",
|
|
||||||
"name": "US Dollar",
|
|
||||||
"symbol": "$",
|
|
||||||
"symbol_native": "$",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"default_currency": Object {
|
|
||||||
"code": "jpy",
|
|
||||||
"name": "Japanese Yen",
|
|
||||||
"symbol": "¥",
|
|
||||||
"symbol_native": "¥",
|
|
||||||
},
|
|
||||||
"default_currency_code": "jpy",
|
|
||||||
"default_location_id": null,
|
|
||||||
"id": Any<String>,
|
|
||||||
"invite_link_template": null,
|
|
||||||
"metadata": null,
|
|
||||||
"name": "Medusa Store",
|
|
||||||
"payment_link_template": null,
|
|
||||||
"swap_link_template": null,
|
|
||||||
"updated_at": Any<String>,
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`/admin/store POST /admin/store successfully updates default currency code 1`] = `
|
|
||||||
Object {
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"currencies": Array [
|
|
||||||
Object {
|
|
||||||
"code": "usd",
|
|
||||||
"name": "US Dollar",
|
|
||||||
"symbol": "$",
|
|
||||||
"symbol_native": "$",
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"code": "dkk",
|
|
||||||
"name": "Danish Krone",
|
|
||||||
"symbol": "Dkr",
|
|
||||||
"symbol_native": "kr",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"default_currency": Object {
|
|
||||||
"code": "dkk",
|
|
||||||
"name": "Danish Krone",
|
|
||||||
"symbol": "Dkr",
|
|
||||||
"symbol_native": "kr",
|
|
||||||
},
|
|
||||||
"default_currency_code": "dkk",
|
|
||||||
"default_location_id": null,
|
|
||||||
"id": Any<String>,
|
|
||||||
"invite_link_template": null,
|
|
||||||
"metadata": null,
|
|
||||||
"name": "Medusa Store",
|
|
||||||
"payment_link_template": null,
|
|
||||||
"swap_link_template": null,
|
|
||||||
"updated_at": Any<String>,
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`/admin/store Store creation has created store with default currency 1`] = `
|
|
||||||
Object {
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"currencies": Array [
|
|
||||||
Object {
|
|
||||||
"code": "usd",
|
|
||||||
"name": "US Dollar",
|
|
||||||
"symbol": "$",
|
|
||||||
"symbol_native": "$",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"default_currency": Object {
|
|
||||||
"code": "usd",
|
|
||||||
"name": "US Dollar",
|
|
||||||
"symbol": "$",
|
|
||||||
"symbol_native": "$",
|
|
||||||
},
|
|
||||||
"default_currency_code": "usd",
|
|
||||||
"default_location_id": null,
|
|
||||||
"feature_flags": Any<Array>,
|
|
||||||
"fulfillment_providers": Array [
|
|
||||||
Object {
|
|
||||||
"id": "test-ful",
|
|
||||||
"is_installed": true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"id": Any<String>,
|
|
||||||
"invite_link_template": null,
|
|
||||||
"metadata": null,
|
|
||||||
"modules": Any<Array>,
|
|
||||||
"name": "Medusa Store",
|
|
||||||
"payment_link_template": null,
|
|
||||||
"payment_providers": Array [
|
|
||||||
Object {
|
|
||||||
"id": "test-pay",
|
|
||||||
"is_installed": true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"swap_link_template": null,
|
|
||||||
"updated_at": Any<String>,
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
@@ -12,7 +12,10 @@ const {
|
|||||||
DiscountConditionOperator,
|
DiscountConditionOperator,
|
||||||
} = require("@medusajs/medusa")
|
} = require("@medusajs/medusa")
|
||||||
const { IdMap } = require("medusa-test-utils")
|
const { IdMap } = require("medusa-test-utils")
|
||||||
const { simpleDiscountFactory } = require("../../factories")
|
const {
|
||||||
|
simpleDiscountFactory,
|
||||||
|
simpleSalesChannelFactory,
|
||||||
|
} = require("../../factories")
|
||||||
|
|
||||||
jest.setTimeout(30000)
|
jest.setTimeout(30000)
|
||||||
|
|
||||||
|
|||||||
@@ -109,31 +109,20 @@ describe("sales channels", () => {
|
|||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.sales_channels).toBeTruthy()
|
expect(response.data.sales_channels).toBeTruthy()
|
||||||
expect(response.data.sales_channels.length).toBe(2)
|
expect(response.data.sales_channels.length).toBe(2)
|
||||||
expect(response.data).toMatchSnapshot({
|
expect(response.data).toEqual(
|
||||||
count: 2,
|
expect.objectContaining({
|
||||||
limit: 20,
|
sales_channels: expect.arrayContaining([
|
||||||
offset: 0,
|
expect.objectContaining({
|
||||||
sales_channels: expect.arrayContaining([
|
name: salesChannel1.name,
|
||||||
{
|
description: salesChannel1.description,
|
||||||
id: expect.any(String),
|
}),
|
||||||
name: salesChannel1.name,
|
expect.objectContaining({
|
||||||
description: salesChannel1.description,
|
name: salesChannel2.name,
|
||||||
is_disabled: false,
|
description: salesChannel2.description,
|
||||||
deleted_at: null,
|
}),
|
||||||
created_at: expect.any(String),
|
]),
|
||||||
updated_at: expect.any(String),
|
})
|
||||||
},
|
)
|
||||||
{
|
|
||||||
id: expect.any(String),
|
|
||||||
name: salesChannel2.name,
|
|
||||||
description: salesChannel2.description,
|
|
||||||
is_disabled: false,
|
|
||||||
deleted_at: null,
|
|
||||||
created_at: expect.any(String),
|
|
||||||
updated_at: expect.any(String),
|
|
||||||
},
|
|
||||||
]),
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should list the sales channel using free text search", async () => {
|
it("should list the sales channel using free text search", async () => {
|
||||||
@@ -632,7 +621,7 @@ describe("sales channels", () => {
|
|||||||
relations: ["sales_channels"],
|
relations: ["sales_channels"],
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(attachedProduct.sales_channels.length).toBe(1)
|
expect(attachedProduct.sales_channels.length).toBe(2)
|
||||||
expect(attachedProduct.sales_channels).toEqual(
|
expect(attachedProduct.sales_channels).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
@@ -641,6 +630,10 @@ describe("sales channels", () => {
|
|||||||
description: "test description",
|
description: "test description",
|
||||||
is_disabled: false,
|
is_disabled: false,
|
||||||
}),
|
}),
|
||||||
|
expect.objectContaining({
|
||||||
|
id: expect.any(String),
|
||||||
|
is_disabled: false,
|
||||||
|
}),
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -679,7 +672,8 @@ describe("sales channels", () => {
|
|||||||
relations: ["sales_channels"],
|
relations: ["sales_channels"],
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(attachedProduct.sales_channels.length).toBe(0)
|
// default sales channel
|
||||||
|
expect(attachedProduct.sales_channels.length).toBe(1)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -733,7 +727,8 @@ describe("sales channels", () => {
|
|||||||
relations: ["sales_channels"],
|
relations: ["sales_channels"],
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(attachedProduct.sales_channels.length).toBe(1)
|
// + default sales channel
|
||||||
|
expect(attachedProduct.sales_channels.length).toBe(2)
|
||||||
expect(attachedProduct.sales_channels).toEqual(
|
expect(attachedProduct.sales_channels).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
@@ -742,6 +737,10 @@ describe("sales channels", () => {
|
|||||||
description: "test description",
|
description: "test description",
|
||||||
is_disabled: false,
|
is_disabled: false,
|
||||||
}),
|
}),
|
||||||
|
expect.objectContaining({
|
||||||
|
id: expect.any(String),
|
||||||
|
is_disabled: false,
|
||||||
|
}),
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -44,20 +44,26 @@ describe("/admin/store", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.store).toMatchSnapshot({
|
expect(response.data.store).toEqual(
|
||||||
id: expect.any(String),
|
expect.objectContaining({
|
||||||
name: "Medusa Store",
|
id: expect.any(String),
|
||||||
currencies: [
|
default_sales_channel_id: expect.any(String),
|
||||||
{
|
default_sales_channel: expect.objectContaining({
|
||||||
code: "usd",
|
id: expect.any(String),
|
||||||
},
|
}),
|
||||||
],
|
name: "Medusa Store",
|
||||||
modules: expect.any(Array),
|
currencies: expect.arrayContaining([
|
||||||
feature_flags: expect.any(Array),
|
expect.objectContaining({
|
||||||
default_currency_code: "usd",
|
code: "usd",
|
||||||
created_at: expect.any(String),
|
}),
|
||||||
updated_at: expect.any(String),
|
]),
|
||||||
})
|
modules: expect.any(Array),
|
||||||
|
feature_flags: expect.any(Array),
|
||||||
|
default_currency_code: "usd",
|
||||||
|
created_at: expect.any(String),
|
||||||
|
updated_at: expect.any(String),
|
||||||
|
})
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -142,21 +148,24 @@ describe("/admin/store", () => {
|
|||||||
.catch((err) => console.log(err))
|
.catch((err) => console.log(err))
|
||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.store).toMatchSnapshot({
|
expect(response.data.store).toEqual(
|
||||||
id: expect.any(String),
|
expect.objectContaining({
|
||||||
name: "Medusa Store",
|
id: expect.any(String),
|
||||||
currencies: [
|
name: "Medusa Store",
|
||||||
{
|
default_sales_channel_id: expect.any(String),
|
||||||
code: "usd",
|
currencies: expect.arrayContaining([
|
||||||
},
|
expect.objectContaining({
|
||||||
{
|
code: "usd",
|
||||||
code: "dkk",
|
}),
|
||||||
},
|
expect.objectContaining({
|
||||||
],
|
code: "dkk",
|
||||||
default_currency_code: "dkk",
|
}),
|
||||||
created_at: expect.any(String),
|
]),
|
||||||
updated_at: expect.any(String),
|
default_currency_code: "dkk",
|
||||||
})
|
created_at: expect.any(String),
|
||||||
|
updated_at: expect.any(String),
|
||||||
|
})
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("successfully updates default currency and store currencies", async () => {
|
it("successfully updates default currency and store currencies", async () => {
|
||||||
@@ -174,21 +183,24 @@ describe("/admin/store", () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.store).toMatchSnapshot({
|
expect(response.data.store).toEqual(
|
||||||
id: expect.any(String),
|
expect.objectContaining({
|
||||||
name: "Medusa Store",
|
id: expect.any(String),
|
||||||
currencies: [
|
name: "Medusa Store",
|
||||||
{
|
default_sales_channel_id: expect.any(String),
|
||||||
code: "jpy",
|
currencies: expect.arrayContaining([
|
||||||
},
|
expect.objectContaining({
|
||||||
{
|
code: "jpy",
|
||||||
code: "usd",
|
}),
|
||||||
},
|
expect.objectContaining({
|
||||||
],
|
code: "usd",
|
||||||
default_currency_code: "jpy",
|
}),
|
||||||
created_at: expect.any(String),
|
]),
|
||||||
updated_at: expect.any(String),
|
default_currency_code: "jpy",
|
||||||
})
|
created_at: expect.any(String),
|
||||||
|
updated_at: expect.any(String),
|
||||||
|
})
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("successfully updates and store currencies", async () => {
|
it("successfully updates and store currencies", async () => {
|
||||||
@@ -205,21 +217,24 @@ describe("/admin/store", () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.store).toMatchSnapshot({
|
expect(response.data.store).toEqual(
|
||||||
id: expect.any(String),
|
expect.objectContaining({
|
||||||
name: "Medusa Store",
|
id: expect.any(String),
|
||||||
currencies: [
|
default_sales_channel_id: expect.any(String),
|
||||||
{
|
name: "Medusa Store",
|
||||||
code: "jpy",
|
currencies: expect.arrayContaining([
|
||||||
},
|
expect.objectContaining({
|
||||||
{
|
code: "jpy",
|
||||||
code: "usd",
|
}),
|
||||||
},
|
expect.objectContaining({
|
||||||
],
|
code: "usd",
|
||||||
default_currency_code: "usd",
|
}),
|
||||||
created_at: expect.any(String),
|
]),
|
||||||
updated_at: expect.any(String),
|
default_currency_code: "usd",
|
||||||
})
|
created_at: expect.any(String),
|
||||||
|
updated_at: expect.any(String),
|
||||||
|
})
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -81,128 +81,3 @@ Object {
|
|||||||
"offset": 0,
|
"offset": 0,
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`/admin/batch-jobs GET /admin/batch-jobs lists batch jobs created by the user and where completed_at is null 1`] = `
|
|
||||||
Object {
|
|
||||||
"batch_jobs": Array [
|
|
||||||
Object {
|
|
||||||
"canceled_at": null,
|
|
||||||
"completed_at": null,
|
|
||||||
"confirmed_at": null,
|
|
||||||
"context": Object {},
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"created_by": "admin_user",
|
|
||||||
"deleted_at": null,
|
|
||||||
"dry_run": false,
|
|
||||||
"failed_at": null,
|
|
||||||
"id": "job_3",
|
|
||||||
"pre_processed_at": null,
|
|
||||||
"processing_at": null,
|
|
||||||
"result": null,
|
|
||||||
"status": "created",
|
|
||||||
"type": "product-export",
|
|
||||||
"updated_at": Any<String>,
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"canceled_at": null,
|
|
||||||
"completed_at": null,
|
|
||||||
"confirmed_at": null,
|
|
||||||
"context": Object {},
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"created_by": "admin_user",
|
|
||||||
"deleted_at": null,
|
|
||||||
"dry_run": false,
|
|
||||||
"failed_at": null,
|
|
||||||
"id": "job_2",
|
|
||||||
"pre_processed_at": null,
|
|
||||||
"processing_at": null,
|
|
||||||
"result": null,
|
|
||||||
"status": "created",
|
|
||||||
"type": "product-export",
|
|
||||||
"updated_at": Any<String>,
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"canceled_at": null,
|
|
||||||
"completed_at": null,
|
|
||||||
"confirmed_at": null,
|
|
||||||
"context": Object {},
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"created_by": "admin_user",
|
|
||||||
"deleted_at": null,
|
|
||||||
"dry_run": false,
|
|
||||||
"failed_at": null,
|
|
||||||
"id": "job_1",
|
|
||||||
"pre_processed_at": null,
|
|
||||||
"processing_at": null,
|
|
||||||
"result": null,
|
|
||||||
"status": "created",
|
|
||||||
"type": "product-export",
|
|
||||||
"updated_at": Any<String>,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"count": 3,
|
|
||||||
"limit": 10,
|
|
||||||
"offset": 0,
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`/admin/batch-jobs POST /admin/batch-jobs/ Creates a batch job 1`] = `
|
|
||||||
Object {
|
|
||||||
"canceled_at": null,
|
|
||||||
"completed_at": null,
|
|
||||||
"confirmed_at": null,
|
|
||||||
"context": Object {
|
|
||||||
"list_config": Object {
|
|
||||||
"order": Object {
|
|
||||||
"created_at": "DESC",
|
|
||||||
},
|
|
||||||
"relations": Array [
|
|
||||||
"variants",
|
|
||||||
"variants.prices",
|
|
||||||
"variants.options",
|
|
||||||
"images",
|
|
||||||
"options",
|
|
||||||
"tags",
|
|
||||||
"type",
|
|
||||||
"collection",
|
|
||||||
"variants.prices.region",
|
|
||||||
],
|
|
||||||
"skip": 0,
|
|
||||||
"take": 50,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"created_by": "admin_user",
|
|
||||||
"deleted_at": null,
|
|
||||||
"dry_run": false,
|
|
||||||
"failed_at": null,
|
|
||||||
"id": Any<String>,
|
|
||||||
"pre_processed_at": null,
|
|
||||||
"processing_at": null,
|
|
||||||
"result": null,
|
|
||||||
"status": "created",
|
|
||||||
"type": "product-export",
|
|
||||||
"updated_at": Any<String>,
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`/admin/batch-jobs POST /admin/batch-jobs/:id/cancel Cancels batch job created by the user 1`] = `
|
|
||||||
Object {
|
|
||||||
"canceled_at": Any<String>,
|
|
||||||
"completed_at": null,
|
|
||||||
"confirmed_at": null,
|
|
||||||
"context": Object {},
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"created_by": "admin_user",
|
|
||||||
"deleted_at": null,
|
|
||||||
"dry_run": false,
|
|
||||||
"failed_at": null,
|
|
||||||
"id": "job_1",
|
|
||||||
"pre_processed_at": null,
|
|
||||||
"processing_at": null,
|
|
||||||
"result": null,
|
|
||||||
"status": "canceled",
|
|
||||||
"type": "product-export",
|
|
||||||
"updated_at": Any<String>,
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
@@ -123,28 +123,30 @@ describe("/admin/batch-jobs", () => {
|
|||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.batch_jobs.length).toEqual(3)
|
expect(response.data.batch_jobs.length).toEqual(3)
|
||||||
expect(response.data).toMatchSnapshot({
|
expect(response.data).toEqual(
|
||||||
batch_jobs: [
|
expect.objectContaining({
|
||||||
{
|
batch_jobs: expect.arrayContaining([
|
||||||
id: "job_3",
|
expect.objectContaining({
|
||||||
created_at: expect.any(String),
|
id: "job_3",
|
||||||
updated_at: expect.any(String),
|
created_at: expect.any(String),
|
||||||
created_by: "admin_user",
|
updated_at: expect.any(String),
|
||||||
},
|
created_by: "admin_user",
|
||||||
{
|
}),
|
||||||
id: "job_2",
|
expect.objectContaining({
|
||||||
created_at: expect.any(String),
|
id: "job_2",
|
||||||
updated_at: expect.any(String),
|
created_at: expect.any(String),
|
||||||
created_by: "admin_user",
|
updated_at: expect.any(String),
|
||||||
},
|
created_by: "admin_user",
|
||||||
{
|
}),
|
||||||
id: "job_1",
|
expect.objectContaining({
|
||||||
created_at: expect.any(String),
|
id: "job_1",
|
||||||
updated_at: expect.any(String),
|
created_at: expect.any(String),
|
||||||
created_by: "admin_user",
|
updated_at: expect.any(String),
|
||||||
},
|
created_by: "admin_user",
|
||||||
],
|
}),
|
||||||
})
|
]),
|
||||||
|
})
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -207,13 +209,15 @@ describe("/admin/batch-jobs", () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
expect(response.status).toEqual(201)
|
expect(response.status).toEqual(201)
|
||||||
expect(response.data.batch_job).toMatchSnapshot({
|
expect(response.data.batch_job).toEqual(
|
||||||
created_by: "admin_user",
|
expect.objectContaining({
|
||||||
status: "created",
|
created_by: "admin_user",
|
||||||
id: expect.any(String),
|
status: "created",
|
||||||
created_at: expect.any(String),
|
id: expect.any(String),
|
||||||
updated_at: expect.any(String),
|
created_at: expect.any(String),
|
||||||
})
|
updated_at: expect.any(String),
|
||||||
|
})
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -272,12 +276,14 @@ describe("/admin/batch-jobs", () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.batch_job).toMatchSnapshot({
|
expect(response.data.batch_job).toEqual(
|
||||||
created_at: expect.any(String),
|
expect.objectContaining({
|
||||||
updated_at: expect.any(String),
|
created_at: expect.any(String),
|
||||||
canceled_at: expect.any(String),
|
updated_at: expect.any(String),
|
||||||
status: "canceled",
|
canceled_at: expect.any(String),
|
||||||
})
|
status: "canceled",
|
||||||
|
})
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("Fails to cancel a batch job created by a different user", async () => {
|
it("Fails to cancel a batch job created by a different user", async () => {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const path = require("path")
|
const path = require("path")
|
||||||
const fs = require("fs/promises")
|
const fs = require("fs/promises")
|
||||||
import { resolve, sep } from "path"
|
import { resolve, sep } from "path"
|
||||||
|
import { simpleSalesChannelFactory } from "../../../factories"
|
||||||
|
|
||||||
const setupServer = require("../../../../helpers/setup-server")
|
const setupServer = require("../../../../helpers/setup-server")
|
||||||
const { useApi } = require("../../../../helpers/use-api")
|
const { useApi } = require("../../../../helpers/use-api")
|
||||||
@@ -49,6 +50,11 @@ describe("Batch job of product-export type", () => {
|
|||||||
await productSeeder(dbConnection)
|
await productSeeder(dbConnection)
|
||||||
await adminSeeder(dbConnection)
|
await adminSeeder(dbConnection)
|
||||||
await userSeeder(dbConnection)
|
await userSeeder(dbConnection)
|
||||||
|
|
||||||
|
await simpleSalesChannelFactory(dbConnection, {
|
||||||
|
id: "test-channel",
|
||||||
|
is_default: true,
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ Object {
|
|||||||
"cart_id": null,
|
"cart_id": null,
|
||||||
"claim_order_id": StringMatching /\\^claim_\\*/,
|
"claim_order_id": StringMatching /\\^claim_\\*/,
|
||||||
"created_at": Any<String>,
|
"created_at": Any<String>,
|
||||||
"description": "Practical Granite Pizza",
|
"description": "Refined Wooden Chair",
|
||||||
"fulfilled_quantity": null,
|
"fulfilled_quantity": null,
|
||||||
"has_shipping": null,
|
"has_shipping": null,
|
||||||
"id": StringMatching /\\^item_\\*/,
|
"id": StringMatching /\\^item_\\*/,
|
||||||
@@ -67,7 +67,7 @@ Object {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
"thumbnail": null,
|
"thumbnail": null,
|
||||||
"title": "Awesome Metal Ball",
|
"title": "Gorgeous Cotton Table",
|
||||||
"unit_price": 100,
|
"unit_price": 100,
|
||||||
"updated_at": Any<String>,
|
"updated_at": Any<String>,
|
||||||
"variant": Object {
|
"variant": Object {
|
||||||
@@ -107,7 +107,7 @@ Object {
|
|||||||
"status": "draft",
|
"status": "draft",
|
||||||
"subtitle": null,
|
"subtitle": null,
|
||||||
"thumbnail": null,
|
"thumbnail": null,
|
||||||
"title": "Awesome Metal Ball",
|
"title": "Gorgeous Cotton Table",
|
||||||
"type_id": null,
|
"type_id": null,
|
||||||
"updated_at": Any<String>,
|
"updated_at": Any<String>,
|
||||||
"weight": null,
|
"weight": null,
|
||||||
@@ -115,7 +115,7 @@ Object {
|
|||||||
},
|
},
|
||||||
"product_id": "test-product",
|
"product_id": "test-product",
|
||||||
"sku": null,
|
"sku": null,
|
||||||
"title": "Practical Granite Pizza",
|
"title": "Refined Wooden Chair",
|
||||||
"upc": null,
|
"upc": null,
|
||||||
"updated_at": Any<String>,
|
"updated_at": Any<String>,
|
||||||
"weight": null,
|
"weight": null,
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ Object {
|
|||||||
"metadata": null,
|
"metadata": null,
|
||||||
"option_id": Any<String>,
|
"option_id": Any<String>,
|
||||||
"updated_at": Any<String>,
|
"updated_at": Any<String>,
|
||||||
"value": "Handcrafted",
|
"value": "Practical",
|
||||||
"variant_id": Any<String>,
|
"variant_id": Any<String>,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ Object {
|
|||||||
"payment_authorized_at": null,
|
"payment_authorized_at": null,
|
||||||
"payment_id": null,
|
"payment_id": null,
|
||||||
"region_id": "test-region",
|
"region_id": "test-region",
|
||||||
|
"sales_channel_id": Any<String>,
|
||||||
"shipping_address_id": "test-shipping-address",
|
"shipping_address_id": "test-shipping-address",
|
||||||
"type": "swap",
|
"type": "swap",
|
||||||
"updated_at": Any<String>,
|
"updated_at": Any<String>,
|
||||||
@@ -131,6 +132,7 @@ Object {
|
|||||||
"object": "order",
|
"object": "order",
|
||||||
"payment_status": "captured",
|
"payment_status": "captured",
|
||||||
"region_id": "test-region",
|
"region_id": "test-region",
|
||||||
|
"sales_channel_id": null,
|
||||||
"shipping_address_id": "test-shipping-address",
|
"shipping_address_id": "test-shipping-address",
|
||||||
"status": "pending",
|
"status": "pending",
|
||||||
"tax_rate": 0,
|
"tax_rate": 0,
|
||||||
@@ -275,6 +277,7 @@ Object {
|
|||||||
"payment_authorized_at": null,
|
"payment_authorized_at": null,
|
||||||
"payment_id": null,
|
"payment_id": null,
|
||||||
"region_id": "test-region",
|
"region_id": "test-region",
|
||||||
|
"sales_channel_id": Any<String>,
|
||||||
"shipping_address_id": "test-shipping-address",
|
"shipping_address_id": "test-shipping-address",
|
||||||
"type": "swap",
|
"type": "swap",
|
||||||
"updated_at": Any<String>,
|
"updated_at": Any<String>,
|
||||||
@@ -308,6 +311,7 @@ Object {
|
|||||||
"object": "order",
|
"object": "order",
|
||||||
"payment_status": "captured",
|
"payment_status": "captured",
|
||||||
"region_id": "test-region",
|
"region_id": "test-region",
|
||||||
|
"sales_channel_id": null,
|
||||||
"shipping_address_id": "test-shipping-address",
|
"shipping_address_id": "test-shipping-address",
|
||||||
"status": "pending",
|
"status": "pending",
|
||||||
"tax_rate": 0,
|
"tax_rate": 0,
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ const {
|
|||||||
simpleProductFactory,
|
simpleProductFactory,
|
||||||
simpleShippingOptionFactory,
|
simpleShippingOptionFactory,
|
||||||
simpleLineItemFactory,
|
simpleLineItemFactory,
|
||||||
|
simpleSalesChannelFactory,
|
||||||
} = require("../../../factories")
|
} = require("../../../factories")
|
||||||
const {
|
const {
|
||||||
simpleDiscountFactory,
|
simpleDiscountFactory,
|
||||||
@@ -57,6 +58,9 @@ describe("/store/carts", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe("POST /store/carts", () => {
|
describe("POST /store/carts", () => {
|
||||||
|
let prod1
|
||||||
|
let prodSale
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const manager = dbConnection.manager
|
const manager = dbConnection.manager
|
||||||
await manager.insert(Region, {
|
await manager.insert(Region, {
|
||||||
@@ -70,6 +74,21 @@ describe("/store/carts", () => {
|
|||||||
SET region_id='region'
|
SET region_id='region'
|
||||||
WHERE iso_2 = 'us'`
|
WHERE iso_2 = 'us'`
|
||||||
)
|
)
|
||||||
|
|
||||||
|
prod1 = await simpleProductFactory(dbConnection, {
|
||||||
|
id: "test-product",
|
||||||
|
variants: [{ id: "test-variant_1" }],
|
||||||
|
})
|
||||||
|
|
||||||
|
prodSale = await simpleProductFactory(dbConnection, {
|
||||||
|
id: "test-product-sale",
|
||||||
|
variants: [
|
||||||
|
{
|
||||||
|
id: "test-variant-sale",
|
||||||
|
prices: [{ amount: 1000, currency: "usd" }],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
@@ -108,8 +127,6 @@ describe("/store/carts", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it("creates a cart with items", async () => {
|
it("creates a cart with items", async () => {
|
||||||
await productSeeder(dbConnection)
|
|
||||||
|
|
||||||
const yesterday = ((today) =>
|
const yesterday = ((today) =>
|
||||||
new Date(today.setDate(today.getDate() - 1)))(new Date())
|
new Date(today.setDate(today.getDate() - 1)))(new Date())
|
||||||
const tomorrow = ((today) =>
|
const tomorrow = ((today) =>
|
||||||
@@ -128,7 +145,7 @@ describe("/store/carts", () => {
|
|||||||
await dbConnection.manager.save(priceList1)
|
await dbConnection.manager.save(priceList1)
|
||||||
|
|
||||||
const ma_sale_1 = dbConnection.manager.create(MoneyAmount, {
|
const ma_sale_1 = dbConnection.manager.create(MoneyAmount, {
|
||||||
variant_id: "test-variant-sale",
|
variant_id: prodSale.variants[0].id,
|
||||||
currency_code: "usd",
|
currency_code: "usd",
|
||||||
amount: 800,
|
amount: 800,
|
||||||
price_list_id: "pl_current",
|
price_list_id: "pl_current",
|
||||||
@@ -142,11 +159,11 @@ describe("/store/carts", () => {
|
|||||||
.post("/store/carts", {
|
.post("/store/carts", {
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
variant_id: "test-variant_1",
|
variant_id: prod1.variants[0].id,
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
variant_id: "test-variant-sale",
|
variant_id: prodSale.variants[0].id,
|
||||||
quantity: 2,
|
quantity: 2,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -160,11 +177,11 @@ describe("/store/carts", () => {
|
|||||||
expect(response.data.cart.items).toEqual(
|
expect(response.data.cart.items).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
variant_id: "test-variant_1",
|
variant_id: prod1.variants[0].id,
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
}),
|
}),
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
variant_id: "test-variant-sale",
|
variant_id: prodSale.variants[0].id,
|
||||||
quantity: 2,
|
quantity: 2,
|
||||||
unit_price: 800,
|
unit_price: 800,
|
||||||
}),
|
}),
|
||||||
@@ -931,6 +948,11 @@ describe("/store/carts", () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await cartSeeder(dbConnection)
|
await cartSeeder(dbConnection)
|
||||||
await swapSeeder(dbConnection)
|
await swapSeeder(dbConnection)
|
||||||
|
|
||||||
|
await simpleSalesChannelFactory(dbConnection, {
|
||||||
|
id: "test-channel",
|
||||||
|
is_default: true,
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
@@ -2263,6 +2285,10 @@ describe("/store/carts", () => {
|
|||||||
describe("get-cart with session customer", () => {
|
describe("get-cart with session customer", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await cartSeeder(dbConnection)
|
await cartSeeder(dbConnection)
|
||||||
|
await simpleSalesChannelFactory(dbConnection, {
|
||||||
|
id: "test-channel",
|
||||||
|
is_default: true,
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ const {
|
|||||||
simpleProductFactory,
|
simpleProductFactory,
|
||||||
simplePriceListFactory,
|
simplePriceListFactory,
|
||||||
simpleDiscountFactory,
|
simpleDiscountFactory,
|
||||||
|
simpleSalesChannelFactory,
|
||||||
} = require("../../../factories")
|
} = require("../../../factories")
|
||||||
const { IdMap } = require("medusa-test-utils")
|
const { IdMap } = require("medusa-test-utils")
|
||||||
|
|
||||||
@@ -155,9 +156,11 @@ describe("[MEDUSA_FF_TAX_INCLUSIVE_PRICING] /store/carts", () => {
|
|||||||
tax_rate: 20,
|
tax_rate: 20,
|
||||||
name: "region test",
|
name: "region test",
|
||||||
}
|
}
|
||||||
const buildProductData = (productId, variantId) => {
|
|
||||||
|
const buildProductData = (productId, variantId, salesChannelId) => {
|
||||||
return {
|
return {
|
||||||
id: productId,
|
id: productId,
|
||||||
|
sales_channels: [{ id: salesChannelId }],
|
||||||
variants: [
|
variants: [
|
||||||
{
|
{
|
||||||
id: variantId,
|
id: variantId,
|
||||||
@@ -203,10 +206,14 @@ describe("[MEDUSA_FF_TAX_INCLUSIVE_PRICING] /store/carts", () => {
|
|||||||
|
|
||||||
describe("with a cart with full tax exclusive variant pricing", () => {
|
describe("with a cart with full tax exclusive variant pricing", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
const salesChannel = await simpleSalesChannelFactory(dbConnection, {
|
||||||
|
id: "test-channel",
|
||||||
|
is_default: true,
|
||||||
|
})
|
||||||
await simpleRegionFactory(dbConnection, regionData)
|
await simpleRegionFactory(dbConnection, regionData)
|
||||||
await simpleProductFactory(
|
await simpleProductFactory(
|
||||||
dbConnection,
|
dbConnection,
|
||||||
buildProductData(productId1, variantId1)
|
buildProductData(productId1, variantId1, salesChannel.id)
|
||||||
)
|
)
|
||||||
await simplePriceListFactory(
|
await simplePriceListFactory(
|
||||||
dbConnection,
|
dbConnection,
|
||||||
@@ -214,7 +221,7 @@ describe("[MEDUSA_FF_TAX_INCLUSIVE_PRICING] /store/carts", () => {
|
|||||||
)
|
)
|
||||||
await simpleProductFactory(
|
await simpleProductFactory(
|
||||||
dbConnection,
|
dbConnection,
|
||||||
buildProductData(productId2, variantId2)
|
buildProductData(productId2, variantId2, salesChannel.id)
|
||||||
)
|
)
|
||||||
await simplePriceListFactory(
|
await simplePriceListFactory(
|
||||||
dbConnection,
|
dbConnection,
|
||||||
@@ -280,10 +287,15 @@ describe("[MEDUSA_FF_TAX_INCLUSIVE_PRICING] /store/carts", () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
const salesChannel = await simpleSalesChannelFactory(dbConnection, {
|
||||||
|
id: "test-channel",
|
||||||
|
is_default: true,
|
||||||
|
})
|
||||||
|
|
||||||
await simpleRegionFactory(dbConnection, regionData)
|
await simpleRegionFactory(dbConnection, regionData)
|
||||||
await simpleProductFactory(
|
await simpleProductFactory(
|
||||||
dbConnection,
|
dbConnection,
|
||||||
buildProductData(productId1, variantId1)
|
buildProductData(productId1, variantId1, salesChannel.id)
|
||||||
)
|
)
|
||||||
await simplePriceListFactory(
|
await simplePriceListFactory(
|
||||||
dbConnection,
|
dbConnection,
|
||||||
@@ -291,7 +303,7 @@ describe("[MEDUSA_FF_TAX_INCLUSIVE_PRICING] /store/carts", () => {
|
|||||||
)
|
)
|
||||||
await simpleProductFactory(
|
await simpleProductFactory(
|
||||||
dbConnection,
|
dbConnection,
|
||||||
buildProductData(productId2, variantId2)
|
buildProductData(productId2, variantId2, salesChannel.id)
|
||||||
)
|
)
|
||||||
await simplePriceListFactory(
|
await simplePriceListFactory(
|
||||||
dbConnection,
|
dbConnection,
|
||||||
@@ -357,10 +369,15 @@ describe("[MEDUSA_FF_TAX_INCLUSIVE_PRICING] /store/carts", () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
const salesChannel = await simpleSalesChannelFactory(dbConnection, {
|
||||||
|
id: "test-channel",
|
||||||
|
is_default: true,
|
||||||
|
})
|
||||||
|
|
||||||
await simpleRegionFactory(dbConnection, regionData)
|
await simpleRegionFactory(dbConnection, regionData)
|
||||||
await simpleProductFactory(
|
await simpleProductFactory(
|
||||||
dbConnection,
|
dbConnection,
|
||||||
buildProductData(productId1, variantId1)
|
buildProductData(productId1, variantId1, salesChannel.id)
|
||||||
)
|
)
|
||||||
await simplePriceListFactory(
|
await simplePriceListFactory(
|
||||||
dbConnection,
|
dbConnection,
|
||||||
@@ -368,7 +385,7 @@ describe("[MEDUSA_FF_TAX_INCLUSIVE_PRICING] /store/carts", () => {
|
|||||||
)
|
)
|
||||||
await simpleProductFactory(
|
await simpleProductFactory(
|
||||||
dbConnection,
|
dbConnection,
|
||||||
buildProductData(productId2, variantId2)
|
buildProductData(productId2, variantId2, salesChannel.id)
|
||||||
)
|
)
|
||||||
await simplePriceListFactory(
|
await simplePriceListFactory(
|
||||||
dbConnection,
|
dbConnection,
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ describe("Gift Card - Tax calculations", () => {
|
|||||||
const cwd = path.resolve(path.join(__dirname, "..", "..", "..", ".."))
|
const cwd = path.resolve(path.join(__dirname, "..", "..", "..", ".."))
|
||||||
const [process, connection] = await startServerWithEnvironment({
|
const [process, connection] = await startServerWithEnvironment({
|
||||||
cwd,
|
cwd,
|
||||||
env: {}
|
env: {},
|
||||||
})
|
})
|
||||||
dbConnection = connection
|
dbConnection = connection
|
||||||
medusaProcess = process
|
medusaProcess = process
|
||||||
@@ -51,7 +51,9 @@ describe("Gift Card - Tax calculations", () => {
|
|||||||
name: "region test",
|
name: "region test",
|
||||||
})
|
})
|
||||||
|
|
||||||
customer = await simpleCustomerFactory(dbConnection, { password: 'medusatest' })
|
customer = await simpleCustomerFactory(dbConnection, {
|
||||||
|
password: "medusatest",
|
||||||
|
})
|
||||||
|
|
||||||
customerData = {
|
customerData = {
|
||||||
email: customer.email,
|
email: customer.email,
|
||||||
@@ -64,19 +66,25 @@ describe("Gift Card - Tax calculations", () => {
|
|||||||
is_giftcard: true,
|
is_giftcard: true,
|
||||||
discountable: false,
|
discountable: false,
|
||||||
options: [{ id: "denom", title: "Denomination" }],
|
options: [{ id: "denom", title: "Denomination" }],
|
||||||
variants: [{
|
variants: [
|
||||||
title: "Gift Card",
|
{
|
||||||
prices: [{ currency: "usd", amount: 30000, region_id: region.id }],
|
title: "Gift Card",
|
||||||
options: [{ option_id: "denom", value: "Denomination" }],
|
prices: [{ currency: "usd", amount: 30000, region_id: region.id }],
|
||||||
}]
|
options: [{ option_id: "denom", value: "Denomination" }],
|
||||||
|
},
|
||||||
|
],
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it("adding a gift card purchase to cart treats it like buying a product", async () => {
|
it("adding a gift card purchase to cart treats it like buying a product", async () => {
|
||||||
const api = useApi()
|
const api = useApi()
|
||||||
const customerResponse = await api.post("/store/customers", customerData, {
|
const customerResponse = await api.post(
|
||||||
withCredentials: true,
|
"/store/customers",
|
||||||
})
|
customerData,
|
||||||
|
{
|
||||||
|
withCredentials: true,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
const createCartResponse = await api.post("/store/carts", {
|
const createCartResponse = await api.post("/store/carts", {
|
||||||
region_id: region.id,
|
region_id: region.id,
|
||||||
@@ -110,8 +118,8 @@ describe("Gift Card - Tax calculations", () => {
|
|||||||
id: product.variants[0].id,
|
id: product.variants[0].id,
|
||||||
product: expect.objectContaining({
|
product: expect.objectContaining({
|
||||||
is_giftcard: true,
|
is_giftcard: true,
|
||||||
})
|
}),
|
||||||
})
|
}),
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
@@ -119,11 +127,18 @@ describe("Gift Card - Tax calculations", () => {
|
|||||||
|
|
||||||
it("purchasing a gift card via an order creates a gift card entity", async () => {
|
it("purchasing a gift card via an order creates a gift card entity", async () => {
|
||||||
const api = useApi()
|
const api = useApi()
|
||||||
const customerResponse = await api.post("/store/customers", customerData, {
|
const customerResponse = await api.post(
|
||||||
withCredentials: true,
|
"/store/customers",
|
||||||
})
|
customerData,
|
||||||
|
{
|
||||||
|
withCredentials: true,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
const cartFactory = await simpleCartFactory(dbConnection, { customer, region })
|
const cartFactory = await simpleCartFactory(dbConnection, {
|
||||||
|
customer,
|
||||||
|
region,
|
||||||
|
})
|
||||||
|
|
||||||
const response = await api.post(
|
const response = await api.post(
|
||||||
`/store/carts/${cartFactory.id}/line-items`,
|
`/store/carts/${cartFactory.id}/line-items`,
|
||||||
@@ -140,9 +155,11 @@ describe("Gift Card - Tax calculations", () => {
|
|||||||
|
|
||||||
await api.post(`/store/carts/${cart.id}/payment-sessions`)
|
await api.post(`/store/carts/${cart.id}/payment-sessions`)
|
||||||
|
|
||||||
const createdOrderResponse = await api.post(`/store/carts/${cart.id}/complete-cart`)
|
const createdOrderResponse = await api.post(
|
||||||
|
`/store/carts/${cart.id}/complete-cart`
|
||||||
|
)
|
||||||
const createdGiftCards = await dbConnection.manager.find(GiftCard, {
|
const createdGiftCards = await dbConnection.manager.find(GiftCard, {
|
||||||
where: { order_id: createdOrderResponse.data.data.id }
|
where: { order_id: createdOrderResponse.data.data.id },
|
||||||
})
|
})
|
||||||
const createdGiftCard = createdGiftCards[0]
|
const createdGiftCard = createdGiftCards[0]
|
||||||
|
|
||||||
@@ -163,14 +180,18 @@ describe("Gift Card - Tax calculations", () => {
|
|||||||
tax_rate: region.tax_rate,
|
tax_rate: region.tax_rate,
|
||||||
})
|
})
|
||||||
const expensiveProduct = await simpleProductFactory(dbConnection, {
|
const expensiveProduct = await simpleProductFactory(dbConnection, {
|
||||||
variants: [{
|
variants: [
|
||||||
title: "Product cost higher than gift card balance",
|
{
|
||||||
prices: [{
|
title: "Product cost higher than gift card balance",
|
||||||
amount: 50000,
|
prices: [
|
||||||
currency: "usd",
|
{
|
||||||
region_id: region.id,
|
amount: 50000,
|
||||||
}],
|
currency: "usd",
|
||||||
}]
|
region_id: region.id,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
const customerRes = await api.post("/store/customers", customerData, {
|
const customerRes = await api.post("/store/customers", customerData, {
|
||||||
@@ -200,7 +221,9 @@ describe("Gift Card - Tax calculations", () => {
|
|||||||
const getCartResponse = await api.get(`/store/carts/${cartFactory.id}`)
|
const getCartResponse = await api.get(`/store/carts/${cartFactory.id}`)
|
||||||
const cart = getCartResponse.data.cart
|
const cart = getCartResponse.data.cart
|
||||||
await api.post(`/store/carts/${cart.id}/payment-sessions`)
|
await api.post(`/store/carts/${cart.id}/payment-sessions`)
|
||||||
const createdOrder = await api.post(`/store/carts/${cart.id}/complete-cart`)
|
const createdOrder = await api.post(
|
||||||
|
`/store/carts/${cart.id}/complete-cart`
|
||||||
|
)
|
||||||
|
|
||||||
expect(createdOrder.data.data).toEqual(
|
expect(createdOrder.data.data).toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
@@ -228,12 +251,12 @@ describe("Gift Card - Tax calculations", () => {
|
|||||||
refundable: 59500,
|
refundable: 59500,
|
||||||
tax_lines: expect.arrayContaining([
|
tax_lines: expect.arrayContaining([
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
rate: 19
|
rate: 19,
|
||||||
})
|
}),
|
||||||
]),
|
]),
|
||||||
})
|
}),
|
||||||
]),
|
]),
|
||||||
}),
|
})
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ describe("/store/carts", () => {
|
|||||||
cart_id: expect.stringMatching(/^cart_*/),
|
cart_id: expect.stringMatching(/^cart_*/),
|
||||||
cart: {
|
cart: {
|
||||||
id: expect.stringMatching(/^cart_*/),
|
id: expect.stringMatching(/^cart_*/),
|
||||||
|
sales_channel_id: expect.any(String),
|
||||||
billing_address_id: "test-billing-address",
|
billing_address_id: "test-billing-address",
|
||||||
type: "swap",
|
type: "swap",
|
||||||
created_at: expect.any(String),
|
created_at: expect.any(String),
|
||||||
@@ -201,6 +202,7 @@ describe("/store/carts", () => {
|
|||||||
cart_id: expect.stringMatching(/^cart_*/),
|
cart_id: expect.stringMatching(/^cart_*/),
|
||||||
cart: {
|
cart: {
|
||||||
id: expect.stringMatching(/^cart_*/),
|
id: expect.stringMatching(/^cart_*/),
|
||||||
|
sales_channel_id: expect.any(String),
|
||||||
billing_address_id: "test-billing-address",
|
billing_address_id: "test-billing-address",
|
||||||
shipping_address_id: "test-shipping-address",
|
shipping_address_id: "test-shipping-address",
|
||||||
type: "swap",
|
type: "swap",
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import {
|
|||||||
ProductTag,
|
ProductTag,
|
||||||
ProductType,
|
ProductType,
|
||||||
ShippingProfile,
|
ShippingProfile,
|
||||||
ShippingProfileType
|
ShippingProfileType,
|
||||||
|
Store
|
||||||
} from "@medusajs/medusa"
|
} from "@medusajs/medusa"
|
||||||
import faker from "faker"
|
import faker from "faker"
|
||||||
import { Connection } from "typeorm"
|
import { Connection } from "typeorm"
|
||||||
@@ -56,6 +57,21 @@ export const simpleProductFactory = async (
|
|||||||
await simpleSalesChannelFactory(connection, salesChannel)
|
await simpleSalesChannelFactory(connection, salesChannel)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
} else {
|
||||||
|
const store = await manager.findOne(Store, {
|
||||||
|
relations: ["default_sales_channel"],
|
||||||
|
})
|
||||||
|
|
||||||
|
if (store?.default_sales_channel) {
|
||||||
|
sales_channels = [store.default_sales_channel]
|
||||||
|
} else {
|
||||||
|
const salesChannel = await simpleSalesChannelFactory(connection, {
|
||||||
|
id: `default-${Math.random() * 1000}`,
|
||||||
|
is_default: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
sales_channels = [salesChannel]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const prodId = data.id || `simple-product-${Math.random() * 1000}`
|
const prodId = data.id || `simple-product-${Math.random() * 1000}`
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
const Scrypt = require("scrypt-kdf")
|
const Scrypt = require("scrypt-kdf")
|
||||||
const { User } = require("@medusajs/medusa")
|
const { User } = require("@medusajs/medusa")
|
||||||
|
const { simpleSalesChannelFactory } = require("../factories")
|
||||||
|
|
||||||
module.exports = async (connection, data = {}) => {
|
module.exports = async (connection, data = {}) => {
|
||||||
const manager = connection.manager
|
const manager = connection.manager
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ const {
|
|||||||
DiscountRule,
|
DiscountRule,
|
||||||
Payment,
|
Payment,
|
||||||
} = require("@medusajs/medusa")
|
} = require("@medusajs/medusa")
|
||||||
|
const { simpleSalesChannelFactory } = require("../factories")
|
||||||
|
|
||||||
module.exports = async (connection, data = {}) => {
|
module.exports = async (connection, data = {}) => {
|
||||||
const manager = connection.manager
|
const manager = connection.manager
|
||||||
@@ -23,6 +24,11 @@ module.exports = async (connection, data = {}) => {
|
|||||||
type: "default",
|
type: "default",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const salesChannel = await simpleSalesChannelFactory(connection, {
|
||||||
|
id: "sales-channel",
|
||||||
|
is_default: true,
|
||||||
|
})
|
||||||
|
|
||||||
await manager.insert(Product, {
|
await manager.insert(Product, {
|
||||||
id: "test-product",
|
id: "test-product",
|
||||||
title: "test product",
|
title: "test product",
|
||||||
@@ -30,6 +36,10 @@ module.exports = async (connection, data = {}) => {
|
|||||||
options: [{ id: "test-option", title: "Size" }],
|
options: [{ id: "test-option", title: "Size" }],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
await manager.query(
|
||||||
|
`insert into product_sales_channel values ('test-product', '${salesChannel.id}');`
|
||||||
|
)
|
||||||
|
|
||||||
await manager.insert(Address, {
|
await manager.insert(Address, {
|
||||||
id: "oli-shipping",
|
id: "oli-shipping",
|
||||||
first_name: "oli",
|
first_name: "oli",
|
||||||
@@ -44,6 +54,10 @@ module.exports = async (connection, data = {}) => {
|
|||||||
options: [{ id: "test-option-color", title: "Color" }],
|
options: [{ id: "test-option-color", title: "Color" }],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
await manager.query(
|
||||||
|
`insert into product_sales_channel values ('test-product-2', '${salesChannel.id}');`
|
||||||
|
)
|
||||||
|
|
||||||
await manager.insert(ProductVariant, {
|
await manager.insert(ProductVariant, {
|
||||||
id: "test-variant",
|
id: "test-variant",
|
||||||
title: "test variant",
|
title: "test variant",
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ const {
|
|||||||
ShippingProfile,
|
ShippingProfile,
|
||||||
Swap,
|
Swap,
|
||||||
} = require("@medusajs/medusa")
|
} = require("@medusajs/medusa")
|
||||||
|
const { simpleSalesChannelFactory } = require("../factories")
|
||||||
|
|
||||||
module.exports = async (connection, data = {}) => {
|
module.exports = async (connection, data = {}) => {
|
||||||
const manager = connection.manager
|
const manager = connection.manager
|
||||||
@@ -22,6 +23,11 @@ module.exports = async (connection, data = {}) => {
|
|||||||
type: "default",
|
type: "default",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const salesChannel = await simpleSalesChannelFactory(connection, {
|
||||||
|
id: "test-channel",
|
||||||
|
is_default: true,
|
||||||
|
})
|
||||||
|
|
||||||
await manager.insert(Product, {
|
await manager.insert(Product, {
|
||||||
id: "test-product",
|
id: "test-product",
|
||||||
title: "test product",
|
title: "test product",
|
||||||
@@ -29,6 +35,10 @@ module.exports = async (connection, data = {}) => {
|
|||||||
options: [{ id: "test-option", title: "Size" }],
|
options: [{ id: "test-option", title: "Size" }],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
await manager.query(
|
||||||
|
`insert into product_sales_channel values ('test-product', '${salesChannel.id}');`
|
||||||
|
)
|
||||||
|
|
||||||
await manager.insert(ProductVariant, {
|
await manager.insert(ProductVariant, {
|
||||||
id: "test-variant",
|
id: "test-variant",
|
||||||
title: "test variant",
|
title: "test variant",
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ const {
|
|||||||
ShippingProfile,
|
ShippingProfile,
|
||||||
ProductVariant,
|
ProductVariant,
|
||||||
Image,
|
Image,
|
||||||
|
Store,
|
||||||
} = require("@medusajs/medusa")
|
} = require("@medusajs/medusa")
|
||||||
|
|
||||||
module.exports = async (connection, data = {}) => {
|
module.exports = async (connection, data = {}) => {
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ Object {
|
|||||||
"object": "order",
|
"object": "order",
|
||||||
"payment_status": "captured",
|
"payment_status": "captured",
|
||||||
"region_id": "test-region",
|
"region_id": "test-region",
|
||||||
|
"sales_channel_id": null,
|
||||||
"shipping_address": Object {
|
"shipping_address": Object {
|
||||||
"address_1": "84185 Lindsey Centers",
|
"address_1": "84185 Lindsey Centers",
|
||||||
"address_2": null,
|
"address_2": null,
|
||||||
@@ -260,6 +261,7 @@ Object {
|
|||||||
"object": "order",
|
"object": "order",
|
||||||
"payment_status": "captured",
|
"payment_status": "captured",
|
||||||
"region_id": "test-region",
|
"region_id": "test-region",
|
||||||
|
"sales_channel_id": null,
|
||||||
"shipping_address": Object {
|
"shipping_address": Object {
|
||||||
"address_1": "84185 Lindsey Centers",
|
"address_1": "84185 Lindsey Centers",
|
||||||
"address_2": null,
|
"address_2": null,
|
||||||
@@ -579,6 +581,7 @@ Object {
|
|||||||
"updated_at": Any<Date>,
|
"updated_at": Any<Date>,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
"sales_channel_id": null,
|
||||||
"shipping_address": Object {
|
"shipping_address": Object {
|
||||||
"address_1": "84185 Lindsey Centers",
|
"address_1": "84185 Lindsey Centers",
|
||||||
"address_2": null,
|
"address_2": null,
|
||||||
@@ -897,6 +900,7 @@ Object {
|
|||||||
},
|
},
|
||||||
"region_id": "test-region",
|
"region_id": "test-region",
|
||||||
"returns": Array [],
|
"returns": Array [],
|
||||||
|
"sales_channel_id": null,
|
||||||
"shipping_address": Object {
|
"shipping_address": Object {
|
||||||
"address_1": "84185 Lindsey Centers",
|
"address_1": "84185 Lindsey Centers",
|
||||||
"address_2": null,
|
"address_2": null,
|
||||||
@@ -1149,6 +1153,7 @@ Object {
|
|||||||
},
|
},
|
||||||
"region_id": "test-region",
|
"region_id": "test-region",
|
||||||
"returns": Array [],
|
"returns": Array [],
|
||||||
|
"sales_channel_id": null,
|
||||||
"shipping_address": Object {
|
"shipping_address": Object {
|
||||||
"address_1": "84185 Lindsey Centers",
|
"address_1": "84185 Lindsey Centers",
|
||||||
"address_2": null,
|
"address_2": null,
|
||||||
@@ -1400,6 +1405,7 @@ Object {
|
|||||||
},
|
},
|
||||||
"region_id": "test-region",
|
"region_id": "test-region",
|
||||||
"returns": Array [],
|
"returns": Array [],
|
||||||
|
"sales_channel_id": null,
|
||||||
"shipping_address": Object {
|
"shipping_address": Object {
|
||||||
"address_1": "84185 Lindsey Centers",
|
"address_1": "84185 Lindsey Centers",
|
||||||
"address_2": null,
|
"address_2": null,
|
||||||
@@ -1754,6 +1760,7 @@ Object {
|
|||||||
"updated_at": Any<Date>,
|
"updated_at": Any<Date>,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
"sales_channel_id": null,
|
||||||
"shipping_address": Object {
|
"shipping_address": Object {
|
||||||
"address_1": "84185 Lindsey Centers",
|
"address_1": "84185 Lindsey Centers",
|
||||||
"address_2": null,
|
"address_2": null,
|
||||||
@@ -2168,6 +2175,7 @@ Object {
|
|||||||
"updated_at": Any<Date>,
|
"updated_at": Any<Date>,
|
||||||
},
|
},
|
||||||
"region_id": "test-region",
|
"region_id": "test-region",
|
||||||
|
"sales_channel_id": null,
|
||||||
"shipping_address_id": Any<String>,
|
"shipping_address_id": Any<String>,
|
||||||
"status": "pending",
|
"status": "pending",
|
||||||
"swaps": Array [
|
"swaps": Array [
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ describe("medusa-plugin-sendgrid", () => {
|
|||||||
const db = useDb()
|
const db = useDb()
|
||||||
await db.shutdown()
|
await db.shutdown()
|
||||||
express.close()
|
express.close()
|
||||||
// medusaProcess.kill()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
@@ -72,6 +71,7 @@ describe("medusa-plugin-sendgrid", () => {
|
|||||||
date: expect.any(String),
|
date: expect.any(String),
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
display_id: expect.any(Number),
|
display_id: expect.any(Number),
|
||||||
|
sales_channel_id: null,
|
||||||
created_at: expect.any(Date),
|
created_at: expect.any(Date),
|
||||||
canceled_at: expect.any(Date),
|
canceled_at: expect.any(Date),
|
||||||
updated_at: expect.any(Date),
|
updated_at: expect.any(Date),
|
||||||
@@ -678,6 +678,7 @@ describe("medusa-plugin-sendgrid", () => {
|
|||||||
items: [{ order_id: expect.any(String), ...itemSnap }],
|
items: [{ order_id: expect.any(String), ...itemSnap }],
|
||||||
customer_id: expect.any(String),
|
customer_id: expect.any(String),
|
||||||
shipping_address_id: expect.any(String),
|
shipping_address_id: expect.any(String),
|
||||||
|
sales_channel_id: null,
|
||||||
swaps: [swapSnap],
|
swaps: [swapSnap],
|
||||||
region: {
|
region: {
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
@@ -725,6 +726,7 @@ describe("medusa-plugin-sendgrid", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test("swap created data", async () => {
|
test("swap created data", async () => {
|
||||||
|
await simpleStoreFactory(dbConnection)
|
||||||
await adminSeeder(dbConnection)
|
await adminSeeder(dbConnection)
|
||||||
|
|
||||||
const order = await createReturnableOrder(dbConnection)
|
const order = await createReturnableOrder(dbConnection)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Connection } from "typeorm"
|
import { SalesChannel, Store } from "@medusajs/medusa"
|
||||||
import faker from "faker"
|
import faker from "faker"
|
||||||
import { Store } from "@medusajs/medusa"
|
import { Connection } from "typeorm"
|
||||||
|
|
||||||
export type StoreFactoryData = {
|
export type StoreFactoryData = {
|
||||||
swap_link_template?: string
|
swap_link_template?: string
|
||||||
@@ -20,5 +20,14 @@ export const simpleStoreFactory = async (
|
|||||||
|
|
||||||
store.swap_link_template = data.swap_link_template ?? "something/{cart_id}"
|
store.swap_link_template = data.swap_link_template ?? "something/{cart_id}"
|
||||||
|
|
||||||
return await manager.save(store)
|
await manager.insert(SalesChannel, {
|
||||||
|
id: "test-channel",
|
||||||
|
name: "Default"
|
||||||
|
})
|
||||||
|
|
||||||
|
const storeToSave = await manager.save(store)
|
||||||
|
|
||||||
|
await manager.query(`update store set default_sales_channel_id = 'test-channel' where id = '${storeToSave!.id}'`)
|
||||||
|
|
||||||
|
return storeToSave!
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ describe("GET /admin/orders", () => {
|
|||||||
"gift_card_tax_total",
|
"gift_card_tax_total",
|
||||||
].includes(field)
|
].includes(field)
|
||||||
}),
|
}),
|
||||||
relations: defaultAdminOrdersRelations,
|
relations: [...defaultAdminOrdersRelations],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,12 +4,11 @@ import { Order } from "../../../.."
|
|||||||
import {
|
import {
|
||||||
DeleteResponse,
|
DeleteResponse,
|
||||||
FindParams,
|
FindParams,
|
||||||
PaginatedResponse,
|
PaginatedResponse
|
||||||
} from "../../../../types/common"
|
} from "../../../../types/common"
|
||||||
|
import { FlagRouter } from "../../../../utils/flag-router"
|
||||||
import middlewares, { transformQuery } from "../../../middlewares"
|
import middlewares, { transformQuery } from "../../../middlewares"
|
||||||
import { AdminGetOrdersParams } from "./list-orders"
|
import { AdminGetOrdersParams } from "./list-orders"
|
||||||
import { FlagRouter } from "../../../../utils/flag-router"
|
|
||||||
import SalesChannelFeatureFlag from "../../../../loaders/feature-flags/sales-channels"
|
|
||||||
|
|
||||||
const route = Router()
|
const route = Router()
|
||||||
|
|
||||||
@@ -17,9 +16,6 @@ export default (app, featureFlagRouter: FlagRouter) => {
|
|||||||
app.use("/orders", route)
|
app.use("/orders", route)
|
||||||
|
|
||||||
const relations = [...defaultAdminOrdersRelations]
|
const relations = [...defaultAdminOrdersRelations]
|
||||||
if (featureFlagRouter.isFeatureEnabled(SalesChannelFeatureFlag.key)) {
|
|
||||||
relations.push("sales_channel")
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List orders
|
* List orders
|
||||||
@@ -286,6 +282,7 @@ export const defaultAdminOrdersRelations = [
|
|||||||
"swaps.additional_items",
|
"swaps.additional_items",
|
||||||
"swaps.fulfillments",
|
"swaps.fulfillments",
|
||||||
"swaps.fulfillments.tracking_links",
|
"swaps.fulfillments.tracking_links",
|
||||||
|
"sales_channel",
|
||||||
]
|
]
|
||||||
|
|
||||||
export const defaultAdminOrdersFields = [
|
export const defaultAdminOrdersFields = [
|
||||||
@@ -297,6 +294,7 @@ export const defaultAdminOrdersFields = [
|
|||||||
"cart_id",
|
"cart_id",
|
||||||
"draft_order_id",
|
"draft_order_id",
|
||||||
"customer_id",
|
"customer_id",
|
||||||
|
"sales_channel_id",
|
||||||
"email",
|
"email",
|
||||||
"region_id",
|
"region_id",
|
||||||
"currency_code",
|
"currency_code",
|
||||||
@@ -330,6 +328,7 @@ export const filterableAdminOrdersFields = [
|
|||||||
"customer_id",
|
"customer_id",
|
||||||
"email",
|
"email",
|
||||||
"region_id",
|
"region_id",
|
||||||
|
"sales_channel_id",
|
||||||
"currency_code",
|
"currency_code",
|
||||||
"tax_rate",
|
"tax_rate",
|
||||||
"canceled_at",
|
"canceled_at",
|
||||||
@@ -362,3 +361,4 @@ export * from "./refund-payment"
|
|||||||
export * from "./request-return"
|
export * from "./request-return"
|
||||||
export * from "./update-claim"
|
export * from "./update-claim"
|
||||||
export * from "./update-order"
|
export * from "./update-order"
|
||||||
|
|
||||||
@@ -65,6 +65,7 @@ describe("GET /admin/products/:id", () => {
|
|||||||
"tags",
|
"tags",
|
||||||
"type",
|
"type",
|
||||||
"collection",
|
"collection",
|
||||||
|
"sales_channels",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -23,10 +23,7 @@ describe("GET /admin/store", () => {
|
|||||||
it("calls service retrieve", () => {
|
it("calls service retrieve", () => {
|
||||||
expect(StoreServiceMock.retrieve).toHaveBeenCalledTimes(1)
|
expect(StoreServiceMock.retrieve).toHaveBeenCalledTimes(1)
|
||||||
expect(StoreServiceMock.retrieve).toHaveBeenCalledWith({
|
expect(StoreServiceMock.retrieve).toHaveBeenCalledWith({
|
||||||
relations: [
|
relations: ["currencies", "default_currency", "default_sales_channel"],
|
||||||
"currencies",
|
|
||||||
"default_currency",
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { FlagSettings } from "../../types/feature-flags"
|
|||||||
|
|
||||||
const SalesChannelFeatureFlag: FlagSettings = {
|
const SalesChannelFeatureFlag: FlagSettings = {
|
||||||
key: "sales_channels",
|
key: "sales_channels",
|
||||||
default_val: false,
|
default_val: true,
|
||||||
env_key: "MEDUSA_FF_SALES_CHANNELS",
|
env_key: "MEDUSA_FF_SALES_CHANNELS",
|
||||||
description: "[WIP] Enable the sales channels feature",
|
description: "[WIP] Enable the sales channels feature",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ export const orders = {
|
|||||||
testOrder: {
|
testOrder: {
|
||||||
id: IdMap.getId("test-order"),
|
id: IdMap.getId("test-order"),
|
||||||
email: "virgil@vandijk.dk",
|
email: "virgil@vandijk.dk",
|
||||||
|
sales_channel_id: "test-channel",
|
||||||
|
sales_channel: {
|
||||||
|
id: "test-channel",
|
||||||
|
},
|
||||||
billing_address: {
|
billing_address: {
|
||||||
first_name: "Virgil",
|
first_name: "Virgil",
|
||||||
last_name: "Van Dijk",
|
last_name: "Van Dijk",
|
||||||
|
|||||||
@@ -174,8 +174,6 @@ export default class EventBusService {
|
|||||||
(sub) => sub.id === subscriberId
|
(sub) => sub.id === subscriberId
|
||||||
)
|
)
|
||||||
|
|
||||||
console.log(subscriberId)
|
|
||||||
|
|
||||||
if (subscriberAlreadyExists) {
|
if (subscriberAlreadyExists) {
|
||||||
throw Error(`Subscriber with id ${subscriberId} already exists`)
|
throw Error(`Subscriber with id ${subscriberId} already exists`)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
/* eslint-disable valid-jsdoc */
|
/* eslint-disable valid-jsdoc */
|
||||||
import { EntityManager } from "typeorm"
|
|
||||||
import { computerizeAmount, MedusaError } from "medusa-core-utils"
|
import { computerizeAmount, MedusaError } from "medusa-core-utils"
|
||||||
|
import { EntityManager } from "typeorm"
|
||||||
|
|
||||||
import { AbstractBatchJobStrategy, IFileService } from "../../../interfaces"
|
import { AbstractBatchJobStrategy, IFileService } from "../../../interfaces"
|
||||||
import CsvParser from "../../../services/csv-parser"
|
import SalesChannelFeatureFlag from "../../../loaders/feature-flags/sales-channels"
|
||||||
|
import { BatchJob, SalesChannel } from "../../../models"
|
||||||
import {
|
import {
|
||||||
BatchJobService,
|
BatchJobService,
|
||||||
ProductCollectionService,
|
ProductCollectionService,
|
||||||
@@ -11,29 +12,28 @@ import {
|
|||||||
ProductVariantService,
|
ProductVariantService,
|
||||||
RegionService,
|
RegionService,
|
||||||
SalesChannelService,
|
SalesChannelService,
|
||||||
ShippingProfileService,
|
ShippingProfileService
|
||||||
} from "../../../services"
|
} from "../../../services"
|
||||||
|
import CsvParser from "../../../services/csv-parser"
|
||||||
import { CreateProductInput } from "../../../types/product"
|
import { CreateProductInput } from "../../../types/product"
|
||||||
import {
|
import {
|
||||||
CreateProductVariantInput,
|
CreateProductVariantInput,
|
||||||
UpdateProductVariantInput,
|
UpdateProductVariantInput
|
||||||
} from "../../../types/product-variant"
|
} from "../../../types/product-variant"
|
||||||
import { BatchJob, SalesChannel } from "../../../models"
|
|
||||||
import { FlagRouter } from "../../../utils/flag-router"
|
import { FlagRouter } from "../../../utils/flag-router"
|
||||||
import { transformProductData, transformVariantData } from "./utils"
|
|
||||||
import SalesChannelFeatureFlag from "../../../loaders/feature-flags/sales-channels"
|
|
||||||
import {
|
import {
|
||||||
OperationType,
|
OperationType,
|
||||||
ProductImportBatchJob,
|
ProductImportBatchJob,
|
||||||
ProductImportCsvSchema,
|
ProductImportCsvSchema,
|
||||||
ProductImportInjectedProps,
|
ProductImportInjectedProps,
|
||||||
ProductImportJobContext,
|
ProductImportJobContext,
|
||||||
TParsedProductImportRowData,
|
TParsedProductImportRowData
|
||||||
} from "./types"
|
} from "./types"
|
||||||
import {
|
import {
|
||||||
productImportColumnsDefinition,
|
productImportColumnsDefinition,
|
||||||
productImportSalesChannelsColumnsDefinition,
|
productImportSalesChannelsColumnsDefinition
|
||||||
} from "./types/columns-definition"
|
} from "./types/columns-definition"
|
||||||
|
import { transformProductData, transformVariantData } from "./utils"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process this many variant rows before reporting progress.
|
* Process this many variant rows before reporting progress.
|
||||||
@@ -462,7 +462,7 @@ class ProductImportStrategy extends AbstractBatchJobStrategy {
|
|||||||
for (const productOp of productOps) {
|
for (const productOp of productOps) {
|
||||||
const productData = transformProductData(productOp)
|
const productData = transformProductData(productOp)
|
||||||
try {
|
try {
|
||||||
if (isSalesChannelsFeatureOn) {
|
if (isSalesChannelsFeatureOn && productOp["product.sales_channels"]) {
|
||||||
productData["sales_channels"] = await this.processSalesChannels(
|
productData["sales_channels"] = await this.processSalesChannels(
|
||||||
productOp["product.sales_channels"] as Pick<
|
productOp["product.sales_channels"] as Pick<
|
||||||
SalesChannel,
|
SalesChannel,
|
||||||
|
|||||||
Reference in new issue
Block a user