chore(feature-flags): Remove OrderEditing feature flag (#3006)
This commit is contained in:
1 parent
d2c692aa96
commit
9e3beaf531
51 files changed
+300
-984
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
chore(feature-flags): Remove OrderEditing feature flag
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class uniquePaySessCartId1673550502785 implements MigrationInterface {
|
||||||
|
name = 'uniquePaySessCartId1673550502785'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`DROP INDEX "public"."UniqPaymentSessionCartIdProviderId"`);
|
||||||
|
await queryRunner.query(`CREATE UNIQUE INDEX "UniqPaymentSessionCartIdProviderId" ON "payment_session" ("cart_id", "provider_id") WHERE cart_id IS NOT NULL`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`DROP INDEX "public"."UniqPaymentSessionCartIdProviderId"`);
|
||||||
|
await queryRunner.query(`CREATE UNIQUE INDEX "UniqPaymentSessionCartIdProviderId" ON "payment_session" ("cart_id", "provider_id") `);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,17 +5,6 @@ import TabItem from '@theme/TabItem';
|
|||||||
|
|
||||||
In this document, you’ll learn how to create an order edit using the Admin API endpoints.
|
In this document, you’ll learn how to create an order edit using the Admin API endpoints.
|
||||||
|
|
||||||
:::note
|
|
||||||
|
|
||||||
The Order Editing feature is currently in beta mode and guarded by a feature flag. To use Order Editing either:
|
|
||||||
|
|
||||||
1. Enable the `MEDUSA_FF_ORDER_EDITING` environment variable;
|
|
||||||
2. Or enable the `order_editing` key in the Medusa server's settings.
|
|
||||||
|
|
||||||
You can learn more about enabling it in the [feature flags](../backend/feature-flags/toggle.md) documentation.
|
|
||||||
|
|
||||||
:::
|
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
The Admin API can be used to edit a customer’s order using the Order Editing feature.
|
The Admin API can be used to edit a customer’s order using the Order Editing feature.
|
||||||
|
|||||||
@@ -1492,17 +1492,6 @@ Object of the following format:
|
|||||||
|
|
||||||
This section holds all events related to order edits.
|
This section holds all events related to order edits.
|
||||||
|
|
||||||
:::note
|
|
||||||
|
|
||||||
As of Medusa v1.3.9, Order Edits are available but guarded by a feature flag. To use Order Edits either:
|
|
||||||
|
|
||||||
1. Enable the `MEDUSA_FF_ORDER_EDITING` environment variable;
|
|
||||||
2. Or enable the `order_editing` key in the Medusa server's settings.
|
|
||||||
|
|
||||||
You can learn more about enabling it in the [feature flags](../feature-flags/toggle.md) documentation.
|
|
||||||
|
|
||||||
:::
|
|
||||||
|
|
||||||
<table class="reference-table">
|
<table class="reference-table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -1671,17 +1660,6 @@ Object of the following format:
|
|||||||
|
|
||||||
This section holds all events related to order edit item changes.
|
This section holds all events related to order edit item changes.
|
||||||
|
|
||||||
:::note
|
|
||||||
|
|
||||||
As of Medusa v1.3.9, Order Edits are available but guarded by a feature flag. To use Order Edits either:
|
|
||||||
|
|
||||||
1. Enable the `MEDUSA_FF_ORDER_EDITING` environment variable;
|
|
||||||
2. Or enable the `order_editing` key in the Medusa server's settings.
|
|
||||||
|
|
||||||
You can learn more about enabling it in the [feature flags](../feature-flags/toggle.md) documentation.
|
|
||||||
|
|
||||||
:::
|
|
||||||
|
|
||||||
<table class="reference-table">
|
<table class="reference-table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@@ -5,17 +5,6 @@ import TabItem from '@theme/TabItem';
|
|||||||
|
|
||||||
In this document, you’ll learn how to allow a customer to confirm or decline an Order Edit.
|
In this document, you’ll learn how to allow a customer to confirm or decline an Order Edit.
|
||||||
|
|
||||||
:::note
|
|
||||||
|
|
||||||
The Order Editing feature is currently in beta mode and guarded by a feature flag. To use Order Editing either:
|
|
||||||
|
|
||||||
1. Enable the `MEDUSA_FF_ORDER_EDITING` environment variable;
|
|
||||||
2. Or enable the `order_editing` key in the Medusa server's settings.
|
|
||||||
|
|
||||||
You can learn more about enabling it in the [feature flags](../backend/feature-flags/toggle.md) documentation.
|
|
||||||
|
|
||||||
:::
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ const path = require("path")
|
|||||||
const startServerWithEnvironment =
|
const startServerWithEnvironment =
|
||||||
require("../../../helpers/start-server-with-environment").default
|
require("../../../helpers/start-server-with-environment").default
|
||||||
const { useApi } = require("../../../helpers/use-api")
|
const { useApi } = require("../../../helpers/use-api")
|
||||||
const { useDb } = require("../../../helpers/use-db")
|
const { useDb, initDb } = require("../../../helpers/use-db")
|
||||||
const adminSeeder = require("../../helpers/admin-seeder")
|
const adminSeeder = require("../../helpers/admin-seeder")
|
||||||
const {
|
const {
|
||||||
simpleOrderEditFactory,
|
simpleOrderEditFactory,
|
||||||
@@ -21,6 +21,7 @@ const {
|
|||||||
simpleRegionFactory,
|
simpleRegionFactory,
|
||||||
} = require("../../factories")
|
} = require("../../factories")
|
||||||
const { OrderEditItemChangeType, OrderEdit } = require("@medusajs/medusa")
|
const { OrderEditItemChangeType, OrderEdit } = require("@medusajs/medusa")
|
||||||
|
const setupServer = require("../../../helpers/setup-server")
|
||||||
|
|
||||||
jest.setTimeout(30000)
|
jest.setTimeout(30000)
|
||||||
|
|
||||||
@@ -30,19 +31,17 @@ const adminHeaders = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("[MEDUSA_FF_ORDER_EDITING] /admin/order-edits", () => {
|
describe("/admin/order-edits", () => {
|
||||||
let medusaProcess
|
let medusaProcess
|
||||||
let dbConnection
|
let dbConnection
|
||||||
const adminUserId = "admin_user"
|
const adminUserId = "admin_user"
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||||
const [process, connection] = await startServerWithEnvironment({
|
dbConnection = await initDb({ cwd })
|
||||||
|
medusaProcess = await setupServer({
|
||||||
cwd,
|
cwd,
|
||||||
env: { MEDUSA_FF_ORDER_EDITING: true },
|
|
||||||
})
|
})
|
||||||
dbConnection = connection
|
|
||||||
medusaProcess = process
|
|
||||||
})
|
})
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ const adminHeaders = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("[MEDUSA_FF_ORDER_EDITING] /admin/payment-collections", () => {
|
describe("/admin/payment-collections", () => {
|
||||||
let medusaProcess
|
let medusaProcess
|
||||||
let dbConnection
|
let dbConnection
|
||||||
|
|
||||||
@@ -27,7 +27,6 @@ describe("[MEDUSA_FF_ORDER_EDITING] /admin/payment-collections", () => {
|
|||||||
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: { MEDUSA_FF_ORDER_EDITING: true },
|
|
||||||
})
|
})
|
||||||
dbConnection = connection
|
dbConnection = connection
|
||||||
medusaProcess = process
|
medusaProcess = process
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ const adminHeaders = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("[MEDUSA_FF_ORDER_EDITING] /admin/payment", () => {
|
describe("/admin/payment", () => {
|
||||||
let medusaProcess
|
let medusaProcess
|
||||||
let dbConnection
|
let dbConnection
|
||||||
|
|
||||||
@@ -30,7 +30,6 @@ describe("[MEDUSA_FF_ORDER_EDITING] /admin/payment", () => {
|
|||||||
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: { MEDUSA_FF_ORDER_EDITING: true },
|
|
||||||
})
|
})
|
||||||
dbConnection = connection
|
dbConnection = connection
|
||||||
medusaProcess = process
|
medusaProcess = process
|
||||||
|
|||||||
@@ -1,153 +0,0 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
||||||
|
|
||||||
exports[`Claims creates a refund claim 1`] = `
|
|
||||||
Object {
|
|
||||||
"additional_items": Array [],
|
|
||||||
"canceled_at": null,
|
|
||||||
"claim_items": ArrayContaining [
|
|
||||||
ObjectContaining {
|
|
||||||
"item": Any<Object>,
|
|
||||||
"item_id": "test-item",
|
|
||||||
"quantity": 1,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"deleted_at": null,
|
|
||||||
"fulfillment_status": "not_fulfilled",
|
|
||||||
"fulfillments": Array [],
|
|
||||||
"id": StringMatching /\\^claim_\\*/,
|
|
||||||
"idempotency_key": Any<String>,
|
|
||||||
"metadata": null,
|
|
||||||
"no_notification": null,
|
|
||||||
"order_id": Any<String>,
|
|
||||||
"payment_status": "refunded",
|
|
||||||
"refund_amount": 1200,
|
|
||||||
"return_order": null,
|
|
||||||
"shipping_address": Any<Object>,
|
|
||||||
"shipping_address_id": Any<String>,
|
|
||||||
"shipping_methods": Array [],
|
|
||||||
"type": "refund",
|
|
||||||
"updated_at": Any<String>,
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`Claims creates a replace claim 1`] = `
|
|
||||||
Object {
|
|
||||||
"additional_items": Array [
|
|
||||||
Object {
|
|
||||||
"adjustments": Array [],
|
|
||||||
"allow_discounts": true,
|
|
||||||
"cart_id": null,
|
|
||||||
"claim_order_id": StringMatching /\\^claim_\\*/,
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"description": "Refined Wooden Chair",
|
|
||||||
"fulfilled_quantity": null,
|
|
||||||
"has_shipping": null,
|
|
||||||
"id": StringMatching /\\^item_\\*/,
|
|
||||||
"is_giftcard": false,
|
|
||||||
"is_return": false,
|
|
||||||
"metadata": Object {},
|
|
||||||
"order_id": null,
|
|
||||||
"quantity": 1,
|
|
||||||
"refundable": 113,
|
|
||||||
"returned_quantity": null,
|
|
||||||
"shipped_quantity": null,
|
|
||||||
"should_merge": true,
|
|
||||||
"swap_id": null,
|
|
||||||
"tax_lines": Array [
|
|
||||||
Object {
|
|
||||||
"code": "default",
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"id": StringMatching /\\^litl_\\*/,
|
|
||||||
"item_id": StringMatching /\\^item_\\*/,
|
|
||||||
"metadata": null,
|
|
||||||
"name": "default",
|
|
||||||
"rate": 12.5,
|
|
||||||
"updated_at": Any<String>,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"thumbnail": null,
|
|
||||||
"title": "Gorgeous Cotton Table",
|
|
||||||
"unit_price": 100,
|
|
||||||
"updated_at": Any<String>,
|
|
||||||
"variant": Object {
|
|
||||||
"allow_backorder": false,
|
|
||||||
"barcode": null,
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"deleted_at": null,
|
|
||||||
"ean": null,
|
|
||||||
"height": null,
|
|
||||||
"hs_code": null,
|
|
||||||
"id": "test-variant",
|
|
||||||
"inventory_quantity": 9,
|
|
||||||
"length": null,
|
|
||||||
"manage_inventory": true,
|
|
||||||
"material": null,
|
|
||||||
"metadata": null,
|
|
||||||
"mid_code": null,
|
|
||||||
"origin_country": null,
|
|
||||||
"product": Object {
|
|
||||||
"collection_id": null,
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"deleted_at": null,
|
|
||||||
"description": null,
|
|
||||||
"discountable": true,
|
|
||||||
"external_id": null,
|
|
||||||
"handle": null,
|
|
||||||
"height": null,
|
|
||||||
"hs_code": null,
|
|
||||||
"id": "test-product",
|
|
||||||
"is_giftcard": false,
|
|
||||||
"length": null,
|
|
||||||
"material": null,
|
|
||||||
"metadata": null,
|
|
||||||
"mid_code": null,
|
|
||||||
"origin_country": null,
|
|
||||||
"profile_id": StringMatching /\\^sp_\\*/,
|
|
||||||
"status": "draft",
|
|
||||||
"subtitle": null,
|
|
||||||
"thumbnail": null,
|
|
||||||
"title": "Gorgeous Cotton Table",
|
|
||||||
"type_id": null,
|
|
||||||
"updated_at": Any<String>,
|
|
||||||
"weight": null,
|
|
||||||
"width": null,
|
|
||||||
},
|
|
||||||
"product_id": "test-product",
|
|
||||||
"sku": null,
|
|
||||||
"title": "Refined Wooden Chair",
|
|
||||||
"upc": null,
|
|
||||||
"updated_at": Any<String>,
|
|
||||||
"weight": null,
|
|
||||||
"width": null,
|
|
||||||
},
|
|
||||||
"variant_id": "test-variant",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"canceled_at": null,
|
|
||||||
"claim_items": ArrayContaining [
|
|
||||||
ObjectContaining {
|
|
||||||
"item": Any<Object>,
|
|
||||||
"item_id": "test-item",
|
|
||||||
"quantity": 1,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"deleted_at": null,
|
|
||||||
"fulfillment_status": "not_fulfilled",
|
|
||||||
"fulfillments": Array [],
|
|
||||||
"id": StringMatching /\\^claim_\\*/,
|
|
||||||
"idempotency_key": Any<String>,
|
|
||||||
"metadata": null,
|
|
||||||
"no_notification": null,
|
|
||||||
"order_id": Any<String>,
|
|
||||||
"payment_status": "na",
|
|
||||||
"refund_amount": null,
|
|
||||||
"return_order": null,
|
|
||||||
"shipping_address": Any<Object>,
|
|
||||||
"shipping_address_id": Any<String>,
|
|
||||||
"shipping_methods": Array [],
|
|
||||||
"type": "replace",
|
|
||||||
"updated_at": Any<String>,
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
@@ -64,23 +64,20 @@ describe("Claims", () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.order.claims[0]).toMatchSnapshot({
|
expect(response.data.order.claims[0]).toEqual(
|
||||||
id: expect.stringMatching(/^claim_*/),
|
expect.objectContaining({
|
||||||
order_id: expect.any(String),
|
id: expect.stringMatching(/^claim_*/),
|
||||||
updated_at: expect.any(String),
|
order_id: expect.any(String),
|
||||||
created_at: expect.any(String),
|
refund_amount: 1200,
|
||||||
idempotency_key: expect.any(String),
|
claim_items: expect.arrayContaining([
|
||||||
shipping_address_id: expect.any(String),
|
expect.objectContaining({
|
||||||
refund_amount: 1200,
|
item: expect.any(Object),
|
||||||
shipping_address: expect.any(Object),
|
item_id: "test-item",
|
||||||
claim_items: expect.arrayContaining([
|
quantity: 1,
|
||||||
expect.objectContaining({
|
}),
|
||||||
item: expect.any(Object),
|
]),
|
||||||
item_id: "test-item",
|
})
|
||||||
quantity: 1,
|
)
|
||||||
}),
|
|
||||||
]),
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
test("creates a replace claim", async () => {
|
test("creates a replace claim", async () => {
|
||||||
@@ -110,49 +107,33 @@ describe("Claims", () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
expect(response.status).toEqual(200)
|
expect(response.status).toEqual(200)
|
||||||
expect(response.data.order.claims[0]).toMatchSnapshot({
|
expect(response.data.order.claims[0]).toEqual(
|
||||||
id: expect.stringMatching(/^claim_*/),
|
expect.objectContaining({
|
||||||
order_id: expect.any(String),
|
id: expect.stringMatching(/^claim_*/),
|
||||||
updated_at: expect.any(String),
|
order_id: expect.any(String),
|
||||||
created_at: expect.any(String),
|
additional_items: expect.arrayContaining([
|
||||||
idempotency_key: expect.any(String),
|
expect.objectContaining({
|
||||||
shipping_address_id: expect.any(String),
|
id: expect.stringMatching(/^item_*/),
|
||||||
refund_amount: null,
|
claim_order_id: expect.stringMatching(/^claim_*/),
|
||||||
shipping_address: expect.any(Object),
|
variant: expect.objectContaining({ id: "test-variant" }),
|
||||||
additional_items: [
|
tax_lines: expect.arrayContaining([
|
||||||
{
|
expect.objectContaining({
|
||||||
id: expect.stringMatching(/^item_*/),
|
id: expect.stringMatching(/^litl_*/),
|
||||||
claim_order_id: expect.stringMatching(/^claim_*/),
|
item_id: expect.stringMatching(/^item_*/),
|
||||||
created_at: expect.any(String),
|
rate: 12.5,
|
||||||
updated_at: expect.any(String),
|
}),
|
||||||
variant: {
|
]),
|
||||||
created_at: expect.any(String),
|
}),
|
||||||
updated_at: expect.any(String),
|
]),
|
||||||
product: {
|
claim_items: expect.arrayContaining([
|
||||||
profile_id: expect.stringMatching(/^sp_*/),
|
expect.objectContaining({
|
||||||
created_at: expect.any(String),
|
item: expect.any(Object),
|
||||||
updated_at: expect.any(String),
|
item_id: "test-item",
|
||||||
},
|
quantity: 1,
|
||||||
},
|
}),
|
||||||
tax_lines: [
|
]),
|
||||||
{
|
})
|
||||||
id: expect.stringMatching(/^litl_*/),
|
)
|
||||||
item_id: expect.stringMatching(/^item_*/),
|
|
||||||
created_at: expect.any(String),
|
|
||||||
updated_at: expect.any(String),
|
|
||||||
rate: 12.5,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
claim_items: expect.arrayContaining([
|
|
||||||
expect.objectContaining({
|
|
||||||
item: expect.any(Object),
|
|
||||||
item_id: "test-item",
|
|
||||||
quantity: 1,
|
|
||||||
}),
|
|
||||||
]),
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
test("creates a replace claim fulfillment", async () => {
|
test("creates a replace claim fulfillment", async () => {
|
||||||
|
|||||||
@@ -1,385 +0,0 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
||||||
|
|
||||||
exports[`/store/carts /store/swaps simple swap 1`] = `
|
|
||||||
Object {
|
|
||||||
"swap": Object {
|
|
||||||
"additional_items": Array [
|
|
||||||
Object {
|
|
||||||
"allow_discounts": true,
|
|
||||||
"cart_id": StringMatching /\\^cart_\\*/,
|
|
||||||
"claim_order_id": null,
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"description": "Swap product",
|
|
||||||
"fulfilled_quantity": null,
|
|
||||||
"has_shipping": null,
|
|
||||||
"id": StringMatching /\\^item_\\*/,
|
|
||||||
"is_giftcard": false,
|
|
||||||
"is_return": false,
|
|
||||||
"metadata": Object {},
|
|
||||||
"order_id": null,
|
|
||||||
"quantity": 1,
|
|
||||||
"returned_quantity": null,
|
|
||||||
"shipped_quantity": null,
|
|
||||||
"should_merge": true,
|
|
||||||
"swap_id": StringMatching /\\^swap_\\*/,
|
|
||||||
"thumbnail": null,
|
|
||||||
"title": "test product",
|
|
||||||
"unit_price": 8000,
|
|
||||||
"updated_at": Any<String>,
|
|
||||||
"variant": Object {
|
|
||||||
"allow_backorder": false,
|
|
||||||
"barcode": null,
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"deleted_at": null,
|
|
||||||
"ean": null,
|
|
||||||
"height": null,
|
|
||||||
"hs_code": null,
|
|
||||||
"id": "test-variant-2",
|
|
||||||
"inventory_quantity": 1,
|
|
||||||
"length": null,
|
|
||||||
"manage_inventory": true,
|
|
||||||
"material": null,
|
|
||||||
"metadata": null,
|
|
||||||
"mid_code": null,
|
|
||||||
"origin_country": null,
|
|
||||||
"product": Object {
|
|
||||||
"collection_id": null,
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"deleted_at": null,
|
|
||||||
"description": null,
|
|
||||||
"discountable": true,
|
|
||||||
"external_id": null,
|
|
||||||
"handle": null,
|
|
||||||
"height": null,
|
|
||||||
"hs_code": null,
|
|
||||||
"id": "test-product",
|
|
||||||
"is_giftcard": false,
|
|
||||||
"length": null,
|
|
||||||
"material": null,
|
|
||||||
"metadata": null,
|
|
||||||
"mid_code": null,
|
|
||||||
"origin_country": null,
|
|
||||||
"profile_id": StringMatching /\\^sp_\\*/,
|
|
||||||
"status": "draft",
|
|
||||||
"subtitle": null,
|
|
||||||
"thumbnail": null,
|
|
||||||
"title": "test product",
|
|
||||||
"type_id": null,
|
|
||||||
"updated_at": Any<String>,
|
|
||||||
"weight": null,
|
|
||||||
"width": null,
|
|
||||||
},
|
|
||||||
"product_id": "test-product",
|
|
||||||
"sku": null,
|
|
||||||
"title": "Swap product",
|
|
||||||
"upc": null,
|
|
||||||
"updated_at": Any<String>,
|
|
||||||
"weight": null,
|
|
||||||
"width": null,
|
|
||||||
},
|
|
||||||
"variant_id": "test-variant-2",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"cart": Object {
|
|
||||||
"billing_address_id": "test-billing-address",
|
|
||||||
"completed_at": null,
|
|
||||||
"context": Object {},
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"customer_id": "test-customer",
|
|
||||||
"deleted_at": null,
|
|
||||||
"email": "test@email.com",
|
|
||||||
"id": StringMatching /\\^cart_\\*/,
|
|
||||||
"idempotency_key": null,
|
|
||||||
"metadata": Object {
|
|
||||||
"parent_order_id": "test-order",
|
|
||||||
"swap_id": StringMatching /\\^swap_\\*/,
|
|
||||||
},
|
|
||||||
"object": "cart",
|
|
||||||
"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>,
|
|
||||||
},
|
|
||||||
"cart_id": StringMatching /\\^cart_\\*/,
|
|
||||||
"confirmed_at": null,
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"deleted_at": null,
|
|
||||||
"difference_due": null,
|
|
||||||
"fulfillment_status": "not_fulfilled",
|
|
||||||
"fulfillments": Array [],
|
|
||||||
"id": StringMatching /\\^swap_\\*/,
|
|
||||||
"idempotency_key": Any<String>,
|
|
||||||
"metadata": null,
|
|
||||||
"order": Object {
|
|
||||||
"billing_address_id": "test-billing-address",
|
|
||||||
"canceled_at": null,
|
|
||||||
"cart_id": null,
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"currency_code": "usd",
|
|
||||||
"customer_id": "test-customer",
|
|
||||||
"display_id": 1,
|
|
||||||
"draft_order_id": null,
|
|
||||||
"email": "test@email.com",
|
|
||||||
"external_id": null,
|
|
||||||
"fulfillment_status": "fulfilled",
|
|
||||||
"id": "test-order",
|
|
||||||
"idempotency_key": null,
|
|
||||||
"metadata": null,
|
|
||||||
"no_notification": null,
|
|
||||||
"object": "order",
|
|
||||||
"payment_status": "captured",
|
|
||||||
"region_id": "test-region",
|
|
||||||
"sales_channel_id": null,
|
|
||||||
"shipping_address_id": "test-shipping-address",
|
|
||||||
"status": "pending",
|
|
||||||
"tax_rate": 0,
|
|
||||||
"updated_at": Any<String>,
|
|
||||||
},
|
|
||||||
"order_id": "test-order",
|
|
||||||
"payment": null,
|
|
||||||
"payment_status": "not_paid",
|
|
||||||
"return_order": Object {
|
|
||||||
"claim_order_id": null,
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"id": StringMatching /\\^ret_\\*/,
|
|
||||||
"idempotency_key": null,
|
|
||||||
"items": Array [
|
|
||||||
Object {
|
|
||||||
"is_requested": true,
|
|
||||||
"item_id": "test-item",
|
|
||||||
"metadata": null,
|
|
||||||
"note": null,
|
|
||||||
"quantity": 1,
|
|
||||||
"reason_id": null,
|
|
||||||
"received_quantity": null,
|
|
||||||
"requested_quantity": 1,
|
|
||||||
"return_id": StringMatching /\\^ret_\\*/,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"location_id": null,
|
|
||||||
"metadata": null,
|
|
||||||
"no_notification": true,
|
|
||||||
"order_id": null,
|
|
||||||
"received_at": null,
|
|
||||||
"refund_amount": 7200,
|
|
||||||
"shipping_data": null,
|
|
||||||
"shipping_method": null,
|
|
||||||
"status": "requested",
|
|
||||||
"swap_id": StringMatching /\\^swap_\\*/,
|
|
||||||
"updated_at": Any<String>,
|
|
||||||
},
|
|
||||||
"shipping_address": null,
|
|
||||||
"shipping_address_id": null,
|
|
||||||
"shipping_methods": Array [],
|
|
||||||
"updated_at": Any<String>,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`/store/carts /store/swaps swap with return shipping 1`] = `
|
|
||||||
Object {
|
|
||||||
"swap": Object {
|
|
||||||
"additional_items": Array [
|
|
||||||
Object {
|
|
||||||
"allow_discounts": true,
|
|
||||||
"cart_id": StringMatching /\\^cart_\\*/,
|
|
||||||
"claim_order_id": null,
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"description": "Swap product",
|
|
||||||
"fulfilled_quantity": null,
|
|
||||||
"has_shipping": null,
|
|
||||||
"id": StringMatching /\\^item_\\*/,
|
|
||||||
"is_giftcard": false,
|
|
||||||
"is_return": false,
|
|
||||||
"metadata": Object {},
|
|
||||||
"order_id": null,
|
|
||||||
"quantity": 1,
|
|
||||||
"returned_quantity": null,
|
|
||||||
"shipped_quantity": null,
|
|
||||||
"should_merge": true,
|
|
||||||
"swap_id": StringMatching /\\^swap_\\*/,
|
|
||||||
"thumbnail": null,
|
|
||||||
"title": "test product",
|
|
||||||
"unit_price": 8000,
|
|
||||||
"updated_at": Any<String>,
|
|
||||||
"variant": Object {
|
|
||||||
"allow_backorder": false,
|
|
||||||
"barcode": null,
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"deleted_at": null,
|
|
||||||
"ean": null,
|
|
||||||
"height": null,
|
|
||||||
"hs_code": null,
|
|
||||||
"id": "test-variant-2",
|
|
||||||
"inventory_quantity": 1,
|
|
||||||
"length": null,
|
|
||||||
"manage_inventory": true,
|
|
||||||
"material": null,
|
|
||||||
"metadata": null,
|
|
||||||
"mid_code": null,
|
|
||||||
"origin_country": null,
|
|
||||||
"product": Object {
|
|
||||||
"collection_id": null,
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"deleted_at": null,
|
|
||||||
"description": null,
|
|
||||||
"discountable": true,
|
|
||||||
"external_id": null,
|
|
||||||
"handle": null,
|
|
||||||
"height": null,
|
|
||||||
"hs_code": null,
|
|
||||||
"id": "test-product",
|
|
||||||
"is_giftcard": false,
|
|
||||||
"length": null,
|
|
||||||
"material": null,
|
|
||||||
"metadata": null,
|
|
||||||
"mid_code": null,
|
|
||||||
"origin_country": null,
|
|
||||||
"profile_id": StringMatching /\\^sp_\\*/,
|
|
||||||
"status": "draft",
|
|
||||||
"subtitle": null,
|
|
||||||
"thumbnail": null,
|
|
||||||
"title": "test product",
|
|
||||||
"type_id": null,
|
|
||||||
"updated_at": Any<String>,
|
|
||||||
"weight": null,
|
|
||||||
"width": null,
|
|
||||||
},
|
|
||||||
"product_id": "test-product",
|
|
||||||
"sku": null,
|
|
||||||
"title": "Swap product",
|
|
||||||
"upc": null,
|
|
||||||
"updated_at": Any<String>,
|
|
||||||
"weight": null,
|
|
||||||
"width": null,
|
|
||||||
},
|
|
||||||
"variant_id": "test-variant-2",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"cart": Object {
|
|
||||||
"billing_address_id": "test-billing-address",
|
|
||||||
"completed_at": null,
|
|
||||||
"context": Object {},
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"customer_id": "test-customer",
|
|
||||||
"deleted_at": null,
|
|
||||||
"email": "test@email.com",
|
|
||||||
"id": StringMatching /\\^cart_\\*/,
|
|
||||||
"idempotency_key": null,
|
|
||||||
"metadata": Object {
|
|
||||||
"parent_order_id": "test-order",
|
|
||||||
"swap_id": StringMatching /\\^swap_\\*/,
|
|
||||||
},
|
|
||||||
"object": "cart",
|
|
||||||
"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>,
|
|
||||||
},
|
|
||||||
"cart_id": StringMatching /\\^cart_\\*/,
|
|
||||||
"confirmed_at": null,
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"deleted_at": null,
|
|
||||||
"difference_due": null,
|
|
||||||
"fulfillment_status": "not_fulfilled",
|
|
||||||
"fulfillments": Array [],
|
|
||||||
"id": StringMatching /\\^swap_\\*/,
|
|
||||||
"idempotency_key": Any<String>,
|
|
||||||
"metadata": null,
|
|
||||||
"order": Object {
|
|
||||||
"billing_address_id": "test-billing-address",
|
|
||||||
"canceled_at": null,
|
|
||||||
"cart_id": null,
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"currency_code": "usd",
|
|
||||||
"customer_id": "test-customer",
|
|
||||||
"display_id": Any<Number>,
|
|
||||||
"draft_order_id": null,
|
|
||||||
"email": "test@email.com",
|
|
||||||
"external_id": null,
|
|
||||||
"fulfillment_status": "fulfilled",
|
|
||||||
"id": "test-order",
|
|
||||||
"idempotency_key": null,
|
|
||||||
"metadata": null,
|
|
||||||
"no_notification": null,
|
|
||||||
"object": "order",
|
|
||||||
"payment_status": "captured",
|
|
||||||
"region_id": "test-region",
|
|
||||||
"sales_channel_id": null,
|
|
||||||
"shipping_address_id": "test-shipping-address",
|
|
||||||
"status": "pending",
|
|
||||||
"tax_rate": 0,
|
|
||||||
"updated_at": Any<String>,
|
|
||||||
},
|
|
||||||
"order_id": "test-order",
|
|
||||||
"payment": null,
|
|
||||||
"payment_status": "not_paid",
|
|
||||||
"return_order": Object {
|
|
||||||
"claim_order_id": null,
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"id": StringMatching /\\^ret_\\*/,
|
|
||||||
"idempotency_key": null,
|
|
||||||
"items": Array [
|
|
||||||
Object {
|
|
||||||
"is_requested": true,
|
|
||||||
"item_id": "test-item",
|
|
||||||
"metadata": null,
|
|
||||||
"note": null,
|
|
||||||
"quantity": 1,
|
|
||||||
"reason_id": null,
|
|
||||||
"received_quantity": null,
|
|
||||||
"requested_quantity": 1,
|
|
||||||
"return_id": StringMatching /\\^ret_\\*/,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"location_id": null,
|
|
||||||
"metadata": null,
|
|
||||||
"no_notification": true,
|
|
||||||
"order_id": null,
|
|
||||||
"received_at": null,
|
|
||||||
"refund_amount": 6200,
|
|
||||||
"shipping_data": Object {},
|
|
||||||
"shipping_method": Object {
|
|
||||||
"cart_id": null,
|
|
||||||
"claim_order_id": null,
|
|
||||||
"data": Object {},
|
|
||||||
"id": StringMatching /\\^sm_\\*/,
|
|
||||||
"order_id": null,
|
|
||||||
"price": 1000,
|
|
||||||
"return_id": StringMatching /\\^ret_\\*/,
|
|
||||||
"shipping_option": Object {
|
|
||||||
"admin_only": false,
|
|
||||||
"amount": 1000,
|
|
||||||
"created_at": Any<String>,
|
|
||||||
"data": Object {},
|
|
||||||
"deleted_at": null,
|
|
||||||
"id": "return-option",
|
|
||||||
"is_return": true,
|
|
||||||
"metadata": null,
|
|
||||||
"name": "Test ret",
|
|
||||||
"price_type": "flat_rate",
|
|
||||||
"profile_id": StringMatching /\\^sp_\\*/,
|
|
||||||
"provider_id": "test-ful",
|
|
||||||
"region_id": "test-region",
|
|
||||||
"updated_at": Any<String>,
|
|
||||||
},
|
|
||||||
"shipping_option_id": "return-option",
|
|
||||||
"swap_id": null,
|
|
||||||
},
|
|
||||||
"status": "requested",
|
|
||||||
"swap_id": StringMatching /\\^swap_\\*/,
|
|
||||||
"updated_at": Any<String>,
|
|
||||||
},
|
|
||||||
"shipping_address": null,
|
|
||||||
"shipping_address_id": null,
|
|
||||||
"shipping_methods": Array [],
|
|
||||||
"updated_at": Any<String>,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
@@ -3,7 +3,7 @@ const path = require("path")
|
|||||||
const startServerWithEnvironment =
|
const startServerWithEnvironment =
|
||||||
require("../../../helpers/start-server-with-environment").default
|
require("../../../helpers/start-server-with-environment").default
|
||||||
const { useApi } = require("../../../helpers/use-api")
|
const { useApi } = require("../../../helpers/use-api")
|
||||||
const { useDb } = require("../../../helpers/use-db")
|
const { useDb, initDb } = require("../../../helpers/use-db")
|
||||||
const adminSeeder = require("../../helpers/admin-seeder")
|
const adminSeeder = require("../../helpers/admin-seeder")
|
||||||
const {
|
const {
|
||||||
getClientAuthenticationCookie,
|
getClientAuthenticationCookie,
|
||||||
@@ -22,21 +22,20 @@ const {
|
|||||||
simpleCustomerFactory,
|
simpleCustomerFactory,
|
||||||
} = require("../../factories")
|
} = require("../../factories")
|
||||||
const { OrderEditItemChangeType } = require("@medusajs/medusa")
|
const { OrderEditItemChangeType } = require("@medusajs/medusa")
|
||||||
|
const setupServer = require("../../../helpers/setup-server")
|
||||||
|
|
||||||
jest.setTimeout(30000)
|
jest.setTimeout(30000)
|
||||||
|
|
||||||
describe("[MEDUSA_FF_ORDER_EDITING] /store/order-edits", () => {
|
describe("/store/order-edits", () => {
|
||||||
let medusaProcess
|
let medusaProcess
|
||||||
let dbConnection
|
let dbConnection
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||||
const [process, connection] = await startServerWithEnvironment({
|
dbConnection = await initDb({ cwd })
|
||||||
|
medusaProcess = await setupServer({
|
||||||
cwd,
|
cwd,
|
||||||
env: { MEDUSA_FF_ORDER_EDITING: true },
|
|
||||||
})
|
})
|
||||||
dbConnection = connection
|
|
||||||
medusaProcess = process
|
|
||||||
|
|
||||||
await simpleCustomerFactory(dbConnection, {
|
await simpleCustomerFactory(dbConnection, {
|
||||||
id: "customer",
|
id: "customer",
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ const {
|
|||||||
|
|
||||||
jest.setTimeout(30000)
|
jest.setTimeout(30000)
|
||||||
|
|
||||||
describe("[MEDUSA_FF_ORDER_EDITING] /store/payment-collections", () => {
|
describe("/store/payment-collections", () => {
|
||||||
let medusaProcess
|
let medusaProcess
|
||||||
let dbConnection
|
let dbConnection
|
||||||
|
|
||||||
@@ -27,7 +27,6 @@ describe("[MEDUSA_FF_ORDER_EDITING] /store/payment-collections", () => {
|
|||||||
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: { MEDUSA_FF_ORDER_EDITING: true },
|
|
||||||
})
|
})
|
||||||
dbConnection = connection
|
dbConnection = connection
|
||||||
medusaProcess = process
|
medusaProcess = process
|
||||||
|
|||||||
@@ -81,67 +81,50 @@ describe("/store/carts", () => {
|
|||||||
console.log(err.response.data.message)
|
console.log(err.response.data.message)
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(response.data).toMatchSnapshot({
|
expect(response.data).toEqual(
|
||||||
swap: {
|
expect.objectContaining({
|
||||||
id: expect.stringMatching(/^swap_*/),
|
swap: expect.objectContaining({
|
||||||
idempotency_key: expect.any(String),
|
id: expect.stringMatching(/^swap_*/),
|
||||||
additional_items: [
|
additional_items: expect.arrayContaining([
|
||||||
{
|
expect.objectContaining({
|
||||||
id: expect.stringMatching(/^item_*/),
|
id: expect.stringMatching(/^item_*/),
|
||||||
cart_id: expect.stringMatching(/^cart_*/),
|
cart_id: expect.stringMatching(/^cart_*/),
|
||||||
swap_id: expect.stringMatching(/^swap_*/),
|
swap_id: expect.stringMatching(/^swap_*/),
|
||||||
variant: {
|
variant: expect.objectContaining({
|
||||||
id: "test-variant-2",
|
id: "test-variant-2",
|
||||||
created_at: expect.any(String),
|
}),
|
||||||
updated_at: expect.any(String),
|
|
||||||
product: {
|
|
||||||
profile_id: expect.stringMatching(/^sp_*/),
|
|
||||||
created_at: expect.any(String),
|
|
||||||
updated_at: expect.any(String),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
quantity: 1,
|
|
||||||
variant_id: "test-variant-2",
|
|
||||||
created_at: expect.any(String),
|
|
||||||
updated_at: expect.any(String),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
order: {
|
|
||||||
id: "test-order",
|
|
||||||
created_at: expect.any(String),
|
|
||||||
updated_at: expect.any(String),
|
|
||||||
},
|
|
||||||
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),
|
|
||||||
updated_at: expect.any(String),
|
|
||||||
shipping_address_id: "test-shipping-address",
|
|
||||||
metadata: {
|
|
||||||
swap_id: expect.stringMatching(/^swap_*/),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
return_order: {
|
|
||||||
id: expect.stringMatching(/^ret_*/),
|
|
||||||
swap_id: expect.stringMatching(/^swap_*/),
|
|
||||||
refund_amount: 7200,
|
|
||||||
items: [
|
|
||||||
{
|
|
||||||
item_id: "test-item",
|
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
return_id: expect.stringMatching(/^ret_*/),
|
variant_id: "test-variant-2",
|
||||||
},
|
}),
|
||||||
],
|
]),
|
||||||
created_at: expect.any(String),
|
order: expect.objectContaining({
|
||||||
updated_at: expect.any(String),
|
id: "test-order",
|
||||||
},
|
}),
|
||||||
created_at: expect.any(String),
|
cart_id: expect.stringMatching(/^cart_*/),
|
||||||
updated_at: expect.any(String),
|
cart: expect.objectContaining({
|
||||||
},
|
id: expect.stringMatching(/^cart_*/),
|
||||||
})
|
billing_address_id: "test-billing-address",
|
||||||
|
type: "swap",
|
||||||
|
shipping_address_id: "test-shipping-address",
|
||||||
|
metadata: expect.objectContaining({
|
||||||
|
swap_id: expect.stringMatching(/^swap_*/),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
return_order: expect.objectContaining({
|
||||||
|
id: expect.stringMatching(/^ret_*/),
|
||||||
|
swap_id: expect.stringMatching(/^swap_*/),
|
||||||
|
refund_amount: 7200,
|
||||||
|
items: expect.arrayContaining([
|
||||||
|
expect.objectContaining({
|
||||||
|
item_id: "test-item",
|
||||||
|
quantity: 1,
|
||||||
|
return_id: expect.stringMatching(/^ret_*/),
|
||||||
|
}),
|
||||||
|
]),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("swap with return shipping", async () => {
|
it("swap with return shipping", async () => {
|
||||||
@@ -168,76 +151,54 @@ describe("/store/carts", () => {
|
|||||||
console.log(err.response.data.message)
|
console.log(err.response.data.message)
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(response.data).toMatchSnapshot({
|
expect(response.data).toEqual({
|
||||||
swap: {
|
swap: expect.objectContaining({
|
||||||
id: expect.stringMatching(/^swap_*/),
|
id: expect.stringMatching(/^swap_*/),
|
||||||
idempotency_key: expect.any(String),
|
additional_items: expect.arrayContaining([
|
||||||
additional_items: [
|
expect.objectContaining({
|
||||||
{
|
|
||||||
id: expect.stringMatching(/^item_*/),
|
id: expect.stringMatching(/^item_*/),
|
||||||
cart_id: expect.stringMatching(/^cart_*/),
|
cart_id: expect.stringMatching(/^cart_*/),
|
||||||
swap_id: expect.stringMatching(/^swap_*/),
|
swap_id: expect.stringMatching(/^swap_*/),
|
||||||
variant: {
|
variant: expect.objectContaining({
|
||||||
id: "test-variant-2",
|
id: "test-variant-2",
|
||||||
created_at: expect.any(String),
|
}),
|
||||||
updated_at: expect.any(String),
|
|
||||||
product: {
|
|
||||||
profile_id: expect.stringMatching(/^sp_*/),
|
|
||||||
created_at: expect.any(String),
|
|
||||||
updated_at: expect.any(String),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
variant_id: "test-variant-2",
|
variant_id: "test-variant-2",
|
||||||
created_at: expect.any(String),
|
}),
|
||||||
updated_at: expect.any(String),
|
]),
|
||||||
},
|
order: expect.objectContaining({
|
||||||
],
|
|
||||||
order: {
|
|
||||||
id: "test-order",
|
id: "test-order",
|
||||||
display_id: expect.any(Number),
|
}),
|
||||||
created_at: expect.any(String),
|
|
||||||
updated_at: expect.any(String),
|
|
||||||
},
|
|
||||||
cart_id: expect.stringMatching(/^cart_*/),
|
cart_id: expect.stringMatching(/^cart_*/),
|
||||||
cart: {
|
cart: expect.objectContaining({
|
||||||
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",
|
||||||
created_at: expect.any(String),
|
metadata: expect.objectContaining({
|
||||||
updated_at: expect.any(String),
|
|
||||||
metadata: {
|
|
||||||
swap_id: expect.stringMatching(/^swap_*/),
|
swap_id: expect.stringMatching(/^swap_*/),
|
||||||
},
|
}),
|
||||||
},
|
}),
|
||||||
return_order: {
|
return_order: expect.objectContaining({
|
||||||
id: expect.stringMatching(/^ret_*/),
|
id: expect.stringMatching(/^ret_*/),
|
||||||
swap_id: expect.stringMatching(/^swap_*/),
|
swap_id: expect.stringMatching(/^swap_*/),
|
||||||
refund_amount: 6200,
|
refund_amount: 6200,
|
||||||
shipping_method: {
|
shipping_method: expect.objectContaining({
|
||||||
id: expect.stringMatching(/^sm_*/),
|
id: expect.stringMatching(/^sm_*/),
|
||||||
return_id: expect.stringMatching(/^ret_*/),
|
return_id: expect.stringMatching(/^ret_*/),
|
||||||
shipping_option: {
|
shipping_option: expect.objectContaining({
|
||||||
profile_id: expect.stringMatching(/^sp_*/),
|
profile_id: expect.stringMatching(/^sp_*/),
|
||||||
created_at: expect.any(String),
|
}),
|
||||||
updated_at: expect.any(String),
|
}),
|
||||||
},
|
items: expect.arrayContaining([
|
||||||
},
|
expect.objectContaining({
|
||||||
items: [
|
|
||||||
{
|
|
||||||
item_id: "test-item",
|
item_id: "test-item",
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
return_id: expect.stringMatching(/^ret_*/),
|
return_id: expect.stringMatching(/^ret_*/),
|
||||||
},
|
}),
|
||||||
],
|
]),
|
||||||
created_at: expect.any(String),
|
}),
|
||||||
updated_at: expect.any(String),
|
}),
|
||||||
},
|
|
||||||
created_at: expect.any(String),
|
|
||||||
updated_at: expect.any(String),
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -18,9 +18,11 @@ const startServerWithEnvironment = async ({
|
|||||||
cwd,
|
cwd,
|
||||||
})
|
})
|
||||||
|
|
||||||
Object.entries(env).forEach(([key]) => {
|
if (env) {
|
||||||
delete process.env[key]
|
Object.entries(env).forEach(([key]) => {
|
||||||
})
|
delete process.env[key]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const medusaProcess = await setupServer({
|
const medusaProcess = await setupServer({
|
||||||
cwd,
|
cwd,
|
||||||
|
|||||||
+30
@@ -38,7 +38,9 @@ Object {
|
|||||||
"is_giftcard": false,
|
"is_giftcard": false,
|
||||||
"is_return": false,
|
"is_return": false,
|
||||||
"metadata": null,
|
"metadata": null,
|
||||||
|
"order_edit_id": null,
|
||||||
"order_id": Any<String>,
|
"order_id": Any<String>,
|
||||||
|
"original_item_id": null,
|
||||||
"quantity": 2,
|
"quantity": 2,
|
||||||
"returned_quantity": null,
|
"returned_quantity": null,
|
||||||
"shipped_quantity": 2,
|
"shipped_quantity": 2,
|
||||||
@@ -192,7 +194,9 @@ Object {
|
|||||||
"is_giftcard": false,
|
"is_giftcard": false,
|
||||||
"is_return": false,
|
"is_return": false,
|
||||||
"metadata": null,
|
"metadata": null,
|
||||||
|
"order_edit_id": null,
|
||||||
"order_id": Any<String>,
|
"order_id": Any<String>,
|
||||||
|
"original_item_id": null,
|
||||||
"quantity": 2,
|
"quantity": 2,
|
||||||
"returned_quantity": null,
|
"returned_quantity": null,
|
||||||
"shipped_quantity": 2,
|
"shipped_quantity": 2,
|
||||||
@@ -308,7 +312,9 @@ Object {
|
|||||||
"is_giftcard": false,
|
"is_giftcard": false,
|
||||||
"is_return": false,
|
"is_return": false,
|
||||||
"metadata": null,
|
"metadata": null,
|
||||||
|
"order_edit_id": null,
|
||||||
"order_id": Any<String>,
|
"order_id": Any<String>,
|
||||||
|
"original_item_id": null,
|
||||||
"price": "12.00 USD",
|
"price": "12.00 USD",
|
||||||
"quantity": 1,
|
"quantity": 1,
|
||||||
"returned_quantity": 1,
|
"returned_quantity": 1,
|
||||||
@@ -442,7 +448,9 @@ Object {
|
|||||||
"is_giftcard": false,
|
"is_giftcard": false,
|
||||||
"is_return": false,
|
"is_return": false,
|
||||||
"metadata": null,
|
"metadata": null,
|
||||||
|
"order_edit_id": null,
|
||||||
"order_id": Any<String>,
|
"order_id": Any<String>,
|
||||||
|
"original_item_id": null,
|
||||||
"original_tax_total": 400,
|
"original_tax_total": 400,
|
||||||
"original_total": 2400,
|
"original_total": 2400,
|
||||||
"quantity": 2,
|
"quantity": 2,
|
||||||
@@ -629,7 +637,9 @@ Object {
|
|||||||
"is_giftcard": false,
|
"is_giftcard": false,
|
||||||
"is_return": false,
|
"is_return": false,
|
||||||
"metadata": null,
|
"metadata": null,
|
||||||
|
"order_edit_id": null,
|
||||||
"order_id": Any<String>,
|
"order_id": Any<String>,
|
||||||
|
"original_item_id": null,
|
||||||
"quantity": 2,
|
"quantity": 2,
|
||||||
"returned_quantity": 1,
|
"returned_quantity": 1,
|
||||||
"shipped_quantity": 2,
|
"shipped_quantity": 2,
|
||||||
@@ -787,7 +797,9 @@ Object {
|
|||||||
"is_giftcard": false,
|
"is_giftcard": false,
|
||||||
"is_return": false,
|
"is_return": false,
|
||||||
"metadata": null,
|
"metadata": null,
|
||||||
|
"order_edit_id": null,
|
||||||
"order_id": Any<String>,
|
"order_id": Any<String>,
|
||||||
|
"original_item_id": null,
|
||||||
"original_tax_total": 400,
|
"original_tax_total": 400,
|
||||||
"original_total": 2400,
|
"original_total": 2400,
|
||||||
"price": "10.00 USD",
|
"price": "10.00 USD",
|
||||||
@@ -1018,7 +1030,9 @@ Object {
|
|||||||
"is_giftcard": false,
|
"is_giftcard": false,
|
||||||
"is_return": false,
|
"is_return": false,
|
||||||
"metadata": null,
|
"metadata": null,
|
||||||
|
"order_edit_id": null,
|
||||||
"order_id": Any<String>,
|
"order_id": Any<String>,
|
||||||
|
"original_item_id": null,
|
||||||
"original_tax_total": 400,
|
"original_tax_total": 400,
|
||||||
"original_total": 2400,
|
"original_total": 2400,
|
||||||
"price": "12.00 USD",
|
"price": "12.00 USD",
|
||||||
@@ -1293,7 +1307,9 @@ Object {
|
|||||||
"is_giftcard": false,
|
"is_giftcard": false,
|
||||||
"is_return": false,
|
"is_return": false,
|
||||||
"metadata": null,
|
"metadata": null,
|
||||||
|
"order_edit_id": null,
|
||||||
"order_id": Any<String>,
|
"order_id": Any<String>,
|
||||||
|
"original_item_id": null,
|
||||||
"original_tax_total": 400,
|
"original_tax_total": 400,
|
||||||
"original_total": 2400,
|
"original_total": 2400,
|
||||||
"quantity": 2,
|
"quantity": 2,
|
||||||
@@ -1487,7 +1503,9 @@ Object {
|
|||||||
"is_giftcard": false,
|
"is_giftcard": false,
|
||||||
"is_return": false,
|
"is_return": false,
|
||||||
"metadata": null,
|
"metadata": null,
|
||||||
|
"order_edit_id": null,
|
||||||
"order_id": Any<String>,
|
"order_id": Any<String>,
|
||||||
|
"original_item_id": null,
|
||||||
"price": "12.00 USD",
|
"price": "12.00 USD",
|
||||||
"quantity": 1,
|
"quantity": 1,
|
||||||
"returned_quantity": null,
|
"returned_quantity": null,
|
||||||
@@ -1621,7 +1639,9 @@ Object {
|
|||||||
"is_giftcard": false,
|
"is_giftcard": false,
|
||||||
"is_return": false,
|
"is_return": false,
|
||||||
"metadata": null,
|
"metadata": null,
|
||||||
|
"order_edit_id": null,
|
||||||
"order_id": Any<String>,
|
"order_id": Any<String>,
|
||||||
|
"original_item_id": null,
|
||||||
"original_tax_total": 400,
|
"original_tax_total": 400,
|
||||||
"original_total": 2400,
|
"original_total": 2400,
|
||||||
"quantity": 2,
|
"quantity": 2,
|
||||||
@@ -1808,7 +1828,9 @@ Object {
|
|||||||
"is_giftcard": false,
|
"is_giftcard": false,
|
||||||
"is_return": false,
|
"is_return": false,
|
||||||
"metadata": null,
|
"metadata": null,
|
||||||
|
"order_edit_id": null,
|
||||||
"order_id": Any<String>,
|
"order_id": Any<String>,
|
||||||
|
"original_item_id": null,
|
||||||
"quantity": 2,
|
"quantity": 2,
|
||||||
"returned_quantity": null,
|
"returned_quantity": null,
|
||||||
"shipped_quantity": 2,
|
"shipped_quantity": 2,
|
||||||
@@ -1966,7 +1988,9 @@ Object {
|
|||||||
"is_giftcard": false,
|
"is_giftcard": false,
|
||||||
"is_return": false,
|
"is_return": false,
|
||||||
"metadata": Object {},
|
"metadata": Object {},
|
||||||
|
"order_edit_id": null,
|
||||||
"order_id": null,
|
"order_id": null,
|
||||||
|
"original_item_id": null,
|
||||||
"price": "11.25 USD",
|
"price": "11.25 USD",
|
||||||
"quantity": 1,
|
"quantity": 1,
|
||||||
"returned_quantity": null,
|
"returned_quantity": null,
|
||||||
@@ -2073,7 +2097,9 @@ Object {
|
|||||||
"is_giftcard": false,
|
"is_giftcard": false,
|
||||||
"is_return": false,
|
"is_return": false,
|
||||||
"metadata": null,
|
"metadata": null,
|
||||||
|
"order_edit_id": null,
|
||||||
"order_id": Any<String>,
|
"order_id": Any<String>,
|
||||||
|
"original_item_id": null,
|
||||||
"quantity": 2,
|
"quantity": 2,
|
||||||
"returned_quantity": null,
|
"returned_quantity": null,
|
||||||
"shipped_quantity": 2,
|
"shipped_quantity": 2,
|
||||||
@@ -2193,7 +2219,9 @@ Object {
|
|||||||
"is_giftcard": false,
|
"is_giftcard": false,
|
||||||
"is_return": false,
|
"is_return": false,
|
||||||
"metadata": Object {},
|
"metadata": Object {},
|
||||||
|
"order_edit_id": null,
|
||||||
"order_id": null,
|
"order_id": null,
|
||||||
|
"original_item_id": null,
|
||||||
"quantity": 1,
|
"quantity": 1,
|
||||||
"returned_quantity": null,
|
"returned_quantity": null,
|
||||||
"shipped_quantity": 1,
|
"shipped_quantity": 1,
|
||||||
@@ -2307,7 +2335,9 @@ Object {
|
|||||||
"is_giftcard": false,
|
"is_giftcard": false,
|
||||||
"is_return": false,
|
"is_return": false,
|
||||||
"metadata": Object {},
|
"metadata": Object {},
|
||||||
|
"order_edit_id": null,
|
||||||
"order_id": null,
|
"order_id": null,
|
||||||
|
"original_item_id": null,
|
||||||
"quantity": 1,
|
"quantity": 1,
|
||||||
"returned_quantity": null,
|
"returned_quantity": null,
|
||||||
"shipped_quantity": 1,
|
"shipped_quantity": 1,
|
||||||
|
|||||||
@@ -104,6 +104,8 @@ describe("medusa-plugin-sendgrid", () => {
|
|||||||
{
|
{
|
||||||
adjustments: [],
|
adjustments: [],
|
||||||
created_at: expect.any(Date),
|
created_at: expect.any(Date),
|
||||||
|
order_edit_id: null,
|
||||||
|
original_item_id: null,
|
||||||
updated_at: expect.any(Date),
|
updated_at: expect.any(Date),
|
||||||
order_id: expect.any(String),
|
order_id: expect.any(String),
|
||||||
tax_lines: [
|
tax_lines: [
|
||||||
@@ -225,6 +227,8 @@ describe("medusa-plugin-sendgrid", () => {
|
|||||||
adjustments: [],
|
adjustments: [],
|
||||||
created_at: expect.any(Date),
|
created_at: expect.any(Date),
|
||||||
updated_at: expect.any(Date),
|
updated_at: expect.any(Date),
|
||||||
|
order_edit_id: null,
|
||||||
|
original_item_id: null,
|
||||||
order_id: expect.any(String),
|
order_id: expect.any(String),
|
||||||
tax_lines: [
|
tax_lines: [
|
||||||
{
|
{
|
||||||
@@ -285,6 +289,8 @@ describe("medusa-plugin-sendgrid", () => {
|
|||||||
created_at: expect.any(Date),
|
created_at: expect.any(Date),
|
||||||
updated_at: expect.any(Date),
|
updated_at: expect.any(Date),
|
||||||
order_id: expect.any(String),
|
order_id: expect.any(String),
|
||||||
|
order_edit_id: null,
|
||||||
|
original_item_id: null,
|
||||||
tax_lines: [
|
tax_lines: [
|
||||||
{
|
{
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
@@ -473,6 +479,8 @@ describe("medusa-plugin-sendgrid", () => {
|
|||||||
{
|
{
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
order_id: expect.any(String),
|
order_id: expect.any(String),
|
||||||
|
order_edit_id: null,
|
||||||
|
original_item_id: null,
|
||||||
created_at: expect.any(Date),
|
created_at: expect.any(Date),
|
||||||
updated_at: expect.any(Date),
|
updated_at: expect.any(Date),
|
||||||
variant: {
|
variant: {
|
||||||
@@ -577,6 +585,8 @@ describe("medusa-plugin-sendgrid", () => {
|
|||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
created_at: expect.any(Date),
|
created_at: expect.any(Date),
|
||||||
updated_at: expect.any(Date),
|
updated_at: expect.any(Date),
|
||||||
|
order_edit_id: null,
|
||||||
|
original_item_id: null,
|
||||||
variant: {
|
variant: {
|
||||||
created_at: expect.any(Date),
|
created_at: expect.any(Date),
|
||||||
updated_at: expect.any(Date),
|
updated_at: expect.any(Date),
|
||||||
@@ -762,6 +772,8 @@ const getReturnSnap = (received = false) => {
|
|||||||
const itemSnap = {
|
const itemSnap = {
|
||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
order_id: expect.any(String),
|
order_id: expect.any(String),
|
||||||
|
order_edit_id: null,
|
||||||
|
original_item_id: null,
|
||||||
created_at: expect.any(Date),
|
created_at: expect.any(Date),
|
||||||
updated_at: expect.any(Date),
|
updated_at: expect.any(Date),
|
||||||
variant: {
|
variant: {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { IdMap } from "medusa-test-utils"
|
import { IdMap } from "medusa-test-utils"
|
||||||
import { request } from "../../../../../helpers/test-request"
|
import { request } from "../../../../../helpers/test-request"
|
||||||
import OrderEditingFeatureFlag from "../../../../../loaders/feature-flags/order-editing"
|
|
||||||
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
||||||
|
|
||||||
describe("POST /admin/order-edits/:id/cancel", () => {
|
describe("POST /admin/order-edits/:id/cancel", () => {
|
||||||
@@ -17,8 +16,7 @@ describe("POST /admin/order-edits/:id/cancel", () => {
|
|||||||
jwt: {
|
jwt: {
|
||||||
userId: IdMap.getId("admin_user"),
|
userId: IdMap.getId("admin_user"),
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
flags: [OrderEditingFeatureFlag],
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { IdMap } from "medusa-test-utils"
|
import { IdMap } from "medusa-test-utils"
|
||||||
import { request } from "../../../../../helpers/test-request"
|
import { request } from "../../../../../helpers/test-request"
|
||||||
import OrderEditingFeatureFlag from "../../../../../loaders/feature-flags/order-editing"
|
|
||||||
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
||||||
|
|
||||||
describe("POST /admin/order-edits/:id/confirm", () => {
|
describe("POST /admin/order-edits/:id/confirm", () => {
|
||||||
@@ -18,7 +17,6 @@ describe("POST /admin/order-edits/:id/confirm", () => {
|
|||||||
userId: "admin_user",
|
userId: "admin_user",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
flags: [OrderEditingFeatureFlag],
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { IdMap } from "medusa-test-utils"
|
import { IdMap } from "medusa-test-utils"
|
||||||
import { request } from "../../../../../helpers/test-request"
|
import { request } from "../../../../../helpers/test-request"
|
||||||
import OrderEditingFeatureFlag from "../../../../../loaders/feature-flags/order-editing"
|
|
||||||
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
||||||
|
|
||||||
describe("POST /admin/order-edits", () => {
|
describe("POST /admin/order-edits", () => {
|
||||||
@@ -20,7 +19,6 @@ describe("POST /admin/order-edits", () => {
|
|||||||
userId: IdMap.getId("admin_user"),
|
userId: IdMap.getId("admin_user"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
flags: [OrderEditingFeatureFlag],
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { IdMap } from "medusa-test-utils"
|
import { IdMap } from "medusa-test-utils"
|
||||||
import { request } from "../../../../../helpers/test-request"
|
import { request } from "../../../../../helpers/test-request"
|
||||||
import OrderEditingFeatureFlag from "../../../../../loaders/feature-flags/order-editing"
|
|
||||||
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
||||||
|
|
||||||
describe("DELETE /admin/order-edits/:id/items/:item_id", () => {
|
describe("DELETE /admin/order-edits/:id/items/:item_id", () => {
|
||||||
@@ -16,7 +15,6 @@ describe("DELETE /admin/order-edits/:id/items/:item_id", () => {
|
|||||||
userId: IdMap.getId("admin_user"),
|
userId: IdMap.getId("admin_user"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
flags: [OrderEditingFeatureFlag],
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
-2
@@ -1,6 +1,5 @@
|
|||||||
import { IdMap } from "medusa-test-utils"
|
import { IdMap } from "medusa-test-utils"
|
||||||
import { request } from "../../../../../helpers/test-request"
|
import { request } from "../../../../../helpers/test-request"
|
||||||
import OrderEditingFeatureFlag from "../../../../../loaders/feature-flags/order-editing"
|
|
||||||
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
||||||
|
|
||||||
describe("DELETE /admin/order-edits/:id/changes/:change_id", () => {
|
describe("DELETE /admin/order-edits/:id/changes/:change_id", () => {
|
||||||
@@ -19,7 +18,6 @@ describe("DELETE /admin/order-edits/:id/changes/:change_id", () => {
|
|||||||
userId: IdMap.getId("admin_user"),
|
userId: IdMap.getId("admin_user"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
flags: [OrderEditingFeatureFlag],
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { IdMap } from "medusa-test-utils"
|
import { IdMap } from "medusa-test-utils"
|
||||||
import { request } from "../../../../../helpers/test-request"
|
import { request } from "../../../../../helpers/test-request"
|
||||||
import OrderEditingFeatureFlag from "../../../../../loaders/feature-flags/order-editing"
|
|
||||||
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
||||||
|
|
||||||
describe("DELETE /admin/order-edits/:id", () => {
|
describe("DELETE /admin/order-edits/:id", () => {
|
||||||
@@ -15,7 +14,6 @@ describe("DELETE /admin/order-edits/:id", () => {
|
|||||||
userId: IdMap.getId("admin_user"),
|
userId: IdMap.getId("admin_user"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
flags: [OrderEditingFeatureFlag],
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import { IdMap } from "medusa-test-utils"
|
import { IdMap } from "medusa-test-utils"
|
||||||
import { request } from "../../../../../helpers/test-request"
|
import { request } from "../../../../../helpers/test-request"
|
||||||
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
||||||
import OrderEditingFeatureFlag from "../../../../../loaders/feature-flags/order-editing"
|
|
||||||
import {
|
import {
|
||||||
defaultOrderEditFields,
|
defaultOrderEditFields,
|
||||||
defaultOrderEditRelations,
|
defaultOrderEditRelations
|
||||||
} from "../../../../../types/order-edit"
|
} from "../../../../../types/order-edit"
|
||||||
|
|
||||||
describe("GET /admin/order-edits/:id", () => {
|
describe("GET /admin/order-edits/:id", () => {
|
||||||
@@ -19,7 +18,6 @@ describe("GET /admin/order-edits/:id", () => {
|
|||||||
userId: IdMap.getId("admin_user"),
|
userId: IdMap.getId("admin_user"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
flags: [OrderEditingFeatureFlag],
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import { IdMap } from "medusa-test-utils"
|
import { IdMap } from "medusa-test-utils"
|
||||||
import { request } from "../../../../../helpers/test-request"
|
import { request } from "../../../../../helpers/test-request"
|
||||||
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
||||||
import OrderEditingFeatureFlag from "../../../../../loaders/feature-flags/order-editing"
|
|
||||||
import {
|
import {
|
||||||
defaultOrderEditFields,
|
defaultOrderEditFields,
|
||||||
defaultOrderEditRelations,
|
defaultOrderEditRelations
|
||||||
} from "../../../../../types/order-edit"
|
} from "../../../../../types/order-edit"
|
||||||
|
|
||||||
describe("GET /admin/order-edits", () => {
|
describe("GET /admin/order-edits", () => {
|
||||||
@@ -18,7 +17,6 @@ describe("GET /admin/order-edits", () => {
|
|||||||
userId: IdMap.getId("admin_user"),
|
userId: IdMap.getId("admin_user"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
flags: [OrderEditingFeatureFlag],
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { IdMap } from "medusa-test-utils"
|
|||||||
import { request } from "../../../../../helpers/test-request"
|
import { request } from "../../../../../helpers/test-request"
|
||||||
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
||||||
|
|
||||||
import OrderEditingFeatureFlag from "../../../../../loaders/feature-flags/order-editing"
|
|
||||||
|
|
||||||
describe("GET /admin/order-edits/:id", () => {
|
describe("GET /admin/order-edits/:id", () => {
|
||||||
describe("successfully requests an order edit confirmation", () => {
|
describe("successfully requests an order edit confirmation", () => {
|
||||||
@@ -19,7 +18,6 @@ describe("GET /admin/order-edits/:id", () => {
|
|||||||
userId: IdMap.getId("admin_user"),
|
userId: IdMap.getId("admin_user"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
flags: [OrderEditingFeatureFlag],
|
|
||||||
payload: {
|
payload: {
|
||||||
payment_collection_description: "PayCol description",
|
payment_collection_description: "PayCol description",
|
||||||
},
|
},
|
||||||
|
|||||||
-2
@@ -1,6 +1,5 @@
|
|||||||
import { IdMap } from "medusa-test-utils"
|
import { IdMap } from "medusa-test-utils"
|
||||||
import { request } from "../../../../../helpers/test-request"
|
import { request } from "../../../../../helpers/test-request"
|
||||||
import OrderEditingFeatureFlag from "../../../../../loaders/feature-flags/order-editing"
|
|
||||||
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
||||||
|
|
||||||
describe("POST /admin/order-edits/:id/items/:item_id", () => {
|
describe("POST /admin/order-edits/:id/items/:item_id", () => {
|
||||||
@@ -22,7 +21,6 @@ describe("POST /admin/order-edits/:id/items/:item_id", () => {
|
|||||||
userId: IdMap.getId("admin_user"),
|
userId: IdMap.getId("admin_user"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
flags: [OrderEditingFeatureFlag],
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,33 +1,27 @@
|
|||||||
import { Router } from "express"
|
import { Router } from "express"
|
||||||
|
|
||||||
import middlewares, {
|
import { OrderEdit } from "../../../../models"
|
||||||
transformBody,
|
|
||||||
transformQuery,
|
|
||||||
} from "../../../middlewares"
|
|
||||||
import { DeleteResponse, PaginatedResponse } from "../../../../types/common"
|
import { DeleteResponse, PaginatedResponse } from "../../../../types/common"
|
||||||
import { isFeatureFlagEnabled } from "../../../middlewares/feature-flag-enabled"
|
|
||||||
import OrderEditingFeatureFlag from "../../../../loaders/feature-flags/order-editing"
|
|
||||||
import {
|
import {
|
||||||
defaultOrderEditFields,
|
defaultOrderEditFields,
|
||||||
defaultOrderEditRelations,
|
defaultOrderEditRelations,
|
||||||
} from "../../../../types/order-edit"
|
} from "../../../../types/order-edit"
|
||||||
import { OrderEdit } from "../../../../models"
|
import middlewares, {
|
||||||
import { AdminPostOrderEditsOrderEditReq } from "./update-order-edit"
|
transformBody,
|
||||||
import { AdminPostOrderEditsReq } from "./create-order-edit"
|
transformQuery,
|
||||||
|
} from "../../../middlewares"
|
||||||
import { AdminPostOrderEditsEditLineItemsReq } from "./add-line-item"
|
import { AdminPostOrderEditsEditLineItemsReq } from "./add-line-item"
|
||||||
import { AdminPostOrderEditsEditLineItemsLineItemReq } from "./update-order-edit-line-item"
|
import { AdminPostOrderEditsReq } from "./create-order-edit"
|
||||||
import { GetOrderEditsParams } from "./list-order-edit"
|
|
||||||
import { GetOrderEditsOrderEditParams } from "./get-order-edit"
|
import { GetOrderEditsOrderEditParams } from "./get-order-edit"
|
||||||
|
import { GetOrderEditsParams } from "./list-order-edit"
|
||||||
import { AdminPostOrderEditsRequestConfirmationReq } from "./request-confirmation"
|
import { AdminPostOrderEditsRequestConfirmationReq } from "./request-confirmation"
|
||||||
|
import { AdminPostOrderEditsOrderEditReq } from "./update-order-edit"
|
||||||
|
import { AdminPostOrderEditsEditLineItemsLineItemReq } from "./update-order-edit-line-item"
|
||||||
|
|
||||||
const route = Router()
|
const route = Router()
|
||||||
|
|
||||||
export default (app) => {
|
export default (app) => {
|
||||||
app.use(
|
app.use("/order-edits", route)
|
||||||
"/order-edits",
|
|
||||||
isFeatureFlagEnabled(OrderEditingFeatureFlag.key),
|
|
||||||
route
|
|
||||||
)
|
|
||||||
|
|
||||||
route.post(
|
route.post(
|
||||||
"/",
|
"/",
|
||||||
@@ -117,10 +111,10 @@ export type AdminOrderEditItemChangeDeleteRes = {
|
|||||||
deleted: boolean
|
deleted: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export * from "./update-order-edit"
|
export * from "./add-line-item"
|
||||||
export * from "./update-order-edit-line-item"
|
|
||||||
export * from "./create-order-edit"
|
export * from "./create-order-edit"
|
||||||
export * from "./get-order-edit"
|
export * from "./get-order-edit"
|
||||||
export * from "./list-order-edit"
|
export * from "./list-order-edit"
|
||||||
export * from "./add-line-item"
|
|
||||||
export * from "./request-confirmation"
|
export * from "./request-confirmation"
|
||||||
|
export * from "./update-order-edit"
|
||||||
|
export * from "./update-order-edit-line-item"
|
||||||
@@ -4,21 +4,15 @@ import middlewares, {
|
|||||||
transformBody,
|
transformBody,
|
||||||
transformQuery,
|
transformQuery,
|
||||||
} from "../../../middlewares"
|
} from "../../../middlewares"
|
||||||
import OrderEditingFeatureFlag from "../../../../loaders/feature-flags/order-editing"
|
|
||||||
import { isFeatureFlagEnabled } from "../../../middlewares/feature-flag-enabled"
|
|
||||||
|
|
||||||
|
import { PaymentCollection } from "../../../../models"
|
||||||
import { GetPaymentCollectionsParams } from "./get-payment-collection"
|
import { GetPaymentCollectionsParams } from "./get-payment-collection"
|
||||||
import { AdminUpdatePaymentCollectionsReq } from "./update-payment-collection"
|
import { AdminUpdatePaymentCollectionsReq } from "./update-payment-collection"
|
||||||
import { PaymentCollection } from "../../../../models"
|
|
||||||
|
|
||||||
const route = Router()
|
const route = Router()
|
||||||
|
|
||||||
export default (app, container) => {
|
export default (app, container) => {
|
||||||
app.use(
|
app.use("/payment-collections", route)
|
||||||
"/payment-collections",
|
|
||||||
isFeatureFlagEnabled(OrderEditingFeatureFlag.key),
|
|
||||||
route
|
|
||||||
)
|
|
||||||
|
|
||||||
route.get(
|
route.get(
|
||||||
"/:id",
|
"/:id",
|
||||||
|
|||||||
@@ -4,17 +4,15 @@ import middlewares, {
|
|||||||
transformBody,
|
transformBody,
|
||||||
transformQuery,
|
transformQuery,
|
||||||
} from "../../../middlewares"
|
} from "../../../middlewares"
|
||||||
import OrderEditingFeatureFlag from "../../../../loaders/feature-flags/order-editing"
|
|
||||||
import { isFeatureFlagEnabled } from "../../../middlewares/feature-flag-enabled"
|
|
||||||
|
|
||||||
|
import { Payment, Refund } from "../../../../models"
|
||||||
import { GetPaymentsParams } from "./get-payment"
|
import { GetPaymentsParams } from "./get-payment"
|
||||||
import { AdminPostPaymentRefundsReq } from "./refund-payment"
|
import { AdminPostPaymentRefundsReq } from "./refund-payment"
|
||||||
import { Payment, Refund } from "../../../../models"
|
|
||||||
|
|
||||||
const route = Router()
|
const route = Router()
|
||||||
|
|
||||||
export default (app, container) => {
|
export default (app, container) => {
|
||||||
app.use("/payments", isFeatureFlagEnabled(OrderEditingFeatureFlag.key), route)
|
app.use("/payments", route)
|
||||||
|
|
||||||
route.get(
|
route.get(
|
||||||
"/:id",
|
"/:id",
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { IdMap } from "medusa-test-utils"
|
import { IdMap } from "medusa-test-utils"
|
||||||
import { request } from "../../../../../helpers/test-request"
|
import { request } from "../../../../../helpers/test-request"
|
||||||
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
||||||
import OrderEditingFeatureFlag from "../../../../../loaders/feature-flags/order-editing"
|
|
||||||
|
|
||||||
describe("GET /store/order-edits/:id/complete", () => {
|
describe("GET /store/order-edits/:id/complete", () => {
|
||||||
describe("successfully complete an order edit", () => {
|
describe("successfully complete an order edit", () => {
|
||||||
@@ -12,9 +11,6 @@ describe("GET /store/order-edits/:id/complete", () => {
|
|||||||
subject = await request(
|
subject = await request(
|
||||||
"POST",
|
"POST",
|
||||||
`/store/order-edits/${orderEditId}/complete`,
|
`/store/order-edits/${orderEditId}/complete`,
|
||||||
{
|
|
||||||
flags: [OrderEditingFeatureFlag],
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -44,7 +40,6 @@ describe("GET /store/order-edits/:id/complete", () => {
|
|||||||
"POST",
|
"POST",
|
||||||
`/store/order-edits/${orderEditId}/complete`,
|
`/store/order-edits/${orderEditId}/complete`,
|
||||||
{
|
{
|
||||||
flags: [OrderEditingFeatureFlag],
|
|
||||||
clientSession: {
|
clientSession: {
|
||||||
jwt: {
|
jwt: {
|
||||||
user: IdMap.getId("lebron"),
|
user: IdMap.getId("lebron"),
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { IdMap } from "medusa-test-utils"
|
import { IdMap } from "medusa-test-utils"
|
||||||
import { request } from "../../../../../helpers/test-request"
|
import { request } from "../../../../../helpers/test-request"
|
||||||
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
||||||
import OrderEditingFeatureFlag from "../../../../../loaders/feature-flags/order-editing"
|
|
||||||
|
|
||||||
describe("GET /store/order-edits/:id/decline", () => {
|
describe("GET /store/order-edits/:id/decline", () => {
|
||||||
describe("successfully decline an order edit", () => {
|
describe("successfully decline an order edit", () => {
|
||||||
@@ -18,7 +17,6 @@ describe("GET /store/order-edits/:id/decline", () => {
|
|||||||
`/store/order-edits/${orderEditId}/decline`,
|
`/store/order-edits/${orderEditId}/decline`,
|
||||||
{
|
{
|
||||||
payload,
|
payload,
|
||||||
flags: [OrderEditingFeatureFlag],
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import { IdMap } from "medusa-test-utils"
|
import { IdMap } from "medusa-test-utils"
|
||||||
import { request } from "../../../../../helpers/test-request"
|
import { request } from "../../../../../helpers/test-request"
|
||||||
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
import { orderEditServiceMock } from "../../../../../services/__mocks__/order-edit"
|
||||||
import OrderEditingFeatureFlag from "../../../../../loaders/feature-flags/order-editing"
|
|
||||||
import {
|
import {
|
||||||
defaultStoreOrderEditFields,
|
defaultStoreOrderEditFields,
|
||||||
defaultStoreOrderEditRelations,
|
defaultStoreOrderEditRelations
|
||||||
} from "../../../../../types/order-edit"
|
} from "../../../../../types/order-edit"
|
||||||
|
|
||||||
describe("GET /store/order-edits/:id", () => {
|
describe("GET /store/order-edits/:id", () => {
|
||||||
@@ -13,9 +12,7 @@ describe("GET /store/order-edits/:id", () => {
|
|||||||
let subject
|
let subject
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
subject = await request("GET", `/store/order-edits/${orderEditId}`, {
|
subject = await request("GET", `/store/order-edits/${orderEditId}`)
|
||||||
flags: [OrderEditingFeatureFlag],
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
|
|||||||
@@ -1,26 +1,20 @@
|
|||||||
import { Router } from "express"
|
import { Router } from "express"
|
||||||
import middlewares, {
|
import { OrderEdit } from "../../../../models"
|
||||||
transformBody,
|
|
||||||
transformQuery,
|
|
||||||
} from "../../../middlewares"
|
|
||||||
import { FindParams } from "../../../../types/common"
|
import { FindParams } from "../../../../types/common"
|
||||||
import { isFeatureFlagEnabled } from "../../../middlewares/feature-flag-enabled"
|
|
||||||
import OrderEditingFeatureFlag from "../../../../loaders/feature-flags/order-editing"
|
|
||||||
import {
|
import {
|
||||||
defaultStoreOrderEditFields,
|
defaultStoreOrderEditFields,
|
||||||
defaultStoreOrderEditRelations,
|
defaultStoreOrderEditRelations,
|
||||||
} from "../../../../types/order-edit"
|
} from "../../../../types/order-edit"
|
||||||
import { OrderEdit } from "../../../../models"
|
import middlewares, {
|
||||||
|
transformBody,
|
||||||
|
transformQuery,
|
||||||
|
} from "../../../middlewares"
|
||||||
import { StorePostOrderEditsOrderEditDecline } from "./decline-order-edit"
|
import { StorePostOrderEditsOrderEditDecline } from "./decline-order-edit"
|
||||||
|
|
||||||
const route = Router()
|
const route = Router()
|
||||||
|
|
||||||
export default (app) => {
|
export default (app) => {
|
||||||
app.use(
|
app.use("/order-edits", route)
|
||||||
"/order-edits",
|
|
||||||
isFeatureFlagEnabled(OrderEditingFeatureFlag.key),
|
|
||||||
route
|
|
||||||
)
|
|
||||||
|
|
||||||
route.get(
|
route.get(
|
||||||
"/:id",
|
"/:id",
|
||||||
|
|||||||
@@ -5,23 +5,16 @@ import middlewares, {
|
|||||||
transformQuery,
|
transformQuery,
|
||||||
} from "../../../middlewares"
|
} from "../../../middlewares"
|
||||||
|
|
||||||
import OrderEditingFeatureFlag from "../../../../loaders/feature-flags/order-editing"
|
|
||||||
import { isFeatureFlagEnabled } from "../../../middlewares/feature-flag-enabled"
|
|
||||||
|
|
||||||
import { StorePostPaymentCollectionsBatchSessionsReq } from "./manage-batch-payment-sessions"
|
|
||||||
import { GetPaymentCollectionsParams } from "./get-payment-collection"
|
|
||||||
import { PaymentCollection, PaymentSession } from "../../../../models"
|
import { PaymentCollection, PaymentSession } from "../../../../models"
|
||||||
import { StorePaymentCollectionSessionsReq } from "./manage-payment-session"
|
|
||||||
import { StorePostPaymentCollectionsBatchSessionsAuthorizeReq } from "./authorize-batch-payment-sessions"
|
import { StorePostPaymentCollectionsBatchSessionsAuthorizeReq } from "./authorize-batch-payment-sessions"
|
||||||
|
import { GetPaymentCollectionsParams } from "./get-payment-collection"
|
||||||
|
import { StorePostPaymentCollectionsBatchSessionsReq } from "./manage-batch-payment-sessions"
|
||||||
|
import { StorePaymentCollectionSessionsReq } from "./manage-payment-session"
|
||||||
|
|
||||||
const route = Router()
|
const route = Router()
|
||||||
|
|
||||||
export default (app, container) => {
|
export default (app, container) => {
|
||||||
app.use(
|
app.use("/payment-collections", route)
|
||||||
"/payment-collections",
|
|
||||||
isFeatureFlagEnabled(OrderEditingFeatureFlag.key),
|
|
||||||
route
|
|
||||||
)
|
|
||||||
|
|
||||||
route.get(
|
route.get(
|
||||||
"/:id",
|
"/:id",
|
||||||
@@ -86,8 +79,8 @@ export type StorePaymentCollectionsSessionRes = {
|
|||||||
payment_session: PaymentSession
|
payment_session: PaymentSession
|
||||||
}
|
}
|
||||||
|
|
||||||
export * from "./get-payment-collection"
|
|
||||||
export * from "./manage-payment-session"
|
|
||||||
export * from "./manage-batch-payment-sessions"
|
|
||||||
export * from "./refresh-payment-session"
|
|
||||||
export * from "./authorize-batch-payment-sessions"
|
export * from "./authorize-batch-payment-sessions"
|
||||||
|
export * from "./get-payment-collection"
|
||||||
|
export * from "./manage-batch-payment-sessions"
|
||||||
|
export * from "./manage-payment-session"
|
||||||
|
export * from "./refresh-payment-session"
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
import glob from "glob"
|
import glob from "glob"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
|
|
||||||
|
import { isDefined } from "medusa-core-utils"
|
||||||
import { trackFeatureFlag } from "medusa-telemetry"
|
import { trackFeatureFlag } from "medusa-telemetry"
|
||||||
import { FlagSettings } from "../../types/feature-flags"
|
import { FlagSettings } from "../../types/feature-flags"
|
||||||
import { Logger } from "../../types/global"
|
import { Logger } from "../../types/global"
|
||||||
import { isDefined } from "medusa-core-utils"
|
|
||||||
import { FlagRouter } from "../../utils/flag-router"
|
import { FlagRouter } from "../../utils/flag-router"
|
||||||
|
|
||||||
const isTruthy = (val: string | boolean | undefined): boolean => {
|
const isTruthy = (val: string | boolean | undefined): boolean => {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { FlagSettings } from "../../types/feature-flags"
|
|||||||
|
|
||||||
const OrderEditingFeatureFlag: FlagSettings = {
|
const OrderEditingFeatureFlag: FlagSettings = {
|
||||||
key: "order_editing",
|
key: "order_editing",
|
||||||
default_val: false,
|
default_val: true,
|
||||||
env_key: "MEDUSA_FF_ORDER_EDITING",
|
env_key: "MEDUSA_FF_ORDER_EDITING",
|
||||||
description: "[WIP] Enable the order editing feature",
|
description: "[WIP] Enable the order editing feature",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
import { MigrationInterface, QueryRunner } from "typeorm"
|
import { MigrationInterface, QueryRunner } from "typeorm"
|
||||||
|
|
||||||
import OrderEditingFeatureFlag from "../loaders/feature-flags/order-editing"
|
|
||||||
|
|
||||||
export const featureFlag = OrderEditingFeatureFlag.key
|
|
||||||
|
|
||||||
export class orderEditing1663059812399 implements MigrationInterface {
|
export class orderEditing1663059812399 implements MigrationInterface {
|
||||||
name = "orderEditing1663059812399"
|
name = "orderEditing1663059812399"
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
import { MigrationInterface, QueryRunner } from "typeorm"
|
import { MigrationInterface, QueryRunner } from "typeorm"
|
||||||
|
|
||||||
import OrderEditingFeatureFlag from "../loaders/feature-flags/order-editing"
|
|
||||||
|
|
||||||
export const featureFlag = OrderEditingFeatureFlag.key
|
|
||||||
|
|
||||||
export class lineItemOriginalItemRelation1663059812400
|
export class lineItemOriginalItemRelation1663059812400
|
||||||
implements MigrationInterface
|
implements MigrationInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
import { MigrationInterface, QueryRunner } from "typeorm"
|
import { MigrationInterface, QueryRunner } from "typeorm"
|
||||||
|
|
||||||
import OrderEditingFeatureFlag from "../loaders/feature-flags/order-editing"
|
|
||||||
|
|
||||||
export const featureFlag = OrderEditingFeatureFlag.key
|
|
||||||
|
|
||||||
export class paymentCollection1664880666982 implements MigrationInterface {
|
export class paymentCollection1664880666982 implements MigrationInterface {
|
||||||
name = "paymentCollection1664880666982"
|
name = "paymentCollection1664880666982"
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ export * from "./address"
|
|||||||
export * from "./analytics-config"
|
export * from "./analytics-config"
|
||||||
export * from "./batch-job"
|
export * from "./batch-job"
|
||||||
export * from "./cart"
|
export * from "./cart"
|
||||||
export * from "./product-category"
|
|
||||||
export * from "./claim-image"
|
export * from "./claim-image"
|
||||||
export * from "./claim-item"
|
export * from "./claim-item"
|
||||||
export * from "./claim-order"
|
export * from "./claim-order"
|
||||||
@@ -45,6 +44,7 @@ export * from "./payment-provider"
|
|||||||
export * from "./payment-session"
|
export * from "./payment-session"
|
||||||
export * from "./price-list"
|
export * from "./price-list"
|
||||||
export * from "./product"
|
export * from "./product"
|
||||||
|
export * from "./product-category"
|
||||||
export * from "./product-collection"
|
export * from "./product-collection"
|
||||||
export * from "./product-option"
|
export * from "./product-option"
|
||||||
export * from "./product-option-value"
|
export * from "./product-option-value"
|
||||||
@@ -61,7 +61,6 @@ export * from "./region"
|
|||||||
export * from "./return"
|
export * from "./return"
|
||||||
export * from "./return-item"
|
export * from "./return-item"
|
||||||
export * from "./return-reason"
|
export * from "./return-reason"
|
||||||
export * from "./sales-channel-location"
|
|
||||||
export * from "./sales-channel"
|
export * from "./sales-channel"
|
||||||
export * from "./sales-channel-location"
|
export * from "./sales-channel-location"
|
||||||
export * from "./shipping-method"
|
export * from "./shipping-method"
|
||||||
|
|||||||
@@ -6,42 +6,35 @@ import {
|
|||||||
Index,
|
Index,
|
||||||
JoinColumn,
|
JoinColumn,
|
||||||
ManyToOne,
|
ManyToOne,
|
||||||
OneToMany,
|
OneToMany
|
||||||
} from "typeorm"
|
} from "typeorm"
|
||||||
|
|
||||||
import { BaseEntity } from "../interfaces"
|
import { BaseEntity } from "../interfaces"
|
||||||
|
import TaxInclusivePricingFeatureFlag from "../loaders/feature-flags/tax-inclusive-pricing"
|
||||||
|
import { generateEntityId } from "../utils"
|
||||||
|
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||||
|
import { FeatureFlagColumn } from "../utils/feature-flag-decorators"
|
||||||
import { Cart } from "./cart"
|
import { Cart } from "./cart"
|
||||||
import { ClaimOrder } from "./claim-order"
|
import { ClaimOrder } from "./claim-order"
|
||||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
|
||||||
import { LineItemAdjustment } from "./line-item-adjustment"
|
import { LineItemAdjustment } from "./line-item-adjustment"
|
||||||
import { LineItemTaxLine } from "./line-item-tax-line"
|
import { LineItemTaxLine } from "./line-item-tax-line"
|
||||||
import { Order } from "./order"
|
import { Order } from "./order"
|
||||||
|
import { OrderEdit } from "./order-edit"
|
||||||
import { ProductVariant } from "./product-variant"
|
import { ProductVariant } from "./product-variant"
|
||||||
import { Swap } from "./swap"
|
import { Swap } from "./swap"
|
||||||
import { generateEntityId } from "../utils"
|
|
||||||
import {
|
|
||||||
FeatureFlagClassDecorators,
|
|
||||||
FeatureFlagColumn,
|
|
||||||
FeatureFlagDecorators,
|
|
||||||
} from "../utils/feature-flag-decorators"
|
|
||||||
import TaxInclusivePricingFeatureFlag from "../loaders/feature-flags/tax-inclusive-pricing"
|
|
||||||
import OrderEditingFeatureFlag from "../loaders/feature-flags/order-editing"
|
|
||||||
import { OrderEdit } from "./order-edit"
|
|
||||||
|
|
||||||
@Check(`"fulfilled_quantity" <= "quantity"`)
|
@Check(`"fulfilled_quantity" <= "quantity"`)
|
||||||
@Check(`"shipped_quantity" <= "fulfilled_quantity"`)
|
@Check(`"shipped_quantity" <= "fulfilled_quantity"`)
|
||||||
@Check(`"returned_quantity" <= "quantity"`)
|
@Check(`"returned_quantity" <= "quantity"`)
|
||||||
@Check(`"quantity" > 0`)
|
@Check(`"quantity" > 0`)
|
||||||
@FeatureFlagClassDecorators(OrderEditingFeatureFlag.key, [
|
@Index(
|
||||||
Index(
|
"unique_li_original_item_id_order_edit_id",
|
||||||
"unique_li_original_item_id_order_edit_id",
|
["order_edit_id", "original_item_id"],
|
||||||
["order_edit_id", "original_item_id"],
|
{
|
||||||
{
|
unique: true,
|
||||||
unique: true,
|
where: "original_item_id IS NOT NULL AND order_edit_id IS NOT NULL",
|
||||||
where: "WHERE original_item_id IS NOT NULL AND order_edit_id IS NOT NULL",
|
}
|
||||||
}
|
)
|
||||||
),
|
|
||||||
])
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class LineItem extends BaseEntity {
|
export class LineItem extends BaseEntity {
|
||||||
@Index()
|
@Index()
|
||||||
@@ -84,25 +77,14 @@ export class LineItem extends BaseEntity {
|
|||||||
})
|
})
|
||||||
adjustments: LineItemAdjustment[]
|
adjustments: LineItemAdjustment[]
|
||||||
|
|
||||||
@FeatureFlagColumn(OrderEditingFeatureFlag.key, {
|
@Column({ nullable: true, type: "varchar" })
|
||||||
nullable: true,
|
|
||||||
type: "varchar",
|
|
||||||
})
|
|
||||||
original_item_id?: string | null
|
original_item_id?: string | null
|
||||||
|
|
||||||
@FeatureFlagColumn(OrderEditingFeatureFlag.key, {
|
@Column({ nullable: true, type: "varchar" })
|
||||||
nullable: true,
|
|
||||||
type: "varchar",
|
|
||||||
})
|
|
||||||
order_edit_id?: string | null
|
order_edit_id?: string | null
|
||||||
|
|
||||||
@FeatureFlagDecorators(OrderEditingFeatureFlag.key, [
|
@ManyToOne(() => OrderEdit, (orderEdit) => orderEdit.items)
|
||||||
ManyToOne(
|
@JoinColumn({ name: "order_edit_id" })
|
||||||
() => OrderEdit,
|
|
||||||
(orderEdit) => orderEdit.items
|
|
||||||
),
|
|
||||||
JoinColumn({ name: "order_edit_id" }),
|
|
||||||
])
|
|
||||||
order_edit?: OrderEdit | null
|
order_edit?: OrderEdit | null
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
|
|||||||
@@ -2,18 +2,17 @@ import {
|
|||||||
AfterLoad,
|
AfterLoad,
|
||||||
BeforeInsert,
|
BeforeInsert,
|
||||||
Column,
|
Column,
|
||||||
|
Entity,
|
||||||
Index,
|
Index,
|
||||||
JoinColumn,
|
JoinColumn,
|
||||||
ManyToOne,
|
ManyToOne,
|
||||||
OneToMany,
|
OneToMany,
|
||||||
OneToOne
|
OneToOne,
|
||||||
} from "typeorm"
|
} from "typeorm"
|
||||||
|
|
||||||
import { BaseEntity } from "../interfaces"
|
import { BaseEntity } from "../interfaces"
|
||||||
import OrderEditingFeatureFlag from "../loaders/feature-flags/order-editing"
|
|
||||||
import { generateEntityId } from "../utils"
|
import { generateEntityId } from "../utils"
|
||||||
import { resolveDbType } from "../utils/db-aware-column"
|
import { resolveDbType } from "../utils/db-aware-column"
|
||||||
import { FeatureFlagEntity } from "../utils/feature-flag-decorators"
|
|
||||||
|
|
||||||
import { LineItem, Order, OrderItemChange, PaymentCollection } from "."
|
import { LineItem, Order, OrderItemChange, PaymentCollection } from "."
|
||||||
|
|
||||||
@@ -25,7 +24,7 @@ export enum OrderEditStatus {
|
|||||||
CANCELED = "canceled",
|
CANCELED = "canceled",
|
||||||
}
|
}
|
||||||
|
|
||||||
@FeatureFlagEntity(OrderEditingFeatureFlag.key)
|
@Entity()
|
||||||
export class OrderEdit extends BaseEntity {
|
export class OrderEdit extends BaseEntity {
|
||||||
@Index()
|
@Index()
|
||||||
@Column()
|
@Column()
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
BeforeInsert,
|
BeforeInsert,
|
||||||
Column,
|
Column,
|
||||||
|
Entity,
|
||||||
JoinColumn,
|
JoinColumn,
|
||||||
ManyToOne,
|
ManyToOne,
|
||||||
OneToOne,
|
OneToOne,
|
||||||
@@ -8,12 +9,10 @@ import {
|
|||||||
} from "typeorm"
|
} from "typeorm"
|
||||||
|
|
||||||
import { SoftDeletableEntity } from "../interfaces"
|
import { SoftDeletableEntity } from "../interfaces"
|
||||||
import OrderEditingFeatureFlag from "../loaders/feature-flags/order-editing"
|
|
||||||
import { FeatureFlagEntity } from "../utils/feature-flag-decorators"
|
|
||||||
import { generateEntityId } from "../utils"
|
import { generateEntityId } from "../utils"
|
||||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||||
import { OrderEdit } from "./order-edit"
|
|
||||||
import { LineItem } from "./line-item"
|
import { LineItem } from "./line-item"
|
||||||
|
import { OrderEdit } from "./order-edit"
|
||||||
|
|
||||||
export enum OrderEditItemChangeType {
|
export enum OrderEditItemChangeType {
|
||||||
ITEM_ADD = "item_add",
|
ITEM_ADD = "item_add",
|
||||||
@@ -21,9 +20,9 @@ export enum OrderEditItemChangeType {
|
|||||||
ITEM_UPDATE = "item_update",
|
ITEM_UPDATE = "item_update",
|
||||||
}
|
}
|
||||||
|
|
||||||
@FeatureFlagEntity(OrderEditingFeatureFlag.key)
|
|
||||||
@Unique(["order_edit_id", "original_line_item_id"])
|
@Unique(["order_edit_id", "original_line_item_id"])
|
||||||
@Unique(["order_edit_id", "line_item_id"])
|
@Unique(["order_edit_id", "line_item_id"])
|
||||||
|
@Entity()
|
||||||
export class OrderItemChange extends SoftDeletableEntity {
|
export class OrderItemChange extends SoftDeletableEntity {
|
||||||
@DbAwareColumn({
|
@DbAwareColumn({
|
||||||
type: "enum",
|
type: "enum",
|
||||||
|
|||||||
@@ -21,8 +21,10 @@ import {
|
|||||||
FeatureFlagDecorators,
|
FeatureFlagDecorators,
|
||||||
} from "../utils/feature-flag-decorators"
|
} from "../utils/feature-flag-decorators"
|
||||||
|
|
||||||
import { Address } from "./address"
|
|
||||||
import { BaseEntity } from "../interfaces/models/base-entity"
|
import { BaseEntity } from "../interfaces/models/base-entity"
|
||||||
|
import { generateEntityId } from "../utils/generate-entity-id"
|
||||||
|
import { manualAutoIncrement } from "../utils/manual-auto-increment"
|
||||||
|
import { Address } from "./address"
|
||||||
import { Cart } from "./cart"
|
import { Cart } from "./cart"
|
||||||
import { ClaimOrder } from "./claim-order"
|
import { ClaimOrder } from "./claim-order"
|
||||||
import { Currency } from "./currency"
|
import { Currency } from "./currency"
|
||||||
@@ -33,6 +35,7 @@ import { Fulfillment } from "./fulfillment"
|
|||||||
import { GiftCard } from "./gift-card"
|
import { GiftCard } from "./gift-card"
|
||||||
import { GiftCardTransaction } from "./gift-card-transaction"
|
import { GiftCardTransaction } from "./gift-card-transaction"
|
||||||
import { LineItem } from "./line-item"
|
import { LineItem } from "./line-item"
|
||||||
|
import { OrderEdit } from "./order-edit"
|
||||||
import { Payment } from "./payment"
|
import { Payment } from "./payment"
|
||||||
import { Refund } from "./refund"
|
import { Refund } from "./refund"
|
||||||
import { Region } from "./region"
|
import { Region } from "./region"
|
||||||
@@ -40,10 +43,6 @@ import { Return } from "./return"
|
|||||||
import { SalesChannel } from "./sales-channel"
|
import { SalesChannel } from "./sales-channel"
|
||||||
import { ShippingMethod } from "./shipping-method"
|
import { ShippingMethod } from "./shipping-method"
|
||||||
import { Swap } from "./swap"
|
import { Swap } from "./swap"
|
||||||
import { generateEntityId } from "../utils/generate-entity-id"
|
|
||||||
import { manualAutoIncrement } from "../utils/manual-auto-increment"
|
|
||||||
import { OrderEdit } from "./order-edit"
|
|
||||||
import OrderEditingFeatureFlag from "../loaders/feature-flags/order-editing"
|
|
||||||
|
|
||||||
export enum OrderStatus {
|
export enum OrderStatus {
|
||||||
PENDING = "pending",
|
PENDING = "pending",
|
||||||
@@ -211,12 +210,7 @@ export class Order extends BaseEntity {
|
|||||||
@JoinColumn({ name: "draft_order_id" })
|
@JoinColumn({ name: "draft_order_id" })
|
||||||
draft_order: DraftOrder
|
draft_order: DraftOrder
|
||||||
|
|
||||||
@FeatureFlagDecorators(OrderEditingFeatureFlag.key, [
|
@OneToMany(() => OrderEdit, (oe) => oe.order)
|
||||||
OneToMany(
|
|
||||||
() => OrderEdit,
|
|
||||||
(oe) => oe.order
|
|
||||||
),
|
|
||||||
])
|
|
||||||
edits: OrderEdit[]
|
edits: OrderEdit[]
|
||||||
|
|
||||||
@OneToMany(() => LineItem, (lineItem) => lineItem.order, {
|
@OneToMany(() => LineItem, (lineItem) => lineItem.order, {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
BeforeInsert,
|
BeforeInsert,
|
||||||
Column,
|
Column,
|
||||||
|
Entity,
|
||||||
Index,
|
Index,
|
||||||
JoinColumn,
|
JoinColumn,
|
||||||
JoinTable,
|
JoinTable,
|
||||||
@@ -8,13 +9,10 @@ import {
|
|||||||
ManyToOne,
|
ManyToOne,
|
||||||
} from "typeorm"
|
} from "typeorm"
|
||||||
|
|
||||||
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
|
||||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
|
||||||
import { generateEntityId } from "../utils"
|
|
||||||
import { Currency, Payment, PaymentSession, Region } from "."
|
import { Currency, Payment, PaymentSession, Region } from "."
|
||||||
|
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
|
||||||
import OrderEditingFeatureFlag from "../loaders/feature-flags/order-editing"
|
import { generateEntityId } from "../utils"
|
||||||
import { FeatureFlagEntity } from "../utils/feature-flag-decorators"
|
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||||
|
|
||||||
export enum PaymentCollectionStatus {
|
export enum PaymentCollectionStatus {
|
||||||
NOT_PAID = "not_paid",
|
NOT_PAID = "not_paid",
|
||||||
@@ -28,7 +26,7 @@ export enum PaymentCollectionType {
|
|||||||
ORDER_EDIT = "order_edit",
|
ORDER_EDIT = "order_edit",
|
||||||
}
|
}
|
||||||
|
|
||||||
@FeatureFlagEntity(OrderEditingFeatureFlag.key)
|
@Entity()
|
||||||
export class PaymentCollection extends SoftDeletableEntity {
|
export class PaymentCollection extends SoftDeletableEntity {
|
||||||
@DbAwareColumn({ type: "enum", enum: PaymentCollectionType })
|
@DbAwareColumn({ type: "enum", enum: PaymentCollectionType })
|
||||||
type: PaymentCollectionType
|
type: PaymentCollectionType
|
||||||
|
|||||||
@@ -1,11 +1,17 @@
|
|||||||
import { BeforeInsert, Column, Entity, Index, JoinColumn, ManyToOne, Unique, } from "typeorm"
|
import {
|
||||||
|
BeforeInsert,
|
||||||
|
Column,
|
||||||
|
Entity,
|
||||||
|
Index,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
Unique,
|
||||||
|
} from "typeorm"
|
||||||
|
|
||||||
import { BaseEntity } from "../interfaces"
|
import { BaseEntity } from "../interfaces"
|
||||||
import { Cart } from "./cart"
|
|
||||||
import { DbAwareColumn, resolveDbType } from "../utils/db-aware-column"
|
|
||||||
import { generateEntityId } from "../utils"
|
import { generateEntityId } from "../utils"
|
||||||
import { FeatureFlagDecorators } from "../utils/feature-flag-decorators"
|
import { DbAwareColumn, resolveDbType } from "../utils/db-aware-column"
|
||||||
import OrderEditingFeatureFlag from "../loaders/feature-flags/order-editing"
|
import { Cart } from "./cart"
|
||||||
|
|
||||||
export enum PaymentSessionStatus {
|
export enum PaymentSessionStatus {
|
||||||
AUTHORIZED = "authorized",
|
AUTHORIZED = "authorized",
|
||||||
@@ -16,8 +22,10 @@ export enum PaymentSessionStatus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Unique("OneSelected", ["cart_id", "is_selected"])
|
@Unique("OneSelected", ["cart_id", "is_selected"])
|
||||||
// TODO: This uniq constraint should be updated once the order edit flag is dropped and should add a where clause on cart_id is not null
|
@Index("UniqPaymentSessionCartIdProviderId", ["cart_id", "provider_id"], {
|
||||||
@Unique("UniqPaymentSessionCartIdProviderId", ["cart_id", "provider_id"])
|
unique: true,
|
||||||
|
where: "cart_id IS NOT NULL",
|
||||||
|
})
|
||||||
@Entity()
|
@Entity()
|
||||||
export class PaymentSession extends BaseEntity {
|
export class PaymentSession extends BaseEntity {
|
||||||
@Index()
|
@Index()
|
||||||
@@ -47,14 +55,10 @@ export class PaymentSession extends BaseEntity {
|
|||||||
@Column({ nullable: true })
|
@Column({ nullable: true })
|
||||||
idempotency_key: string
|
idempotency_key: string
|
||||||
|
|
||||||
@FeatureFlagDecorators(OrderEditingFeatureFlag.key, [
|
@Column({ type: "integer", nullable: true })
|
||||||
Column({ type: "integer", nullable: true }),
|
|
||||||
])
|
|
||||||
amount: number
|
amount: number
|
||||||
|
|
||||||
@FeatureFlagDecorators(OrderEditingFeatureFlag.key, [
|
@Column({ type: resolveDbType("timestamptz"), nullable: true })
|
||||||
Column({ type: resolveDbType("timestamptz"), nullable: true }),
|
|
||||||
])
|
|
||||||
payment_authorized_at: Date
|
payment_authorized_at: Date
|
||||||
|
|
||||||
@BeforeInsert()
|
@BeforeInsert()
|
||||||
|
|||||||
@@ -10,11 +10,9 @@ import {
|
|||||||
|
|
||||||
import { BaseEntity } from "../interfaces/models/base-entity"
|
import { BaseEntity } from "../interfaces/models/base-entity"
|
||||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||||
import { Order } from "./order"
|
|
||||||
import { generateEntityId } from "../utils/generate-entity-id"
|
import { generateEntityId } from "../utils/generate-entity-id"
|
||||||
|
import { Order } from "./order"
|
||||||
import { Payment } from "./payment"
|
import { Payment } from "./payment"
|
||||||
import { FeatureFlagDecorators } from "../utils/feature-flag-decorators"
|
|
||||||
import OrderEditingFeatureFlag from "../loaders/feature-flags/order-editing"
|
|
||||||
|
|
||||||
export enum RefundReason {
|
export enum RefundReason {
|
||||||
DISCOUNT = "discount",
|
DISCOUNT = "discount",
|
||||||
@@ -30,20 +28,16 @@ export class Refund extends BaseEntity {
|
|||||||
@Column({ nullable: true })
|
@Column({ nullable: true })
|
||||||
order_id: string
|
order_id: string
|
||||||
|
|
||||||
@FeatureFlagDecorators(OrderEditingFeatureFlag.key, [
|
@Index()
|
||||||
Index(),
|
@Column({ nullable: true })
|
||||||
Column({ nullable: true }),
|
|
||||||
])
|
|
||||||
payment_id: string
|
payment_id: string
|
||||||
|
|
||||||
@ManyToOne(() => Order, (order) => order.payments)
|
@ManyToOne(() => Order, (order) => order.payments)
|
||||||
@JoinColumn({ name: "order_id" })
|
@JoinColumn({ name: "order_id" })
|
||||||
order: Order
|
order: Order
|
||||||
|
|
||||||
@FeatureFlagDecorators(OrderEditingFeatureFlag.key, [
|
@OneToOne(() => Payment, { nullable: true })
|
||||||
OneToOne(() => Payment, { nullable: true }),
|
@JoinColumn({ name: "payment_id" })
|
||||||
JoinColumn({ name: "payment_id" }),
|
|
||||||
])
|
|
||||||
payment: Payment
|
payment: Payment
|
||||||
|
|
||||||
@Column({ type: "int" })
|
@Column({ type: "int" })
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import LineItemService from "../line-item"
|
|||||||
import { PricingServiceMock } from "../__mocks__/pricing"
|
import { PricingServiceMock } from "../__mocks__/pricing"
|
||||||
import { ProductVariantServiceMock } from "../__mocks__/product-variant"
|
import { ProductVariantServiceMock } from "../__mocks__/product-variant"
|
||||||
import { RegionServiceMock } from "../__mocks__/region"
|
import { RegionServiceMock } from "../__mocks__/region"
|
||||||
|
|
||||||
;[true, false].forEach((isTaxInclusiveEnabled) => {
|
;[true, false].forEach((isTaxInclusiveEnabled) => {
|
||||||
describe(`tax inclusive flag set to: ${isTaxInclusiveEnabled}`, () => {
|
describe(`tax inclusive flag set to: ${isTaxInclusiveEnabled}`, () => {
|
||||||
describe("LineItemService", () => {
|
describe("LineItemService", () => {
|
||||||
@@ -428,6 +427,7 @@ describe("LineItemService", () => {
|
|||||||
thumbnail: "",
|
thumbnail: "",
|
||||||
variant_id: IdMap.getId("test-variant"),
|
variant_id: IdMap.getId("test-variant"),
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
|
order_edit_id: null,
|
||||||
allow_discounts: undefined,
|
allow_discounts: undefined,
|
||||||
is_giftcard: undefined,
|
is_giftcard: undefined,
|
||||||
metadata: {},
|
metadata: {},
|
||||||
@@ -464,6 +464,7 @@ describe("LineItemService", () => {
|
|||||||
variant_id: IdMap.getId("test-variant"),
|
variant_id: IdMap.getId("test-variant"),
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
allow_discounts: undefined,
|
allow_discounts: undefined,
|
||||||
|
order_edit_id: null,
|
||||||
is_giftcard: undefined,
|
is_giftcard: undefined,
|
||||||
metadata: {},
|
metadata: {},
|
||||||
should_merge: true,
|
should_merge: true,
|
||||||
@@ -585,6 +586,7 @@ describe("LineItemService", () => {
|
|||||||
variant_id: IdMap.getId("test-variant"),
|
variant_id: IdMap.getId("test-variant"),
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
allow_discounts: undefined,
|
allow_discounts: undefined,
|
||||||
|
order_edit_id: null,
|
||||||
is_giftcard: undefined,
|
is_giftcard: undefined,
|
||||||
metadata: {},
|
metadata: {},
|
||||||
should_merge: true,
|
should_merge: true,
|
||||||
@@ -621,6 +623,7 @@ describe("LineItemService", () => {
|
|||||||
quantity: 1,
|
quantity: 1,
|
||||||
allow_discounts: undefined,
|
allow_discounts: undefined,
|
||||||
is_giftcard: undefined,
|
is_giftcard: undefined,
|
||||||
|
order_edit_id: null,
|
||||||
metadata: {},
|
metadata: {},
|
||||||
should_merge: true,
|
should_merge: true,
|
||||||
includes_tax: false,
|
includes_tax: false,
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { EntityManager, In } from "typeorm"
|
|||||||
import { DeepPartial } from "typeorm/common/DeepPartial"
|
import { DeepPartial } from "typeorm/common/DeepPartial"
|
||||||
|
|
||||||
import { TransactionBaseService } from "../interfaces"
|
import { TransactionBaseService } from "../interfaces"
|
||||||
import OrderEditingFeatureFlag from "../loaders/feature-flags/order-editing"
|
|
||||||
import TaxInclusivePricingFeatureFlag from "../loaders/feature-flags/tax-inclusive-pricing"
|
import TaxInclusivePricingFeatureFlag from "../loaders/feature-flags/tax-inclusive-pricing"
|
||||||
import {
|
import {
|
||||||
LineItem,
|
LineItem,
|
||||||
@@ -70,6 +69,7 @@ class LineItemService extends TransactionBaseService {
|
|||||||
taxProviderService,
|
taxProviderService,
|
||||||
featureFlagRouter,
|
featureFlagRouter,
|
||||||
}: InjectedDependencies) {
|
}: InjectedDependencies) {
|
||||||
|
// eslint-disable-next-line prefer-rest-params
|
||||||
super(arguments[0])
|
super(arguments[0])
|
||||||
|
|
||||||
this.manager_ = manager
|
this.manager_ = manager
|
||||||
@@ -348,9 +348,7 @@ class LineItemService extends TransactionBaseService {
|
|||||||
rawLineItem.includes_tax = unitPriceIncludesTax
|
rawLineItem.includes_tax = unitPriceIncludesTax
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.featureFlagRouter_.isFeatureEnabled(OrderEditingFeatureFlag.key)) {
|
rawLineItem.order_edit_id = context.order_edit_id || null
|
||||||
rawLineItem.order_edit_id = context.order_edit_id || null
|
|
||||||
}
|
|
||||||
|
|
||||||
const lineItemRepo = transactionManager.getCustomRepository(
|
const lineItemRepo = transactionManager.getCustomRepository(
|
||||||
this.lineItemRepository_
|
this.lineItemRepository_
|
||||||
|
|||||||
@@ -1,18 +1,12 @@
|
|||||||
import { isDefined, MedusaError } from "medusa-core-utils"
|
import { isDefined, MedusaError } from "medusa-core-utils"
|
||||||
import { BasePaymentService } from "medusa-interfaces"
|
import { BasePaymentService } from "medusa-interfaces"
|
||||||
|
import { EntityManager } from "typeorm"
|
||||||
import {
|
import {
|
||||||
AbstractPaymentService,
|
AbstractPaymentService,
|
||||||
PaymentContext,
|
PaymentContext,
|
||||||
PaymentSessionResponse,
|
PaymentSessionResponse,
|
||||||
TransactionBaseService,
|
TransactionBaseService,
|
||||||
} from "../interfaces"
|
} from "../interfaces"
|
||||||
import { EntityManager } from "typeorm"
|
|
||||||
import { PaymentSessionRepository } from "../repositories/payment-session"
|
|
||||||
import { PaymentRepository } from "../repositories/payment"
|
|
||||||
import { RefundRepository } from "../repositories/refund"
|
|
||||||
import { PaymentProviderRepository } from "../repositories/payment-provider"
|
|
||||||
import { buildQuery, isString } from "../utils"
|
|
||||||
import { FindConfig, Selector } from "../types/common"
|
|
||||||
import {
|
import {
|
||||||
Cart,
|
Cart,
|
||||||
Payment,
|
Payment,
|
||||||
@@ -21,12 +15,17 @@ import {
|
|||||||
PaymentSessionStatus,
|
PaymentSessionStatus,
|
||||||
Refund,
|
Refund,
|
||||||
} from "../models"
|
} from "../models"
|
||||||
import { FlagRouter } from "../utils/flag-router"
|
import { PaymentRepository } from "../repositories/payment"
|
||||||
import OrderEditingFeatureFlag from "../loaders/feature-flags/order-editing"
|
import { PaymentProviderRepository } from "../repositories/payment-provider"
|
||||||
import PaymentService from "./payment"
|
import { PaymentSessionRepository } from "../repositories/payment-session"
|
||||||
|
import { RefundRepository } from "../repositories/refund"
|
||||||
|
import { FindConfig, Selector } from "../types/common"
|
||||||
import { Logger } from "../types/global"
|
import { Logger } from "../types/global"
|
||||||
import { CreatePaymentInput, PaymentSessionInput } from "../types/payment"
|
import { CreatePaymentInput, PaymentSessionInput } from "../types/payment"
|
||||||
|
import { buildQuery, isString } from "../utils"
|
||||||
|
import { FlagRouter } from "../utils/flag-router"
|
||||||
import { CustomerService } from "./index"
|
import { CustomerService } from "./index"
|
||||||
|
import PaymentService from "./payment"
|
||||||
|
|
||||||
type PaymentProviderKey = `pp_${string}` | "systemPaymentProviderService"
|
type PaymentProviderKey = `pp_${string}` | "systemPaymentProviderService"
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
@@ -414,10 +413,7 @@ export default class PaymentProviderService extends TransactionBaseService {
|
|||||||
session.data = data
|
session.data = data
|
||||||
session.status = status
|
session.status = status
|
||||||
|
|
||||||
if (
|
if (status === PaymentSessionStatus.AUTHORIZED) {
|
||||||
this.featureFlagRouter_.isFeatureEnabled(OrderEditingFeatureFlag.key) &&
|
|
||||||
status === PaymentSessionStatus.AUTHORIZED
|
|
||||||
) {
|
|
||||||
session.payment_authorized_at = new Date()
|
session.payment_authorized_at = new Date()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user