release: next (#239)
* hotfix(medusa-plugin-brightpearl): Use order id in sales order endpoint * feat(medusa-plugin-sendgrid): adds localization option (#238) * chore(deps): bump y18n from 4.0.0 to 4.0.1 in /packages/medusa-cli (#226) Bumps [y18n](https://github.com/yargs/y18n) from 4.0.0 to 4.0.1. - [Release notes](https://github.com/yargs/y18n/releases) - [Changelog](https://github.com/yargs/y18n/blob/master/CHANGELOG.md) - [Commits](https://github.com/yargs/y18n/commits) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump y18n from 4.0.0 to 4.0.3 in /packages/medusa (#235) Bumps [y18n](https://github.com/yargs/y18n) from 4.0.0 to 4.0.3. - [Release notes](https://github.com/yargs/y18n/releases) - [Changelog](https://github.com/yargs/y18n/blob/y18n-v4.0.3/CHANGELOG.md) - [Commits](https://github.com/yargs/y18n/compare/v4.0.0...y18n-v4.0.3) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump y18n from 4.0.0 to 4.0.1 in /e2e/prod-project (#225) Bumps [y18n](https://github.com/yargs/y18n) from 4.0.0 to 4.0.1. - [Release notes](https://github.com/yargs/y18n/releases) - [Changelog](https://github.com/yargs/y18n/blob/master/CHANGELOG.md) - [Commits](https://github.com/yargs/y18n/commits) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump y18n in /packages/medusa-core-utils (#224) Bumps [y18n](https://github.com/yargs/y18n) from 4.0.0 to 4.0.1. - [Release notes](https://github.com/yargs/y18n/releases) - [Changelog](https://github.com/yargs/y18n/blob/master/CHANGELOG.md) - [Commits](https://github.com/yargs/y18n/commits) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * feat(medusa): Swaps on swaps (#229) Co-authored-by: Sebastian Rindom <skrindom@gmail.com> * chore: version bumps * chore: version bumps * chore(release): Publish - babel-preset-medusa-package@1.1.1 - @medusajs/medusa-cli@1.1.5 - medusa-core-utils@1.1.7 - medusa-dev-cli@0.0.6 - medusa-file-spaces@1.1.10 - medusa-fulfillment-manual@1.1.7 - medusa-fulfillment-webshipper@1.1.10 - medusa-interfaces@1.1.8 - medusa-payment-adyen@1.1.10 - medusa-payment-klarna@1.1.11 - medusa-payment-paypal@1.0.10 - medusa-payment-stripe@1.1.10 - medusa-plugin-add-ons@1.1.10 - medusa-plugin-brightpearl@1.1.13 - medusa-plugin-contentful@1.1.11 - medusa-plugin-discount-generator@1.1.1 - medusa-plugin-economic@1.1.10 - medusa-plugin-ip-lookup@1.1.1 - medusa-plugin-mailchimp@1.1.10 - medusa-plugin-permissions@1.1.10 - medusa-plugin-restock-notification@0.0.4 - medusa-plugin-segment@1.1.13 - medusa-plugin-sendgrid@1.1.11 - medusa-plugin-slack-notification@1.1.10 - medusa-plugin-twilio-sms@1.1.10 - medusa-plugin-wishlist@1.1.10 - medusa-test-utils@1.1.10 - @medusajs/medusa@1.1.20 * chore(release): Publish - babel-preset-medusa-package@1.1.2 - @medusajs/medusa-cli@1.1.6 - medusa-core-utils@1.1.8 - medusa-dev-cli@0.0.7 - medusa-file-spaces@1.1.11 - medusa-fulfillment-manual@1.1.8 - medusa-fulfillment-webshipper@1.1.11 - medusa-interfaces@1.1.9 - medusa-payment-adyen@1.1.11 - medusa-payment-klarna@1.1.12 - medusa-payment-paypal@1.0.11 - medusa-payment-stripe@1.1.11 - medusa-plugin-add-ons@1.1.11 - medusa-plugin-brightpearl@1.1.14 - medusa-plugin-contentful@1.1.12 - medusa-plugin-discount-generator@1.1.2 - medusa-plugin-economic@1.1.11 - medusa-plugin-ip-lookup@1.1.2 - medusa-plugin-mailchimp@1.1.11 - medusa-plugin-permissions@1.1.11 - medusa-plugin-restock-notification@0.0.5 - medusa-plugin-segment@1.1.14 - medusa-plugin-sendgrid@1.1.12 - medusa-plugin-slack-notification@1.1.11 - medusa-plugin-twilio-sms@1.1.11 - medusa-plugin-wishlist@1.1.11 - medusa-test-utils@1.1.11 - @medusajs/medusa@1.1.21 Co-authored-by: Sebastian Rindom <skrindom@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
6b51c06c22
commit
7343a4e841
@@ -7,6 +7,7 @@ const { useApi } = require("../../../helpers/use-api");
|
||||
const { initDb } = require("../../../helpers/use-db");
|
||||
|
||||
const orderSeeder = require("../../helpers/order-seeder");
|
||||
const swapSeeder = require("../../helpers/swap-seeder");
|
||||
const adminSeeder = require("../../helpers/admin-seeder");
|
||||
|
||||
jest.setTimeout(30000);
|
||||
@@ -706,4 +707,286 @@ describe("/admin/orders", () => {
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("POST /admin/orders/:id/swaps", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection);
|
||||
await orderSeeder(dbConnection);
|
||||
await swapSeeder(dbConnection);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
const manager = dbConnection.manager;
|
||||
await manager.query(`DELETE FROM "fulfillment_item"`);
|
||||
await manager.query(`DELETE FROM "fulfillment"`);
|
||||
await manager.query(`DELETE FROM "return_item"`);
|
||||
await manager.query(`DELETE FROM "return_reason"`);
|
||||
await manager.query(`DELETE FROM "return"`);
|
||||
await manager.query(`DELETE FROM "claim_image"`);
|
||||
await manager.query(`DELETE FROM "claim_tag"`);
|
||||
await manager.query(`DELETE FROM "claim_item"`);
|
||||
await manager.query(`DELETE FROM "shipping_method"`);
|
||||
await manager.query(`DELETE FROM "line_item"`);
|
||||
await manager.query(`DELETE FROM "payment"`);
|
||||
await manager.query(`DELETE FROM "swap"`);
|
||||
await manager.query(`DELETE FROM "cart"`);
|
||||
await manager.query(`DELETE FROM "claim_order"`);
|
||||
await manager.query(`DELETE FROM "money_amount"`);
|
||||
await manager.query(`DELETE FROM "product_variant"`);
|
||||
await manager.query(`DELETE FROM "product"`);
|
||||
await manager.query(`DELETE FROM "shipping_option"`);
|
||||
await manager.query(`DELETE FROM "discount"`);
|
||||
await manager.query(`DELETE FROM "refund"`);
|
||||
await manager.query(`DELETE FROM "order"`);
|
||||
await manager.query(`DELETE FROM "customer"`);
|
||||
await manager.query(
|
||||
`UPDATE "country" SET region_id=NULL WHERE iso_2 = 'us'`
|
||||
);
|
||||
await manager.query(`DELETE FROM "region"`);
|
||||
await manager.query(`DELETE FROM "user"`);
|
||||
});
|
||||
|
||||
it("creates a swap", async () => {
|
||||
const api = useApi();
|
||||
|
||||
const response = await api.post(
|
||||
"/admin/orders/test-order/swaps",
|
||||
{
|
||||
return_items: [
|
||||
{
|
||||
item_id: "test-item",
|
||||
quantity: 1,
|
||||
},
|
||||
],
|
||||
additional_items: [{ variant_id: "test-variant-2", quantity: 1 }],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
);
|
||||
expect(response.status).toEqual(200);
|
||||
});
|
||||
|
||||
it("creates a swap and a return", async () => {
|
||||
const api = useApi();
|
||||
|
||||
const returnedOrderFirst = await api.post(
|
||||
"/admin/orders/order-with-swap/return",
|
||||
{
|
||||
items: [
|
||||
{
|
||||
item_id: "test-item-many",
|
||||
quantity: 2,
|
||||
},
|
||||
],
|
||||
receive_now: true,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(returnedOrderFirst.status).toEqual(200);
|
||||
|
||||
const returnedOrderSecond = await api.post(
|
||||
"/admin/orders/order-with-swap/return",
|
||||
{
|
||||
items: [
|
||||
{
|
||||
item_id: "test-item-many",
|
||||
quantity: 1,
|
||||
},
|
||||
],
|
||||
receive_now: true,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(returnedOrderSecond.status).toEqual(200);
|
||||
expect(returnedOrderSecond.data.order.items[1].returned_quantity).toBe(3);
|
||||
});
|
||||
|
||||
it("creates a swap and receives the items", async () => {
|
||||
const api = useApi();
|
||||
|
||||
const createdSwapOrder = await api.post(
|
||||
"/admin/orders/test-order/swaps",
|
||||
{
|
||||
return_items: [
|
||||
{
|
||||
item_id: "test-item",
|
||||
quantity: 1,
|
||||
},
|
||||
],
|
||||
additional_items: [{ variant_id: "test-variant-2", quantity: 1 }],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(createdSwapOrder.status).toEqual(200);
|
||||
|
||||
const swap = createdSwapOrder.data.order.swaps[0];
|
||||
|
||||
const receivedSwap = await api.post(
|
||||
`/admin/returns/${swap.return_order.id}/receive`,
|
||||
{
|
||||
items: [
|
||||
{
|
||||
item_id: "test-item",
|
||||
quantity: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(receivedSwap.status).toEqual(200);
|
||||
expect(receivedSwap.data.return.status).toBe("received");
|
||||
});
|
||||
|
||||
it("creates a swap on a swap", async () => {
|
||||
const api = useApi();
|
||||
|
||||
const swapOnSwap = await api.post(
|
||||
"/admin/orders/order-with-swap/swaps",
|
||||
{
|
||||
return_items: [
|
||||
{
|
||||
item_id: "test-item-swapped",
|
||||
quantity: 1,
|
||||
},
|
||||
],
|
||||
additional_items: [{ variant_id: "test-variant", quantity: 1 }],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(swapOnSwap.status).toEqual(200);
|
||||
});
|
||||
|
||||
it("receives a swap on swap", async () => {
|
||||
const api = useApi();
|
||||
|
||||
const received = await api.post(
|
||||
`/admin/returns/return-on-swap/receive`,
|
||||
{
|
||||
items: [
|
||||
{
|
||||
item_id: "test-item-swapped",
|
||||
quantity: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(received.status).toEqual(200);
|
||||
});
|
||||
|
||||
it("creates a return on a swap", async () => {
|
||||
const api = useApi();
|
||||
|
||||
const returnOnSwap = await api.post(
|
||||
"/admin/orders/order-with-swap/return",
|
||||
{
|
||||
items: [
|
||||
{
|
||||
item_id: "test-item-swapped",
|
||||
quantity: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(returnOnSwap.status).toEqual(200);
|
||||
});
|
||||
|
||||
it("creates a return on an order", async () => {
|
||||
const api = useApi();
|
||||
|
||||
const returnOnOrder = await api.post(
|
||||
"/admin/orders/test-order/return",
|
||||
{
|
||||
items: [
|
||||
{
|
||||
item_id: "test-item",
|
||||
quantity: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(returnOnOrder.status).toEqual(200);
|
||||
|
||||
const captured = await api.post(
|
||||
"/admin/orders/test-order/capture",
|
||||
{},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const returnId = returnOnOrder.data.order.returns[0].id;
|
||||
|
||||
const received = await api.post(
|
||||
`/admin/returns/${returnId}/receive`,
|
||||
{
|
||||
items: [
|
||||
{
|
||||
item_id: "test-item",
|
||||
quantity: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(received.status).toEqual(200);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user