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