fix: merge conflicts
This commit is contained in:
commit
632ad17e3f
134 files changed
+5517
-628
No files matched your search
@@ -0,0 +1,16 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`/admin/discounts creates admin session correctly 1`] = `
|
||||
Object {
|
||||
"api_token": "test_token",
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"email": "admin@medusa.js",
|
||||
"first_name": null,
|
||||
"id": "admin_user",
|
||||
"last_name": null,
|
||||
"metadata": null,
|
||||
"updated_at": Any<String>,
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -0,0 +1,384 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`/admin/products GET /admin/products returns a list of products with child entities 1`] = `
|
||||
Array [
|
||||
Object {
|
||||
"collection": Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"handle": "test-collection",
|
||||
"id": StringMatching /\\^test-\\*/,
|
||||
"metadata": null,
|
||||
"title": "Test collection",
|
||||
"updated_at": Any<String>,
|
||||
},
|
||||
"collection_id": "test-collection",
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"description": "test-product-description",
|
||||
"discountable": true,
|
||||
"handle": "test-product",
|
||||
"height": null,
|
||||
"hs_code": null,
|
||||
"id": StringMatching /\\^test-\\*/,
|
||||
"images": Array [
|
||||
Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"id": StringMatching /\\^test-\\*/,
|
||||
"metadata": null,
|
||||
"updated_at": Any<String>,
|
||||
"url": "test-image.png",
|
||||
},
|
||||
],
|
||||
"is_giftcard": false,
|
||||
"length": null,
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"options": Array [
|
||||
Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"id": StringMatching /\\^test-\\*/,
|
||||
"metadata": null,
|
||||
"product_id": StringMatching /\\^test-\\*/,
|
||||
"title": "test-option",
|
||||
"updated_at": Any<String>,
|
||||
},
|
||||
],
|
||||
"origin_country": null,
|
||||
"profile_id": StringMatching /\\^sp_\\*/,
|
||||
"status": "draft",
|
||||
"subtitle": null,
|
||||
"tags": Array [
|
||||
Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"id": StringMatching /\\^tag\\*/,
|
||||
"metadata": null,
|
||||
"updated_at": Any<String>,
|
||||
"value": "123",
|
||||
},
|
||||
],
|
||||
"thumbnail": null,
|
||||
"title": "Test product",
|
||||
"type": Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"id": StringMatching /\\^test-\\*/,
|
||||
"metadata": null,
|
||||
"updated_at": Any<String>,
|
||||
"value": "test-type",
|
||||
},
|
||||
"type_id": "test-type",
|
||||
"updated_at": Any<String>,
|
||||
"variants": Array [
|
||||
Object {
|
||||
"allow_backorder": false,
|
||||
"barcode": "test-barcode",
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"ean": "test-ean",
|
||||
"height": null,
|
||||
"hs_code": null,
|
||||
"id": "test-variant",
|
||||
"inventory_quantity": 10,
|
||||
"length": null,
|
||||
"manage_inventory": true,
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"options": Array [
|
||||
Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"id": StringMatching /\\^test-variant-option\\*/,
|
||||
"metadata": null,
|
||||
"option_id": StringMatching /\\^test-opt\\*/,
|
||||
"updated_at": Any<String>,
|
||||
"value": "Default variant",
|
||||
"variant_id": StringMatching /\\^test-variant\\*/,
|
||||
},
|
||||
],
|
||||
"origin_country": null,
|
||||
"prices": Array [
|
||||
Object {
|
||||
"amount": 100,
|
||||
"created_at": Any<String>,
|
||||
"currency_code": "usd",
|
||||
"deleted_at": null,
|
||||
"id": StringMatching /\\^test-price\\*/,
|
||||
"region_id": null,
|
||||
"sale_amount": null,
|
||||
"updated_at": Any<String>,
|
||||
"variant_id": StringMatching /\\^test-variant\\*/,
|
||||
},
|
||||
],
|
||||
"product_id": StringMatching /\\^test-\\*/,
|
||||
"sku": "test-sku",
|
||||
"title": "Test variant",
|
||||
"upc": "test-upc",
|
||||
"updated_at": Any<String>,
|
||||
"weight": null,
|
||||
"width": null,
|
||||
},
|
||||
Object {
|
||||
"allow_backorder": false,
|
||||
"barcode": null,
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"ean": "test-ean2",
|
||||
"height": null,
|
||||
"hs_code": null,
|
||||
"id": "test-variant_2",
|
||||
"inventory_quantity": 10,
|
||||
"length": null,
|
||||
"manage_inventory": true,
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"options": Array [
|
||||
Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"id": StringMatching /\\^test-variant-option\\*/,
|
||||
"metadata": null,
|
||||
"option_id": StringMatching /\\^test-opt\\*/,
|
||||
"updated_at": Any<String>,
|
||||
"value": "Default variant 2",
|
||||
"variant_id": StringMatching /\\^test-variant\\*/,
|
||||
},
|
||||
],
|
||||
"origin_country": null,
|
||||
"prices": Array [
|
||||
Object {
|
||||
"amount": 100,
|
||||
"created_at": Any<String>,
|
||||
"currency_code": "usd",
|
||||
"deleted_at": null,
|
||||
"id": StringMatching /\\^test-price\\*/,
|
||||
"region_id": null,
|
||||
"sale_amount": null,
|
||||
"updated_at": Any<String>,
|
||||
"variant_id": StringMatching /\\^test-variant\\*/,
|
||||
},
|
||||
],
|
||||
"product_id": StringMatching /\\^test-\\*/,
|
||||
"sku": "test-sku2",
|
||||
"title": "Test variant rank (2)",
|
||||
"upc": "test-upc2",
|
||||
"updated_at": Any<String>,
|
||||
"weight": null,
|
||||
"width": null,
|
||||
},
|
||||
Object {
|
||||
"allow_backorder": false,
|
||||
"barcode": "test-barcode 1",
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"ean": "test-ean1",
|
||||
"height": null,
|
||||
"hs_code": null,
|
||||
"id": "test-variant_1",
|
||||
"inventory_quantity": 10,
|
||||
"length": null,
|
||||
"manage_inventory": true,
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"options": Array [
|
||||
Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"id": StringMatching /\\^test-variant-option\\*/,
|
||||
"metadata": null,
|
||||
"option_id": StringMatching /\\^test-opt\\*/,
|
||||
"updated_at": Any<String>,
|
||||
"value": "Default variant 1",
|
||||
"variant_id": StringMatching /\\^test-variant\\*/,
|
||||
},
|
||||
],
|
||||
"origin_country": null,
|
||||
"prices": Array [
|
||||
Object {
|
||||
"amount": 100,
|
||||
"created_at": Any<String>,
|
||||
"currency_code": "usd",
|
||||
"deleted_at": null,
|
||||
"id": StringMatching /\\^test-price\\*/,
|
||||
"region_id": null,
|
||||
"sale_amount": null,
|
||||
"updated_at": Any<String>,
|
||||
"variant_id": StringMatching /\\^test-variant\\*/,
|
||||
},
|
||||
],
|
||||
"product_id": StringMatching /\\^test-\\*/,
|
||||
"sku": "test-sku1",
|
||||
"title": "Test variant rank (1)",
|
||||
"upc": "test-upc1",
|
||||
"updated_at": Any<String>,
|
||||
"weight": null,
|
||||
"width": null,
|
||||
},
|
||||
],
|
||||
"weight": null,
|
||||
"width": null,
|
||||
},
|
||||
Object {
|
||||
"collection": Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"handle": "test-collection",
|
||||
"id": StringMatching /\\^test-\\*/,
|
||||
"metadata": null,
|
||||
"title": "Test collection",
|
||||
"updated_at": Any<String>,
|
||||
},
|
||||
"collection_id": "test-collection",
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"description": "test-product-description1",
|
||||
"discountable": true,
|
||||
"handle": "test-product1",
|
||||
"height": null,
|
||||
"hs_code": null,
|
||||
"id": StringMatching /\\^test-\\*/,
|
||||
"images": Array [],
|
||||
"is_giftcard": false,
|
||||
"length": null,
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"options": Array [],
|
||||
"origin_country": null,
|
||||
"profile_id": StringMatching /\\^sp_\\*/,
|
||||
"status": "draft",
|
||||
"subtitle": null,
|
||||
"tags": Array [
|
||||
Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"id": StringMatching /\\^tag\\*/,
|
||||
"metadata": null,
|
||||
"updated_at": Any<String>,
|
||||
"value": "123",
|
||||
},
|
||||
],
|
||||
"thumbnail": null,
|
||||
"title": "Test product1",
|
||||
"type": Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"id": StringMatching /\\^test-\\*/,
|
||||
"metadata": null,
|
||||
"updated_at": Any<String>,
|
||||
"value": "test-type",
|
||||
},
|
||||
"type_id": "test-type",
|
||||
"updated_at": Any<String>,
|
||||
"variants": Array [
|
||||
Object {
|
||||
"allow_backorder": false,
|
||||
"barcode": null,
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"ean": "test-ean4",
|
||||
"height": null,
|
||||
"hs_code": null,
|
||||
"id": "test-variant_4",
|
||||
"inventory_quantity": 10,
|
||||
"length": null,
|
||||
"manage_inventory": true,
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"options": Array [
|
||||
Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"id": StringMatching /\\^test-variant-option\\*/,
|
||||
"metadata": null,
|
||||
"option_id": StringMatching /\\^test-opt\\*/,
|
||||
"updated_at": Any<String>,
|
||||
"value": "Default variant 4",
|
||||
"variant_id": StringMatching /\\^test-variant\\*/,
|
||||
},
|
||||
],
|
||||
"origin_country": null,
|
||||
"prices": Array [
|
||||
Object {
|
||||
"amount": 100,
|
||||
"created_at": Any<String>,
|
||||
"currency_code": "usd",
|
||||
"deleted_at": null,
|
||||
"id": StringMatching /\\^test-price\\*/,
|
||||
"region_id": null,
|
||||
"sale_amount": null,
|
||||
"updated_at": Any<String>,
|
||||
"variant_id": StringMatching /\\^test-variant\\*/,
|
||||
},
|
||||
],
|
||||
"product_id": StringMatching /\\^test-\\*/,
|
||||
"sku": "test-sku4",
|
||||
"title": "Test variant rank (2)",
|
||||
"upc": "test-upc4",
|
||||
"updated_at": Any<String>,
|
||||
"weight": null,
|
||||
"width": null,
|
||||
},
|
||||
Object {
|
||||
"allow_backorder": false,
|
||||
"barcode": null,
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"ean": "test-ean3",
|
||||
"height": null,
|
||||
"hs_code": null,
|
||||
"id": "test-variant_3",
|
||||
"inventory_quantity": 10,
|
||||
"length": null,
|
||||
"manage_inventory": true,
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"options": Array [
|
||||
Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"id": StringMatching /\\^test-variant-option\\*/,
|
||||
"metadata": null,
|
||||
"option_id": StringMatching /\\^test-opt\\*/,
|
||||
"updated_at": Any<String>,
|
||||
"value": "Default variant 3",
|
||||
"variant_id": StringMatching /\\^test-variant\\*/,
|
||||
},
|
||||
],
|
||||
"origin_country": null,
|
||||
"prices": Array [
|
||||
Object {
|
||||
"amount": 100,
|
||||
"created_at": Any<String>,
|
||||
"currency_code": "usd",
|
||||
"deleted_at": null,
|
||||
"id": StringMatching /\\^test-price\\*/,
|
||||
"region_id": null,
|
||||
"sale_amount": null,
|
||||
"updated_at": Any<String>,
|
||||
"variant_id": StringMatching /\\^test-variant\\*/,
|
||||
},
|
||||
],
|
||||
"product_id": StringMatching /\\^test-\\*/,
|
||||
"sku": "test-sku3",
|
||||
"title": "Test variant rank (2)",
|
||||
"upc": "test-upc3",
|
||||
"updated_at": Any<String>,
|
||||
"weight": null,
|
||||
"width": null,
|
||||
},
|
||||
],
|
||||
"weight": null,
|
||||
"width": null,
|
||||
},
|
||||
]
|
||||
`;
|
||||
@@ -0,0 +1,16 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`/admin/return-reasons POST /admin/return-reasons creates a return_reason 1`] = `
|
||||
Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"description": "Use this if the size was too big",
|
||||
"id": Any<String>,
|
||||
"label": "Too Big",
|
||||
"parent_return_reason": null,
|
||||
"parent_return_reason_id": null,
|
||||
"return_reason_children": Array [],
|
||||
"updated_at": Any<String>,
|
||||
"value": "too_big",
|
||||
}
|
||||
`;
|
||||
@@ -0,0 +1,54 @@
|
||||
const path = require("path")
|
||||
const { Region, DiscountRule, Discount } = require("@medusajs/medusa")
|
||||
|
||||
const setupServer = require("../../../helpers/setup-server")
|
||||
const { useApi } = require("../../../helpers/use-api")
|
||||
const { initDb, useDb } = require("../../../helpers/use-db")
|
||||
const adminSeeder = require("../../helpers/admin-seeder")
|
||||
const { exportAllDeclaration } = require("@babel/types")
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
describe("/admin/auth", () => {
|
||||
let medusaProcess
|
||||
let dbConnection
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
medusaProcess = await setupServer({ cwd })
|
||||
|
||||
try {
|
||||
await adminSeeder(dbConnection)
|
||||
} catch (e) {
|
||||
throw e
|
||||
}
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
medusaProcess.kill()
|
||||
})
|
||||
|
||||
it("creates admin session correctly", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.post("/admin/auth", {
|
||||
email: "admin@medusa.js",
|
||||
password: "secret_password",
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.user.password_hash).toEqual(undefined)
|
||||
expect(response.data.user).toMatchSnapshot({
|
||||
email: "admin@medusa.js",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,50 +1,50 @@
|
||||
const { dropDatabase } = require("pg-god");
|
||||
const path = require("path");
|
||||
const { dropDatabase } = require("pg-god")
|
||||
const path = require("path")
|
||||
|
||||
const setupServer = require("../../../helpers/setup-server");
|
||||
const { useApi } = require("../../../helpers/use-api");
|
||||
const { useDb, initDb } = require("../../../helpers/use-db");
|
||||
const setupServer = require("../../../helpers/setup-server")
|
||||
const { useApi } = require("../../../helpers/use-api")
|
||||
const { useDb, initDb } = require("../../../helpers/use-db")
|
||||
|
||||
const customerSeeder = require("../../helpers/customer-seeder");
|
||||
const adminSeeder = require("../../helpers/admin-seeder");
|
||||
const customerSeeder = require("../../helpers/customer-seeder")
|
||||
const adminSeeder = require("../../helpers/admin-seeder")
|
||||
|
||||
jest.setTimeout(30000);
|
||||
jest.setTimeout(30000)
|
||||
|
||||
describe("/admin/customers", () => {
|
||||
let medusaProcess;
|
||||
let dbConnection;
|
||||
let medusaProcess
|
||||
let dbConnection
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."));
|
||||
dbConnection = await initDb({ cwd });
|
||||
medusaProcess = await setupServer({ cwd });
|
||||
});
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
medusaProcess = await setupServer({ cwd })
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb();
|
||||
await db.shutdown();
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
|
||||
medusaProcess.kill();
|
||||
});
|
||||
medusaProcess.kill()
|
||||
})
|
||||
|
||||
describe("GET /admin/customers", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection);
|
||||
await customerSeeder(dbConnection);
|
||||
await adminSeeder(dbConnection)
|
||||
await customerSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
throw err;
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb();
|
||||
await db.teardown();
|
||||
});
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("lists customers and query count", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.get("/admin/customers", {
|
||||
@@ -53,11 +53,11 @@ describe("/admin/customers", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.data.count).toEqual(3);
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.count).toEqual(4)
|
||||
expect(response.data.customers).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
@@ -69,25 +69,28 @@ describe("/admin/customers", () => {
|
||||
expect.objectContaining({
|
||||
id: "test-customer-3",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-customer-has_account",
|
||||
}),
|
||||
])
|
||||
);
|
||||
});
|
||||
)
|
||||
})
|
||||
|
||||
it("lists customers with specific query", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.get("/admin/customers?q=test2@email.com", {
|
||||
.get("/admin/customers?q=est2@", {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.data.count).toEqual(1);
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.count).toEqual(1)
|
||||
expect(response.data.customers).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
@@ -95,11 +98,11 @@ describe("/admin/customers", () => {
|
||||
email: "test2@email.com",
|
||||
}),
|
||||
])
|
||||
);
|
||||
});
|
||||
)
|
||||
})
|
||||
|
||||
it("lists customers with expand query", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.get("/admin/customers?q=test1@email.com&expand=shipping_addresses", {
|
||||
@@ -108,11 +111,11 @@ describe("/admin/customers", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.data.count).toEqual(1);
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.count).toEqual(1)
|
||||
expect(response.data.customers).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
@@ -126,7 +129,54 @@ describe("/admin/customers", () => {
|
||||
]),
|
||||
}),
|
||||
])
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe("POST /admin/customers/:id", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection)
|
||||
await customerSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("Correctly updates customer", async () => {
|
||||
const api = useApi()
|
||||
const response = await api
|
||||
.post(
|
||||
"/admin/customers/test-customer-3",
|
||||
{
|
||||
first_name: "newf",
|
||||
last_name: "newl",
|
||||
email: "new@email.com",
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.customer).toEqual(
|
||||
expect.objectContaining({
|
||||
first_name: "newf",
|
||||
last_name: "newl",
|
||||
email: "new@email.com",
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -24,6 +24,67 @@ describe("/admin/discounts", () => {
|
||||
medusaProcess.kill()
|
||||
})
|
||||
|
||||
describe("GET /admin/discounts", () => {
|
||||
beforeEach(async () => {
|
||||
const manager = dbConnection.manager
|
||||
try {
|
||||
await adminSeeder(dbConnection)
|
||||
await manager.insert(DiscountRule, {
|
||||
id: "test-discount-rule",
|
||||
description: "Test discount rule",
|
||||
type: "percentage",
|
||||
value: 10,
|
||||
allocation: "total",
|
||||
})
|
||||
await manager.insert(Discount, {
|
||||
id: "test-discount",
|
||||
code: "TESTING",
|
||||
rule_id: "test-discount-rule",
|
||||
is_dynamic: false,
|
||||
is_disabled: false,
|
||||
})
|
||||
await manager.insert(Discount, {
|
||||
id: "messi-discount",
|
||||
code: "BARCA100",
|
||||
rule_id: "test-discount-rule",
|
||||
is_dynamic: false,
|
||||
is_disabled: false,
|
||||
})
|
||||
} catch (err) {
|
||||
throw err
|
||||
}
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("should list discounts that match a specific query in a case insensitive manner", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.get("/admin/discounts?q=barca", {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.count).toEqual(1)
|
||||
expect(response.data.discounts).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "messi-discount",
|
||||
code: "BARCA100",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe("POST /admin/discounts", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
@@ -97,6 +158,193 @@ describe("/admin/discounts", () => {
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it("creates a discount with start and end dates", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.post(
|
||||
"/admin/discounts",
|
||||
{
|
||||
code: "HELLOWORLD",
|
||||
rule: {
|
||||
description: "test",
|
||||
type: "percentage",
|
||||
value: 10,
|
||||
allocation: "total",
|
||||
},
|
||||
usage_limit: 10,
|
||||
starts_at: new Date("09/15/2021 11:50"),
|
||||
ends_at: new Date("09/15/2021 17:50"),
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.discount).toEqual(
|
||||
expect.objectContaining({
|
||||
code: "HELLOWORLD",
|
||||
usage_limit: 10,
|
||||
starts_at: expect.any(String),
|
||||
ends_at: expect.any(String),
|
||||
})
|
||||
)
|
||||
|
||||
expect(new Date(response.data.discount.starts_at)).toEqual(
|
||||
new Date("09/15/2021 11:50")
|
||||
)
|
||||
|
||||
expect(new Date(response.data.discount.ends_at)).toEqual(
|
||||
new Date("09/15/2021 17:50")
|
||||
)
|
||||
|
||||
const updated = await api
|
||||
.post(
|
||||
`/admin/discounts/${response.data.discount.id}`,
|
||||
{
|
||||
usage_limit: 20,
|
||||
starts_at: new Date("09/14/2021 11:50"),
|
||||
ends_at: new Date("09/17/2021 17:50"),
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(updated.status).toEqual(200)
|
||||
expect(updated.data.discount).toEqual(
|
||||
expect.objectContaining({
|
||||
code: "HELLOWORLD",
|
||||
usage_limit: 20,
|
||||
starts_at: expect.any(String),
|
||||
ends_at: expect.any(String),
|
||||
})
|
||||
)
|
||||
|
||||
expect(new Date(updated.data.discount.starts_at)).toEqual(
|
||||
new Date("09/14/2021 11:50")
|
||||
)
|
||||
|
||||
expect(new Date(updated.data.discount.ends_at)).toEqual(
|
||||
new Date("09/17/2021 17:50")
|
||||
)
|
||||
})
|
||||
|
||||
it("fails to update end date to a date before start date", async () => {
|
||||
expect.assertions(6)
|
||||
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.post(
|
||||
"/admin/discounts",
|
||||
{
|
||||
code: "HELLOWORLD",
|
||||
rule: {
|
||||
description: "test",
|
||||
type: "percentage",
|
||||
value: 10,
|
||||
allocation: "total",
|
||||
},
|
||||
usage_limit: 10,
|
||||
starts_at: new Date("09/15/2021 11:50"),
|
||||
ends_at: new Date("09/15/2021 17:50"),
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.discount).toEqual(
|
||||
expect.objectContaining({
|
||||
code: "HELLOWORLD",
|
||||
usage_limit: 10,
|
||||
starts_at: expect.any(String),
|
||||
ends_at: expect.any(String),
|
||||
})
|
||||
)
|
||||
|
||||
expect(new Date(response.data.discount.starts_at)).toEqual(
|
||||
new Date("09/15/2021 11:50")
|
||||
)
|
||||
|
||||
expect(new Date(response.data.discount.ends_at)).toEqual(
|
||||
new Date("09/15/2021 17:50")
|
||||
)
|
||||
|
||||
await api
|
||||
.post(
|
||||
`/admin/discounts/${response.data.discount.id}`,
|
||||
{
|
||||
usage_limit: 20,
|
||||
ends_at: new Date("09/11/2021 17:50"),
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
expect(err.response.status).toEqual(400)
|
||||
expect(err.response.data.message).toEqual(
|
||||
`"ends_at" must be greater than "starts_at"`
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
it("fails to create discount with end date before start date", async () => {
|
||||
expect.assertions(2)
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.post(
|
||||
"/admin/discounts",
|
||||
{
|
||||
code: "HELLOWORLD",
|
||||
rule: {
|
||||
description: "test",
|
||||
type: "percentage",
|
||||
value: 10,
|
||||
allocation: "total",
|
||||
},
|
||||
usage_limit: 10,
|
||||
starts_at: new Date("09/15/2021 11:50"),
|
||||
ends_at: new Date("09/14/2021 17:50"),
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
expect(err.response.status).toEqual(400)
|
||||
expect(err.response.data.message).toEqual([
|
||||
expect.objectContaining({
|
||||
message: `"ends_at" must be greater than "ref:starts_at"`,
|
||||
}),
|
||||
])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("testing for soft-deletion + uniqueness on discount codes", () => {
|
||||
@@ -225,6 +473,21 @@ describe("/admin/discounts", () => {
|
||||
is_dynamic: true,
|
||||
is_disabled: false,
|
||||
rule_id: "test-discount-rule",
|
||||
valid_duration: "P2Y",
|
||||
})
|
||||
await manager.insert(DiscountRule, {
|
||||
id: "test-discount-rule1",
|
||||
description: "Dynamic rule",
|
||||
type: "percentage",
|
||||
value: 10,
|
||||
allocation: "total",
|
||||
})
|
||||
await manager.insert(Discount, {
|
||||
id: "test-discount1",
|
||||
code: "DYNAMICCode",
|
||||
is_dynamic: true,
|
||||
is_disabled: false,
|
||||
rule_id: "test-discount-rule1",
|
||||
})
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
@@ -237,7 +500,7 @@ describe("/admin/discounts", () => {
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("creates a dynamic discount", async () => {
|
||||
it("creates a dynamic discount with ends_at", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
@@ -257,6 +520,40 @@ describe("/admin/discounts", () => {
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.discount).toEqual(
|
||||
expect.objectContaining({
|
||||
code: "HELLOWORLD",
|
||||
ends_at: expect.any(String),
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it("creates a dynamic discount without ends_at", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.post(
|
||||
"/admin/discounts/test-discount1/dynamic-codes",
|
||||
{
|
||||
code: "HELLOWORLD",
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
// console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.discount).toEqual(
|
||||
expect.objectContaining({
|
||||
code: "HELLOWORLD",
|
||||
ends_at: null,
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,54 +1,162 @@
|
||||
const path = require("path");
|
||||
const { Region } = require("@medusajs/medusa");
|
||||
const path = require("path")
|
||||
const { Region, GiftCard } = require("@medusajs/medusa")
|
||||
|
||||
const setupServer = require("../../../helpers/setup-server");
|
||||
const { useApi } = require("../../../helpers/use-api");
|
||||
const { initDb, useDb } = require("../../../helpers/use-db");
|
||||
const adminSeeder = require("../../helpers/admin-seeder");
|
||||
const setupServer = require("../../../helpers/setup-server")
|
||||
const { useApi } = require("../../../helpers/use-api")
|
||||
const { initDb, useDb } = require("../../../helpers/use-db")
|
||||
const adminSeeder = require("../../helpers/admin-seeder")
|
||||
|
||||
jest.setTimeout(30000);
|
||||
jest.setTimeout(30000)
|
||||
|
||||
describe("/admin/gift-cards", () => {
|
||||
let medusaProcess;
|
||||
let dbConnection;
|
||||
let medusaProcess
|
||||
let dbConnection
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."));
|
||||
dbConnection = await initDb({ cwd });
|
||||
medusaProcess = await setupServer({ cwd });
|
||||
});
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
medusaProcess = await setupServer({ cwd })
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb();
|
||||
await db.shutdown();
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
|
||||
medusaProcess.kill();
|
||||
});
|
||||
medusaProcess.kill()
|
||||
})
|
||||
|
||||
describe("GET /admin/gift-cards", () => {
|
||||
beforeEach(async () => {
|
||||
const manager = dbConnection.manager
|
||||
try {
|
||||
await adminSeeder(dbConnection)
|
||||
await manager.insert(Region, {
|
||||
id: "test-region",
|
||||
name: "Test Region",
|
||||
currency_code: "usd",
|
||||
tax_rate: 0,
|
||||
})
|
||||
await manager.insert(GiftCard, {
|
||||
id: "gift_test",
|
||||
code: "GC_TEST",
|
||||
value: 20000,
|
||||
balance: 20000,
|
||||
region_id: "test-region",
|
||||
})
|
||||
await manager.insert(GiftCard, {
|
||||
id: "another_gift_test",
|
||||
code: "CARD_TEST",
|
||||
value: 200000,
|
||||
balance: 200000,
|
||||
region_id: "test-region",
|
||||
})
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("lists gift cards and query count", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.get("/admin/gift-cards", {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.gift_cards).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "gift_test",
|
||||
code: "GC_TEST",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "another_gift_test",
|
||||
code: "CARD_TEST",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("lists gift cards with specific query", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.get("/admin/gift-cards?q=gc", {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.gift_cards.length).toEqual(1)
|
||||
expect(response.data.gift_cards).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "gift_test",
|
||||
code: "GC_TEST",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("lists no gift cards on query for non-existing gift card code", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.get("/admin/gift-cards?q=bla", {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.gift_cards.length).toEqual(0)
|
||||
expect(response.data.gift_cards).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe("POST /admin/gift-cards", () => {
|
||||
beforeEach(async () => {
|
||||
const manager = dbConnection.manager;
|
||||
const manager = dbConnection.manager
|
||||
try {
|
||||
await adminSeeder(dbConnection);
|
||||
await adminSeeder(dbConnection)
|
||||
await manager.insert(Region, {
|
||||
id: "region",
|
||||
name: "Test Region",
|
||||
currency_code: "usd",
|
||||
tax_rate: 0,
|
||||
});
|
||||
})
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
throw err;
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb();
|
||||
await db.teardown();
|
||||
});
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("creates a gift card", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.post(
|
||||
@@ -64,13 +172,13 @@ describe("/admin/gift-cards", () => {
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.data.gift_card.value).toEqual(1000);
|
||||
expect(response.data.gift_card.balance).toEqual(1000);
|
||||
expect(response.data.gift_card.region_id).toEqual("region");
|
||||
});
|
||||
});
|
||||
});
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.gift_card.value).toEqual(1000)
|
||||
expect(response.data.gift_card.balance).toEqual(1000)
|
||||
expect(response.data.gift_card.region_id).toEqual("region")
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,268 @@
|
||||
const path = require("path")
|
||||
const { Note } = require("@medusajs/medusa")
|
||||
|
||||
const setupServer = require("../../../helpers/setup-server")
|
||||
const { useApi } = require("../../../helpers/use-api")
|
||||
const { initDb, useDb } = require("../../../helpers/use-db")
|
||||
|
||||
const adminSeeder = require("../../helpers/admin-seeder")
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
const note = {
|
||||
id: "note1",
|
||||
value: "note text",
|
||||
resource_id: "resource1",
|
||||
resource_type: "type",
|
||||
author: { id: "admin_user" },
|
||||
}
|
||||
|
||||
describe("/admin/notes", () => {
|
||||
let medusaProcess
|
||||
let dbConnection
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
medusaProcess = await setupServer({ cwd })
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
medusaProcess.kill()
|
||||
})
|
||||
|
||||
describe("GET /admin/notes/:id", () => {
|
||||
beforeEach(async () => {
|
||||
const manager = dbConnection.manager
|
||||
try {
|
||||
await adminSeeder(dbConnection)
|
||||
|
||||
await manager.insert(Note, note)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("properly retrieves note", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api.get("/admin/notes/note1", {
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
|
||||
expect(response.data).toMatchObject({
|
||||
note: {
|
||||
id: "note1",
|
||||
resource_id: "resource1",
|
||||
resource_type: "type",
|
||||
value: "note text",
|
||||
author: { id: "admin_user" },
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("POST /admin/notes", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("creates a note", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.post(
|
||||
"/admin/notes",
|
||||
{
|
||||
resource_id: "resource-id",
|
||||
resource_type: "resource-type",
|
||||
value: "my note",
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.data).toMatchObject({
|
||||
note: {
|
||||
id: expect.stringMatching(/^note_*/),
|
||||
resource_id: "resource-id",
|
||||
resource_type: "resource-type",
|
||||
value: "my note",
|
||||
author_id: "admin_user",
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("GET /admin/notes", () => {
|
||||
beforeEach(async () => {
|
||||
const manager = dbConnection.manager
|
||||
try {
|
||||
await adminSeeder(dbConnection)
|
||||
|
||||
await manager.insert(Note, { ...note, id: "note1" })
|
||||
await manager.insert(Note, { ...note, id: "note2" })
|
||||
await manager.insert(Note, {
|
||||
...note,
|
||||
id: "note3",
|
||||
resource_id: "resource2",
|
||||
})
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("lists notes only related to wanted resource", async () => {
|
||||
const api = useApi()
|
||||
const response = await api
|
||||
.get("/admin/notes?resource_id=resource1", {
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.data.notes.length).toEqual(2)
|
||||
expect(response.data).toMatchObject({
|
||||
notes: [
|
||||
{
|
||||
id: "note1",
|
||||
resource_id: "resource1",
|
||||
resource_type: "type",
|
||||
value: "note text",
|
||||
author: { id: "admin_user" },
|
||||
},
|
||||
{
|
||||
id: "note2",
|
||||
resource_id: "resource1",
|
||||
resource_type: "type",
|
||||
value: "note text",
|
||||
author: { id: "admin_user" },
|
||||
},
|
||||
],
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("POST /admin/notes/:id", () => {
|
||||
beforeEach(async () => {
|
||||
const manager = dbConnection.manager
|
||||
try {
|
||||
await adminSeeder(dbConnection)
|
||||
|
||||
await manager.insert(Note, note)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("updates the content of the note", async () => {
|
||||
const api = useApi()
|
||||
|
||||
await api
|
||||
.post(
|
||||
"/admin/notes/note1",
|
||||
{ value: "new text" },
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
const response = await api
|
||||
.get("/admin/notes/note1", {
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.data.note.value).toEqual("new text")
|
||||
})
|
||||
})
|
||||
|
||||
describe("DELETE /admin/notes/:id", () => {
|
||||
beforeEach(async () => {
|
||||
const manager = dbConnection.manager
|
||||
try {
|
||||
await adminSeeder(dbConnection)
|
||||
|
||||
await manager.insert(Note, note)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("deletes the wanted note", async () => {
|
||||
const api = useApi()
|
||||
|
||||
await api
|
||||
.delete("/admin/notes/note1", {
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
let error
|
||||
await api
|
||||
.get("/admin/notes/note1", {
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => (error = err))
|
||||
|
||||
expect(error.response.status).toEqual(404)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1013,6 +1013,47 @@ describe("/admin/orders", () => {
|
||||
])
|
||||
})
|
||||
|
||||
it("list all orders with matching order email", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api.get(
|
||||
"/admin/orders?fields=id,email&q=test@email",
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.count).toEqual(1)
|
||||
expect(response.data.orders).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-order",
|
||||
email: "test@email.com",
|
||||
}),
|
||||
])
|
||||
})
|
||||
|
||||
it("list all orders with matching shipping_address first name", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api.get("/admin/orders?q=lebron", {
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.count).toEqual(1)
|
||||
expect(response.data.orders).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-order",
|
||||
shipping_address: expect.objectContaining({ first_name: "lebron" }),
|
||||
}),
|
||||
])
|
||||
})
|
||||
|
||||
it("successfully lists orders with greater than", async () => {
|
||||
const api = useApi()
|
||||
|
||||
|
||||
@@ -42,6 +42,73 @@ describe("/admin/products", () => {
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("returns a list of products with all statuses when no status or invalid status is provided", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const res = await api
|
||||
.get("/admin/products?status%5B%5D=null", {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(res.status).toEqual(200)
|
||||
expect(res.data.products).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-product",
|
||||
status: "draft",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: "test-product1",
|
||||
status: "draft",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("returns a list of products where status is proposed", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
status: "proposed",
|
||||
}
|
||||
|
||||
//update test-product status to proposed
|
||||
await api
|
||||
.post("/admin/products/test-product", payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
const response = await api
|
||||
.get("/admin/products?status%5B%5D=proposed", {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.products).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-product",
|
||||
status: "proposed",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("returns a list of products with child entities", async () => {
|
||||
const api = useApi()
|
||||
|
||||
@@ -297,6 +364,7 @@ describe("/admin/products", () => {
|
||||
discountable: true,
|
||||
is_giftcard: false,
|
||||
handle: "test",
|
||||
status: "draft",
|
||||
images: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
url: "test-image.png",
|
||||
@@ -455,7 +523,7 @@ describe("/admin/products", () => {
|
||||
)
|
||||
})
|
||||
|
||||
it("updates a product (update prices, tags, delete collection, delete type, replaces images)", async () => {
|
||||
it("updates a product (update prices, tags, update status, delete collection, delete type, replaces images)", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
@@ -476,6 +544,7 @@ describe("/admin/products", () => {
|
||||
tags: [{ value: "123" }],
|
||||
images: ["test-image-2.png"],
|
||||
type: { value: "test-type-2" },
|
||||
status: "published",
|
||||
}
|
||||
|
||||
const response = await api
|
||||
@@ -514,6 +583,7 @@ describe("/admin/products", () => {
|
||||
}),
|
||||
],
|
||||
type: null,
|
||||
status: "published",
|
||||
collection: null,
|
||||
type: expect.objectContaining({
|
||||
value: "test-type-2",
|
||||
@@ -522,6 +592,25 @@ describe("/admin/products", () => {
|
||||
)
|
||||
})
|
||||
|
||||
it("fails to update product with invalid status", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
status: null,
|
||||
}
|
||||
|
||||
try {
|
||||
await api.post("/admin/products/test-product", payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
} catch (e) {
|
||||
expect(e.response.status).toEqual(400)
|
||||
expect(e.response.data.type).toEqual("invalid_data")
|
||||
}
|
||||
})
|
||||
|
||||
it("updates a product (variant ordering)", async () => {
|
||||
const api = useApi()
|
||||
|
||||
|
||||
@@ -1,53 +1,55 @@
|
||||
const path = require("path");
|
||||
const { match } = require("assert")
|
||||
const path = require("path")
|
||||
const { RepositoryNotTreeError } = require("typeorm")
|
||||
|
||||
const setupServer = require("../../../helpers/setup-server");
|
||||
const { useApi } = require("../../../helpers/use-api");
|
||||
const { initDb, useDb } = require("../../../helpers/use-db");
|
||||
const setupServer = require("../../../helpers/setup-server")
|
||||
const { useApi } = require("../../../helpers/use-api")
|
||||
const { initDb, useDb } = require("../../../helpers/use-db")
|
||||
|
||||
const adminSeeder = require("../../helpers/admin-seeder");
|
||||
const adminSeeder = require("../../helpers/admin-seeder")
|
||||
|
||||
jest.setTimeout(30000);
|
||||
jest.setTimeout(30000)
|
||||
|
||||
describe("/admin/return-reasons", () => {
|
||||
let medusaProcess;
|
||||
let dbConnection;
|
||||
let medusaProcess
|
||||
let dbConnection
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."));
|
||||
dbConnection = await initDb({ cwd });
|
||||
medusaProcess = await setupServer({ cwd });
|
||||
});
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
medusaProcess = await setupServer({ cwd })
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb();
|
||||
await db.shutdown();
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
|
||||
medusaProcess.kill();
|
||||
});
|
||||
medusaProcess.kill()
|
||||
})
|
||||
|
||||
describe("POST /admin/return-reasons", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection);
|
||||
await adminSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
throw err;
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb();
|
||||
await db.teardown();
|
||||
});
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("creates a return_reason", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
label: "Too Big",
|
||||
description: "Use this if the size was too big",
|
||||
value: "too_big",
|
||||
};
|
||||
}
|
||||
|
||||
const response = await api
|
||||
.post("/admin/return-reasons", payload, {
|
||||
@@ -56,10 +58,172 @@ describe("/admin/return-reasons", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
expect(response.data.return_reason).toMatchSnapshot({
|
||||
id: expect.any(String),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
parent_return_reason: null,
|
||||
parent_return_reason_id: null,
|
||||
label: "Too Big",
|
||||
description: "Use this if the size was too big",
|
||||
value: "too_big",
|
||||
})
|
||||
})
|
||||
|
||||
it("creates a nested return reason", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
label: "Wrong size",
|
||||
description: "Use this if the size was too big",
|
||||
value: "wrong_size",
|
||||
}
|
||||
|
||||
const response = await api
|
||||
.post("/admin/return-reasons", payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
expect(response.data.return_reason).toEqual(
|
||||
expect.objectContaining({
|
||||
label: "Wrong size",
|
||||
description: "Use this if the size was too big",
|
||||
value: "wrong_size",
|
||||
})
|
||||
)
|
||||
|
||||
const nested_payload = {
|
||||
parent_return_reason_id: response.data.return_reason.id,
|
||||
label: "Too Big",
|
||||
description: "Use this if the size was too big",
|
||||
value: "too_big",
|
||||
}
|
||||
|
||||
const nested_response = await api
|
||||
.post("/admin/return-reasons", nested_payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(nested_response.status).toEqual(200)
|
||||
|
||||
expect(nested_response.data.return_reason).toEqual(
|
||||
expect.objectContaining({
|
||||
parent_return_reason_id: response.data.return_reason.id,
|
||||
|
||||
label: "Too Big",
|
||||
description: "Use this if the size was too big",
|
||||
value: "too_big",
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it("fails to create a doubly nested return reason", async () => {
|
||||
expect.assertions(5)
|
||||
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
label: "Wrong size",
|
||||
description: "Use this if the size was too big",
|
||||
value: "wrong_size",
|
||||
}
|
||||
|
||||
const response = await api
|
||||
.post("/admin/return-reasons", payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
expect(response.data.return_reason).toEqual(
|
||||
expect.objectContaining({
|
||||
label: "Wrong size",
|
||||
description: "Use this if the size was too big",
|
||||
value: "wrong_size",
|
||||
})
|
||||
)
|
||||
|
||||
const nested_payload = {
|
||||
parent_return_reason_id: response.data.return_reason.id,
|
||||
label: "Too Big",
|
||||
description: "Use this if the size was too big",
|
||||
value: "too_big",
|
||||
}
|
||||
|
||||
const nested_response = await api
|
||||
.post("/admin/return-reasons", nested_payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
const dbl_nested_payload = {
|
||||
parent_return_reason_id: nested_response.data.return_reason.id,
|
||||
label: "Too large size",
|
||||
description: "Use this if the size was too big",
|
||||
value: "large_size",
|
||||
}
|
||||
|
||||
const dbl_nested_response = await api
|
||||
.post("/admin/return-reasons", dbl_nested_payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
expect(err.response.status).toEqual(400)
|
||||
expect(err.response.data.type).toEqual("invalid_data")
|
||||
expect(err.response.data.message).toEqual(
|
||||
"Doubly nested return reasons is not supported"
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
it("deletes a return_reason", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
label: "Too Big",
|
||||
description: "Use this if the size was too big",
|
||||
value: "too_big",
|
||||
}
|
||||
|
||||
const response = await api
|
||||
.post("/admin/return-reasons", payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
expect(response.data.return_reason).toEqual(
|
||||
expect.objectContaining({
|
||||
@@ -67,17 +231,37 @@ describe("/admin/return-reasons", () => {
|
||||
description: "Use this if the size was too big",
|
||||
value: "too_big",
|
||||
})
|
||||
);
|
||||
});
|
||||
)
|
||||
|
||||
const deleteResponse = await api
|
||||
.delete(`/admin/return-reasons/${response.data.return_reason.id}`, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
expect(deleteResponse.data).toEqual(
|
||||
expect.objectContaining({
|
||||
id: response.data.return_reason.id,
|
||||
object: "return_reason",
|
||||
deleted: true,
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it("update a return reason", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
label: "Too Big Typo",
|
||||
description: "Use this if the size was too big",
|
||||
value: "too_big",
|
||||
};
|
||||
}
|
||||
|
||||
const response = await api
|
||||
.post("/admin/return-reasons", payload, {
|
||||
@@ -86,10 +270,10 @@ describe("/admin/return-reasons", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
expect(response.data.return_reason).toEqual(
|
||||
expect.objectContaining({
|
||||
@@ -97,7 +281,7 @@ describe("/admin/return-reasons", () => {
|
||||
description: "Use this if the size was too big",
|
||||
value: "too_big",
|
||||
})
|
||||
);
|
||||
)
|
||||
|
||||
const newResponse = await api
|
||||
.post(
|
||||
@@ -113,8 +297,8 @@ describe("/admin/return-reasons", () => {
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(newResponse.data.return_reason).toEqual(
|
||||
expect.objectContaining({
|
||||
@@ -122,17 +306,81 @@ describe("/admin/return-reasons", () => {
|
||||
description: "new desc",
|
||||
value: "too_big",
|
||||
})
|
||||
);
|
||||
});
|
||||
)
|
||||
})
|
||||
|
||||
it("lists nested return reasons", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
label: "Wrong size",
|
||||
description: "Use this if the size was too big",
|
||||
value: "wrong_size",
|
||||
}
|
||||
|
||||
const response = await api
|
||||
.post("/admin/return-reasons", payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
const nested_payload = {
|
||||
parent_return_reason_id: response.data.return_reason.id,
|
||||
label: "Too Big",
|
||||
description: "Use this if the size was too big",
|
||||
value: "too_big",
|
||||
}
|
||||
|
||||
const resp = await api
|
||||
.post("/admin/return-reasons", nested_payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
const nested_response = await api
|
||||
.get("/admin/return-reasons", {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(nested_response.status).toEqual(200)
|
||||
|
||||
expect(nested_response.data.return_reasons).toEqual([
|
||||
expect.objectContaining({
|
||||
label: "Wrong size",
|
||||
description: "Use this if the size was too big",
|
||||
value: "wrong_size",
|
||||
return_reason_children: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
label: "Too Big",
|
||||
description: "Use this if the size was too big",
|
||||
value: "too_big",
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
])
|
||||
})
|
||||
|
||||
it("list return reasons", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
label: "Too Big Typo",
|
||||
description: "Use this if the size was too big",
|
||||
value: "too_big",
|
||||
};
|
||||
}
|
||||
|
||||
await api
|
||||
.post("/admin/return-reasons", payload, {
|
||||
@@ -141,8 +389,8 @@ describe("/admin/return-reasons", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
const response = await api
|
||||
.get("/admin/return-reasons", {
|
||||
@@ -151,15 +399,191 @@ describe("/admin/return-reasons", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.return_reasons).toEqual([
|
||||
expect.objectContaining({
|
||||
value: "too_big",
|
||||
}),
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
describe("DELETE /admin/return-reasons", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("deletes single return reason", async () => {
|
||||
expect.assertions(6)
|
||||
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
label: "Too Big",
|
||||
description: "Use this if the size was too big",
|
||||
value: "too_big",
|
||||
}
|
||||
|
||||
const response = await api
|
||||
.post("/admin/return-reasons", payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
expect(response.data.return_reason).toEqual(
|
||||
expect.objectContaining({
|
||||
label: "Too Big",
|
||||
description: "Use this if the size was too big",
|
||||
value: "too_big",
|
||||
})
|
||||
)
|
||||
|
||||
const deleteResult = await api.delete(
|
||||
`/admin/return-reasons/${response.data.return_reason.id}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
expect(deleteResult.status).toEqual(200)
|
||||
|
||||
expect(deleteResult.data).toEqual({
|
||||
id: response.data.return_reason.id,
|
||||
object: "return_reason",
|
||||
deleted: true,
|
||||
})
|
||||
|
||||
const getResult = await api
|
||||
.get(`/admin/return-reasons/${response.data.return_reason.id}`, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
expect(err.response.status).toEqual(404)
|
||||
expect(err.response.data.type).toEqual("not_found")
|
||||
})
|
||||
})
|
||||
|
||||
it("deletes cascade through nested return reasons", async () => {
|
||||
expect.assertions(10)
|
||||
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
label: "Wrong Size",
|
||||
description: "Use this if the size was wrong",
|
||||
value: "wrong_size",
|
||||
}
|
||||
|
||||
const response = await api
|
||||
.post("/admin/return-reasons", payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
expect(response.data.return_reason).toEqual(
|
||||
expect.objectContaining({
|
||||
label: "Wrong Size",
|
||||
description: "Use this if the size was wrong",
|
||||
value: "wrong_size",
|
||||
})
|
||||
)
|
||||
|
||||
const payload_child = {
|
||||
label: "Too Big",
|
||||
description: "Use this if the size was too big",
|
||||
value: "too_big",
|
||||
parent_return_reason_id: response.data.return_reason.id,
|
||||
}
|
||||
|
||||
const response_child = await api
|
||||
.post("/admin/return-reasons", payload_child, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response_child.status).toEqual(200)
|
||||
|
||||
expect(response_child.data.return_reason).toEqual(
|
||||
expect.objectContaining({
|
||||
label: "Too Big",
|
||||
description: "Use this if the size was too big",
|
||||
value: "too_big",
|
||||
parent_return_reason_id: response.data.return_reason.id,
|
||||
})
|
||||
)
|
||||
|
||||
const deleteResult = await api
|
||||
.delete(`/admin/return-reasons/${response.data.return_reason.id}`, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err.response.data)
|
||||
})
|
||||
|
||||
expect(deleteResult.status).toEqual(200)
|
||||
|
||||
expect(deleteResult.data).toEqual({
|
||||
id: response.data.return_reason.id,
|
||||
object: "return_reason",
|
||||
deleted: true,
|
||||
})
|
||||
|
||||
await api
|
||||
.get(`/admin/return-reasons/${response.data.return_reason.id}`, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
expect(err.response.status).toEqual(404)
|
||||
expect(err.response.data.type).toEqual("not_found")
|
||||
})
|
||||
|
||||
await api
|
||||
.get(`/admin/return-reasons/${response_child.data.return_reason.id}`, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
expect(err.response.status).toEqual(404)
|
||||
expect(err.response.data.type).toEqual("not_found")
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,102 +1,53 @@
|
||||
const path = require("path");
|
||||
const path = require("path")
|
||||
const {
|
||||
Region,
|
||||
ShippingProfile,
|
||||
ShippingOption,
|
||||
ShippingOptionRequirement,
|
||||
} = require("@medusajs/medusa");
|
||||
} = require("@medusajs/medusa")
|
||||
|
||||
const setupServer = require("../../../helpers/setup-server");
|
||||
const { useApi } = require("../../../helpers/use-api");
|
||||
const { initDb, useDb } = require("../../../helpers/use-db");
|
||||
const adminSeeder = require("../../helpers/admin-seeder");
|
||||
const setupServer = require("../../../helpers/setup-server")
|
||||
const { useApi } = require("../../../helpers/use-api")
|
||||
const { initDb, useDb } = require("../../../helpers/use-db")
|
||||
const adminSeeder = require("../../helpers/admin-seeder")
|
||||
const shippingOptionSeeder = require("../../helpers/shipping-option-seeder")
|
||||
|
||||
jest.setTimeout(30000);
|
||||
jest.setTimeout(30000)
|
||||
|
||||
describe("/admin/shipping-options", () => {
|
||||
let medusaProcess;
|
||||
let dbConnection;
|
||||
let medusaProcess
|
||||
let dbConnection
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."));
|
||||
dbConnection = await initDb({ cwd });
|
||||
medusaProcess = await setupServer({ cwd });
|
||||
});
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
medusaProcess = await setupServer({ cwd })
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb();
|
||||
await db.shutdown();
|
||||
medusaProcess.kill();
|
||||
});
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
medusaProcess.kill()
|
||||
})
|
||||
|
||||
describe("POST /admin/shipping-options", () => {
|
||||
describe("POST /admin/shipping-options/:id", () => {
|
||||
beforeEach(async () => {
|
||||
const manager = dbConnection.manager;
|
||||
|
||||
try {
|
||||
await adminSeeder(dbConnection);
|
||||
|
||||
await manager.insert(Region, {
|
||||
id: "region",
|
||||
name: "Test Region",
|
||||
currency_code: "usd",
|
||||
tax_rate: 0,
|
||||
});
|
||||
|
||||
const defaultProfile = await manager.findOne(ShippingProfile, {
|
||||
type: "default",
|
||||
});
|
||||
|
||||
await manager.insert(ShippingOption, {
|
||||
id: "test-out",
|
||||
name: "Test out",
|
||||
profile_id: defaultProfile.id,
|
||||
region_id: "region",
|
||||
provider_id: "test-ful",
|
||||
data: {},
|
||||
price_type: "flat_rate",
|
||||
amount: 2000,
|
||||
is_return: false,
|
||||
});
|
||||
|
||||
await manager.insert(ShippingOption, {
|
||||
id: "test-option-req",
|
||||
name: "With req",
|
||||
profile_id: defaultProfile.id,
|
||||
region_id: "region",
|
||||
provider_id: "test-ful",
|
||||
data: {},
|
||||
price_type: "flat_rate",
|
||||
amount: 2000,
|
||||
is_return: false,
|
||||
});
|
||||
|
||||
await manager.insert(ShippingOptionRequirement, {
|
||||
id: "option-req",
|
||||
shipping_option_id: "test-option-req",
|
||||
type: "min_subtotal",
|
||||
amount: 5,
|
||||
});
|
||||
|
||||
await manager.insert(ShippingOptionRequirement, {
|
||||
id: "option-req-2",
|
||||
shipping_option_id: "test-option-req",
|
||||
type: "max_subtotal",
|
||||
amount: 10,
|
||||
});
|
||||
await adminSeeder(dbConnection)
|
||||
await shippingOptionSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
throw err;
|
||||
console.error(err)
|
||||
throw err
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb();
|
||||
await db.teardown();
|
||||
});
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("updates a shipping option with no existing requirements", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
name: "Test option",
|
||||
@@ -111,36 +62,36 @@ describe("/admin/shipping-options", () => {
|
||||
amount: 2,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const res = await api.post(`/admin/shipping-options/test-out`, payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
});
|
||||
})
|
||||
|
||||
const requirements = res.data.shipping_option.requirements;
|
||||
const requirements = res.data.shipping_option.requirements
|
||||
|
||||
expect(res.status).toEqual(200);
|
||||
expect(requirements.length).toEqual(2);
|
||||
expect(res.status).toEqual(200)
|
||||
expect(requirements.length).toEqual(2)
|
||||
expect(requirements[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
type: "min_subtotal",
|
||||
shipping_option_id: "test-out",
|
||||
amount: 1,
|
||||
})
|
||||
);
|
||||
)
|
||||
expect(requirements[1]).toEqual(
|
||||
expect.objectContaining({
|
||||
type: "max_subtotal",
|
||||
shipping_option_id: "test-out",
|
||||
amount: 2,
|
||||
})
|
||||
);
|
||||
});
|
||||
)
|
||||
})
|
||||
|
||||
it("fails as it is not allowed to set id from client side", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
name: "Test option",
|
||||
@@ -157,7 +108,7 @@ describe("/admin/shipping-options", () => {
|
||||
amount: 2,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const res = await api
|
||||
.post(`/admin/shipping-options/test-out`, payload, {
|
||||
@@ -166,15 +117,15 @@ describe("/admin/shipping-options", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
return err.response;
|
||||
});
|
||||
return err.response
|
||||
})
|
||||
|
||||
expect(res.status).toEqual(400);
|
||||
expect(res.data.message).toEqual("ID does not exist");
|
||||
});
|
||||
expect(res.status).toEqual(400)
|
||||
expect(res.data.message).toEqual("ID does not exist")
|
||||
})
|
||||
|
||||
it("it succesfully updates a set of existing requirements", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
requirements: [
|
||||
@@ -190,7 +141,7 @@ describe("/admin/shipping-options", () => {
|
||||
},
|
||||
],
|
||||
amount: 200,
|
||||
};
|
||||
}
|
||||
|
||||
const res = await api
|
||||
.post(`/admin/shipping-options/test-option-req`, payload, {
|
||||
@@ -199,14 +150,14 @@ describe("/admin/shipping-options", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err.response.data.message);
|
||||
});
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
|
||||
expect(res.status).toEqual(200);
|
||||
});
|
||||
expect(res.status).toEqual(200)
|
||||
})
|
||||
|
||||
it("it succesfully updates a set of existing requirements by updating one and deleting the other", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
requirements: [
|
||||
@@ -216,7 +167,7 @@ describe("/admin/shipping-options", () => {
|
||||
amount: 15,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const res = await api
|
||||
.post(`/admin/shipping-options/test-option-req`, payload, {
|
||||
@@ -225,14 +176,14 @@ describe("/admin/shipping-options", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err.response.data.message);
|
||||
});
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
|
||||
expect(res.status).toEqual(200);
|
||||
});
|
||||
expect(res.status).toEqual(200)
|
||||
})
|
||||
|
||||
it("succesfully updates a set of requirements because max. subtotal >= min. subtotal", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
requirements: [
|
||||
@@ -247,7 +198,7 @@ describe("/admin/shipping-options", () => {
|
||||
amount: 200,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const res = await api
|
||||
.post(`/admin/shipping-options/test-option-req`, payload, {
|
||||
@@ -256,16 +207,16 @@ describe("/admin/shipping-options", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err.response.data.message);
|
||||
});
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
|
||||
expect(res.status).toEqual(200);
|
||||
expect(res.data.shipping_option.requirements[0].amount).toEqual(150);
|
||||
expect(res.data.shipping_option.requirements[1].amount).toEqual(200);
|
||||
});
|
||||
expect(res.status).toEqual(200)
|
||||
expect(res.data.shipping_option.requirements[0].amount).toEqual(150)
|
||||
expect(res.data.shipping_option.requirements[1].amount).toEqual(200)
|
||||
})
|
||||
|
||||
it("fails to updates a set of requirements because max. subtotal <= min. subtotal", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
requirements: [
|
||||
@@ -280,7 +231,7 @@ describe("/admin/shipping-options", () => {
|
||||
amount: 200,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const res = await api
|
||||
.post(`/admin/shipping-options/test-option-req`, payload, {
|
||||
@@ -289,13 +240,147 @@ describe("/admin/shipping-options", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
return err.response;
|
||||
});
|
||||
return err.response
|
||||
})
|
||||
|
||||
expect(res.status).toEqual(400);
|
||||
expect(res.status).toEqual(400)
|
||||
expect(res.data.message).toEqual(
|
||||
"Max. subtotal must be greater than Min. subtotal"
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe("POST /admin/shipping-options", () => {
|
||||
let payload
|
||||
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection)
|
||||
await shippingOptionSeeder(dbConnection)
|
||||
|
||||
const api = useApi()
|
||||
await api.post(
|
||||
`/admin/regions/region`,
|
||||
{
|
||||
fulfillment_providers: ["test-ful"],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
const manager = dbConnection.manager
|
||||
const defaultProfile = await manager.findOne(ShippingProfile, {
|
||||
type: "default",
|
||||
})
|
||||
|
||||
payload = {
|
||||
name: "Test option",
|
||||
amount: 100,
|
||||
price_type: "flat_rate",
|
||||
region_id: "region",
|
||||
provider_id: "test-ful",
|
||||
data: {},
|
||||
profile_id: defaultProfile.id,
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
throw err
|
||||
}
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("creates a shipping option with requirements", async () => {
|
||||
const api = useApi()
|
||||
payload.requirements = [
|
||||
{
|
||||
type: "max_subtotal",
|
||||
amount: 2,
|
||||
},
|
||||
{
|
||||
type: "min_subtotal",
|
||||
amount: 1,
|
||||
},
|
||||
]
|
||||
|
||||
const res = await api.post(`/admin/shipping-options`, payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
|
||||
expect(res.status).toEqual(200)
|
||||
expect(res.data.shipping_option.requirements.length).toEqual(2)
|
||||
})
|
||||
|
||||
it("creates a shipping option with no requirements", async () => {
|
||||
const api = useApi()
|
||||
const res = await api.post(`/admin/shipping-options`, payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
|
||||
expect(res.status).toEqual(200)
|
||||
expect(res.data.shipping_option.requirements.length).toEqual(0)
|
||||
})
|
||||
|
||||
it("fails on same requirement types", async () => {
|
||||
const api = useApi()
|
||||
payload.requirements = [
|
||||
{
|
||||
type: "max_subtotal",
|
||||
amount: 2,
|
||||
},
|
||||
{
|
||||
type: "max_subtotal",
|
||||
amount: 1,
|
||||
},
|
||||
]
|
||||
|
||||
try {
|
||||
await api.post(`/admin/shipping-options`, payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
} catch (error) {
|
||||
expect(error.response.data.message).toEqual(
|
||||
"Only one requirement of each type is allowed"
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
it("fails when min_subtotal > max_subtotal", async () => {
|
||||
const api = useApi()
|
||||
payload.requirements = [
|
||||
{
|
||||
type: "max_subtotal",
|
||||
amount: 2,
|
||||
},
|
||||
{
|
||||
type: "min_subtotal",
|
||||
amount: 4,
|
||||
},
|
||||
]
|
||||
|
||||
try {
|
||||
await api.post(`/admin/shipping-options`, payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
} catch (error) {
|
||||
expect(error.response.data.message).toEqual(
|
||||
"Max. subtotal must be greater than Min. subtotal"
|
||||
)
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,49 +1,49 @@
|
||||
const path = require("path");
|
||||
const path = require("path")
|
||||
|
||||
const setupServer = require("../../../helpers/setup-server");
|
||||
const { useApi } = require("../../../helpers/use-api");
|
||||
const { initDb, useDb } = require("../../../helpers/use-db");
|
||||
const setupServer = require("../../../helpers/setup-server")
|
||||
const { useApi } = require("../../../helpers/use-api")
|
||||
const { initDb, useDb } = require("../../../helpers/use-db")
|
||||
|
||||
const orderSeeder = require("../../helpers/order-seeder");
|
||||
const swapSeeder = require("../../helpers/swap-seeder");
|
||||
const adminSeeder = require("../../helpers/admin-seeder");
|
||||
const orderSeeder = require("../../helpers/order-seeder")
|
||||
const swapSeeder = require("../../helpers/swap-seeder")
|
||||
const adminSeeder = require("../../helpers/admin-seeder")
|
||||
|
||||
jest.setTimeout(30000);
|
||||
jest.setTimeout(30000)
|
||||
|
||||
describe("/admin/swaps", () => {
|
||||
let medusaProcess;
|
||||
let dbConnection;
|
||||
let medusaProcess
|
||||
let dbConnection
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."));
|
||||
dbConnection = await initDb({ cwd });
|
||||
medusaProcess = await setupServer({ cwd });
|
||||
});
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
medusaProcess = await setupServer({ cwd })
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb();
|
||||
await db.shutdown();
|
||||
medusaProcess.kill();
|
||||
});
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
medusaProcess.kill()
|
||||
})
|
||||
|
||||
describe("GET /admin/swaps/:id", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection);
|
||||
await orderSeeder(dbConnection);
|
||||
await swapSeeder(dbConnection);
|
||||
await adminSeeder(dbConnection)
|
||||
await orderSeeder(dbConnection)
|
||||
await swapSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
throw err;
|
||||
throw err
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb();
|
||||
await db.teardown();
|
||||
});
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("gets a swap with cart and totals", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.get("/admin/swaps/test-swap", {
|
||||
@@ -52,46 +52,46 @@ describe("/admin/swaps", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
expect(response.status).toEqual(200);
|
||||
console.log(err)
|
||||
})
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.swap).toEqual(
|
||||
expect.objectContaining({
|
||||
id: "test-swap",
|
||||
})
|
||||
);
|
||||
)
|
||||
|
||||
expect(response.data.swap.cart).toEqual(
|
||||
expect.objectContaining({
|
||||
id: "test-cart",
|
||||
id: "test-cart-w-swap",
|
||||
shipping_total: 1000,
|
||||
subtotal: 1000,
|
||||
total: 2000,
|
||||
})
|
||||
);
|
||||
expect(response.data.swap.cart).toHaveProperty("discount_total");
|
||||
expect(response.data.swap.cart).toHaveProperty("gift_card_total");
|
||||
});
|
||||
});
|
||||
)
|
||||
expect(response.data.swap.cart).toHaveProperty("discount_total")
|
||||
expect(response.data.swap.cart).toHaveProperty("gift_card_total")
|
||||
})
|
||||
})
|
||||
|
||||
describe("GET /admin/swaps/", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection);
|
||||
await orderSeeder(dbConnection);
|
||||
await swapSeeder(dbConnection);
|
||||
await adminSeeder(dbConnection)
|
||||
await orderSeeder(dbConnection)
|
||||
await swapSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
throw err;
|
||||
throw err
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb();
|
||||
await db.teardown();
|
||||
});
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("lists all swaps", async () => {
|
||||
const api = useApi();
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.get("/admin/swaps/", {
|
||||
@@ -100,18 +100,18 @@ describe("/admin/swaps", () => {
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.data).toHaveProperty("count");
|
||||
expect(response.data.offset).toBe(0);
|
||||
expect(response.data.limit).toBe(50);
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data).toHaveProperty("count")
|
||||
expect(response.data.offset).toBe(0)
|
||||
expect(response.data.limit).toBe(50)
|
||||
expect(response.data.swaps).toContainEqual(
|
||||
expect.objectContaining({
|
||||
id: "test-swap",
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,153 @@
|
||||
const path = require("path")
|
||||
|
||||
const setupServer = require("../../../helpers/setup-server")
|
||||
const { useApi } = require("../../../helpers/use-api")
|
||||
const { initDb, useDb } = require("../../../helpers/use-db")
|
||||
|
||||
const adminSeeder = require("../../helpers/admin-seeder")
|
||||
const productSeeder = require("../../helpers/product-seeder")
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
describe("/admin/products", () => {
|
||||
let medusaProcess
|
||||
let dbConnection
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
medusaProcess = await setupServer({ cwd })
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
|
||||
medusaProcess.kill()
|
||||
})
|
||||
|
||||
describe("GET /admin/product-variants", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await productSeeder(dbConnection)
|
||||
await adminSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("lists all product variants", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.get("/admin/variants/", {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.variants).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining(
|
||||
{
|
||||
id: "test-variant",
|
||||
},
|
||||
{
|
||||
id: "test-variant_2",
|
||||
},
|
||||
{
|
||||
id: "test-variant_1",
|
||||
}
|
||||
),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("lists all product variants matching a specific sku", async () => {
|
||||
const api = useApi()
|
||||
const response = await api
|
||||
.get("/admin/variants?q=sku2", {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.variants.length).toEqual(1)
|
||||
expect(response.data.variants).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
sku: "test-sku2",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("lists all product variants matching a specific variant title", async () => {
|
||||
const api = useApi()
|
||||
const response = await api
|
||||
.get("/admin/variants?q=rank (1)", {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.variants.length).toEqual(1)
|
||||
expect(response.data.variants).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-variant_1",
|
||||
sku: "test-sku1",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("lists all product variants matching a specific product title", async () => {
|
||||
const api = useApi()
|
||||
const response = await api
|
||||
.get("/admin/variants?q=Test product1", {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.variants.length).toEqual(2)
|
||||
expect(response.data.variants).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
product_id: "test-product1",
|
||||
id: "test-variant_3",
|
||||
sku: "test-sku3",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
product_id: "test-product1",
|
||||
id: "test-variant_4",
|
||||
sku: "test-sku4",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,18 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`/admin/discounts creates store session correctly 1`] = `
|
||||
Object {
|
||||
"billing_address_id": null,
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"email": "test@testesen.dk",
|
||||
"first_name": "test",
|
||||
"has_account": true,
|
||||
"id": Any<String>,
|
||||
"last_name": "testesen",
|
||||
"metadata": null,
|
||||
"orders": Array [],
|
||||
"phone": "12345678",
|
||||
"updated_at": Any<String>,
|
||||
}
|
||||
`;
|
||||
@@ -8,6 +8,14 @@ Object {
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`/store/carts POST /store/carts/:id fails to complete swap cart with items inventory not/partially covered 1`] = `
|
||||
Object {
|
||||
"code": "insufficient_inventory",
|
||||
"message": "Variant with id: test-variant-2 does not have the required inventory",
|
||||
"type": "not_allowed",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`/store/carts POST /store/carts/:id returns early, if cart is already completed 1`] = `
|
||||
Object {
|
||||
"code": "cart_incompatible_state",
|
||||
|
||||
@@ -101,6 +101,7 @@ Object {
|
||||
],
|
||||
"origin_country": null,
|
||||
"profile_id": StringMatching /\\^sp_\\*/,
|
||||
"status": "draft",
|
||||
"subtitle": null,
|
||||
"tags": Array [
|
||||
Object {
|
||||
|
||||
@@ -58,6 +58,7 @@ Object {
|
||||
"mid_code": null,
|
||||
"origin_country": null,
|
||||
"profile_id": StringMatching /\\^sp_\\*/,
|
||||
"status": "draft",
|
||||
"subtitle": null,
|
||||
"thumbnail": null,
|
||||
"title": "test product",
|
||||
@@ -91,6 +92,7 @@ Object {
|
||||
"parent_order_id": "test-order",
|
||||
"swap_id": StringMatching /\\^swap_\\*/,
|
||||
},
|
||||
"payment_authorized_at": null,
|
||||
"payment_id": null,
|
||||
"region_id": "test-region",
|
||||
"shipping_address_id": "test-shipping-address",
|
||||
@@ -227,6 +229,7 @@ Object {
|
||||
"mid_code": null,
|
||||
"origin_country": null,
|
||||
"profile_id": StringMatching /\\^sp_\\*/,
|
||||
"status": "draft",
|
||||
"subtitle": null,
|
||||
"thumbnail": null,
|
||||
"title": "test product",
|
||||
@@ -260,6 +263,7 @@ Object {
|
||||
"parent_order_id": "test-order",
|
||||
"swap_id": StringMatching /\\^swap_\\*/,
|
||||
},
|
||||
"payment_authorized_at": null,
|
||||
"payment_id": null,
|
||||
"region_id": "test-region",
|
||||
"shipping_address_id": "test-shipping-address",
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
const path = require("path")
|
||||
const { Region, DiscountRule, Discount } = require("@medusajs/medusa")
|
||||
|
||||
const setupServer = require("../../../helpers/setup-server")
|
||||
const { useApi } = require("../../../helpers/use-api")
|
||||
const { initDb, useDb } = require("../../../helpers/use-db")
|
||||
const adminSeeder = require("../../helpers/admin-seeder")
|
||||
const { exportAllDeclaration } = require("@babel/types")
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
describe("/admin/auth", () => {
|
||||
let medusaProcess
|
||||
let dbConnection
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
medusaProcess = await setupServer({ cwd })
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
const db = useDb()
|
||||
await db.shutdown()
|
||||
medusaProcess.kill()
|
||||
})
|
||||
|
||||
it("creates store session correctly", async () => {
|
||||
const api = useApi()
|
||||
|
||||
await api
|
||||
.post("/store/customers", {
|
||||
email: "test@testesen.dk",
|
||||
password: "secret_password",
|
||||
first_name: "test",
|
||||
last_name: "testesen",
|
||||
phone: "12345678",
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
const response = await api
|
||||
.post("/store/auth", {
|
||||
email: "test@testesen.dk",
|
||||
password: "secret_password",
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.customer.password_hash).toEqual(undefined)
|
||||
expect(response.data.customer).toMatchSnapshot({
|
||||
id: expect.any(String),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
first_name: "test",
|
||||
last_name: "testesen",
|
||||
phone: "12345678",
|
||||
email: "test@testesen.dk",
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -27,8 +27,12 @@ describe("/store/carts", () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
||||
dbConnection = await initDb({ cwd })
|
||||
medusaProcess = await setupServer({ cwd })
|
||||
try {
|
||||
dbConnection = await initDb({ cwd })
|
||||
medusaProcess = await setupServer({ cwd })
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
@@ -103,6 +107,7 @@ describe("/store/carts", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await cartSeeder(dbConnection)
|
||||
await swapSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
throw err
|
||||
@@ -113,7 +118,26 @@ describe("/store/carts", () => {
|
||||
await doAfterEach()
|
||||
})
|
||||
|
||||
// We were experiencing some issues when having created a cart in a region
|
||||
// containing multiple countries. At this point, the cart does not have a shipping
|
||||
// address. Therefore, on subsequent requests to update the cart, the server
|
||||
// would throw a 500 due to missing shipping address id on insertion.
|
||||
it("updates a cart, that does not have a shipping address", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api.post("/store/carts", {
|
||||
region_id: "test-region-multiple",
|
||||
})
|
||||
|
||||
const getRes = await api.post(`/store/carts/${response.data.cart.id}`, {
|
||||
region_id: "test-region",
|
||||
})
|
||||
|
||||
expect(getRes.status).toEqual(200)
|
||||
})
|
||||
|
||||
it("fails on apply discount if limit has been reached", async () => {
|
||||
expect.assertions(2)
|
||||
const api = useApi()
|
||||
|
||||
try {
|
||||
@@ -128,6 +152,62 @@ describe("/store/carts", () => {
|
||||
}
|
||||
})
|
||||
|
||||
it("fails to apply expired discount", async () => {
|
||||
expect.assertions(2)
|
||||
const api = useApi()
|
||||
|
||||
try {
|
||||
await api.post("/store/carts/test-cart", {
|
||||
discounts: [{ code: "EXP_DISC" }],
|
||||
})
|
||||
} catch (error) {
|
||||
expect(error.response.status).toEqual(400)
|
||||
expect(error.response.data.message).toEqual("Discount is expired")
|
||||
}
|
||||
})
|
||||
|
||||
it("fails on discount before start day", async () => {
|
||||
expect.assertions(2)
|
||||
const api = useApi()
|
||||
|
||||
try {
|
||||
await api.post("/store/carts/test-cart", {
|
||||
discounts: [{ code: "PREM_DISC" }],
|
||||
})
|
||||
} catch (error) {
|
||||
expect(error.response.status).toEqual(400)
|
||||
expect(error.response.data.message).toEqual("Discount is not valid yet")
|
||||
}
|
||||
})
|
||||
|
||||
it("fails on apply invalid dynamic discount", async () => {
|
||||
const api = useApi()
|
||||
|
||||
try {
|
||||
await api.post("/store/carts/test-cart", {
|
||||
discounts: [{ code: "INV_DYN_DISC" }],
|
||||
})
|
||||
} catch (error) {
|
||||
expect(error.response.status).toEqual(400)
|
||||
expect(error.response.data.message).toEqual("Discount is expired")
|
||||
}
|
||||
})
|
||||
|
||||
it("Applies dynamic discount to cart correctly", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const cart = await api.post(
|
||||
"/store/carts/test-cart",
|
||||
{
|
||||
discounts: [{ code: "DYN_DISC" }],
|
||||
},
|
||||
{ withCredentials: true }
|
||||
)
|
||||
|
||||
expect(cart.data.cart.shipping_total).toBe(1000)
|
||||
expect(cart.status).toEqual(200)
|
||||
})
|
||||
|
||||
it("updates cart customer id", async () => {
|
||||
const api = useApi()
|
||||
|
||||
@@ -279,9 +359,82 @@ describe("/store/carts", () => {
|
||||
expect(e.response.status).toBe(409)
|
||||
}
|
||||
|
||||
//check to see if payment has been cancelled
|
||||
//check to see if payment has been cancelled and cart is not completed
|
||||
const res = await api.get(`/store/carts/test-cart-2`)
|
||||
expect(res.data.cart.payment.canceled_at).not.toBe(null)
|
||||
expect(res.data.cart.completed_at).toBe(null)
|
||||
})
|
||||
|
||||
it("fails to complete swap cart with items inventory not/partially covered", async () => {
|
||||
const manager = dbConnection.manager
|
||||
|
||||
const li = manager.create(LineItem, {
|
||||
id: "test-item",
|
||||
title: "Line Item",
|
||||
description: "Line Item Desc",
|
||||
thumbnail: "https://test.js/1234",
|
||||
unit_price: 8000,
|
||||
quantity: 99,
|
||||
variant_id: "test-variant-2",
|
||||
cart_id: "swap-cart",
|
||||
})
|
||||
await manager.save(li)
|
||||
|
||||
await manager.query(
|
||||
"UPDATE swap SET cart_id='swap-cart' where id='test-swap'"
|
||||
)
|
||||
|
||||
const api = useApi()
|
||||
|
||||
try {
|
||||
await api.post(`/store/carts/swap-cart/complete-cart`)
|
||||
} catch (e) {
|
||||
expect(e.response.data).toMatchSnapshot({
|
||||
code: "insufficient_inventory",
|
||||
})
|
||||
expect(e.response.status).toBe(409)
|
||||
}
|
||||
|
||||
//check to see if payment has been cancelled and cart is not completed
|
||||
const res = await api.get(`/store/carts/swap-cart`)
|
||||
expect(res.data.cart.payment_authorized_at).toBe(null)
|
||||
expect(res.data.cart.payment.canceled_at).not.toBe(null)
|
||||
})
|
||||
|
||||
it("successfully completes swap cart with items inventory not/partially covered due to backorder flag", async () => {
|
||||
const manager = dbConnection.manager
|
||||
|
||||
const li = manager.create(LineItem, {
|
||||
id: "test-item",
|
||||
title: "Line Item",
|
||||
description: "Line Item Desc",
|
||||
thumbnail: "https://test.js/1234",
|
||||
unit_price: 8000,
|
||||
quantity: 99,
|
||||
variant_id: "test-variant-2",
|
||||
cart_id: "swap-cart",
|
||||
})
|
||||
await manager.save(li)
|
||||
await manager.query(
|
||||
"UPDATE swap SET cart_id='swap-cart' where id='test-swap'"
|
||||
)
|
||||
await manager.query(
|
||||
"UPDATE swap SET allow_backorder=true where id='test-swap'"
|
||||
)
|
||||
await manager.query("DELETE FROM payment where swap_id='test-swap'")
|
||||
|
||||
const api = useApi()
|
||||
|
||||
try {
|
||||
await api.post(`/store/carts/swap-cart/complete-cart`)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
|
||||
//check to see if payment is authorized and cart is completed
|
||||
const res = await api.get(`/store/carts/swap-cart`)
|
||||
expect(res.data.cart.payment_authorized_at).not.toBe(null)
|
||||
expect(res.data.cart.completed_at).not.toBe(null)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -377,13 +530,15 @@ describe("/store/carts", () => {
|
||||
)
|
||||
|
||||
// Add a 10% discount to the cart
|
||||
const cartWithGiftcard = await api.post(
|
||||
"/store/carts/test-cart",
|
||||
{
|
||||
discounts: [{ code: "10PERCENT" }],
|
||||
},
|
||||
{ withCredentials: true }
|
||||
)
|
||||
const cartWithGiftcard = await api
|
||||
.post(
|
||||
"/store/carts/test-cart",
|
||||
{
|
||||
discounts: [{ code: "10PERCENT" }],
|
||||
},
|
||||
{ withCredentials: true }
|
||||
)
|
||||
.catch((err) => console.log(err))
|
||||
|
||||
// Ensure that the discount is only applied to the standard item
|
||||
expect(cartWithGiftcard.data.cart.total).toBe(1900) // 1000 (giftcard) + 900 (standard item with 10% discount)
|
||||
|
||||
@@ -5,6 +5,7 @@ const { useApi } = require("../../../helpers/use-api")
|
||||
const { initDb, useDb } = require("../../../helpers/use-db")
|
||||
|
||||
const productSeeder = require("../../helpers/product-seeder")
|
||||
const adminSeeder = require("../../helpers/admin-seeder")
|
||||
jest.setTimeout(30000)
|
||||
describe("/store/products", () => {
|
||||
let medusaProcess
|
||||
@@ -26,6 +27,7 @@ describe("/store/products", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await productSeeder(dbConnection)
|
||||
await adminSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
throw err
|
||||
@@ -261,5 +263,38 @@ describe("/store/products", () => {
|
||||
|
||||
expect(product.variants.some((variant) => variant.options)).toEqual(false)
|
||||
})
|
||||
|
||||
it("lists all published products", async () => {
|
||||
const api = useApi()
|
||||
|
||||
//update test-product status to published
|
||||
await api
|
||||
.post(
|
||||
"/admin/products/test-product",
|
||||
{
|
||||
status: "published",
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
const response = await api.get("/store/products")
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.products).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: "test-product",
|
||||
status: "published",
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -26,16 +26,35 @@ describe("/store/return-reasons", () => {
|
||||
|
||||
describe("GET /store/return-reasons", () => {
|
||||
let rrId;
|
||||
let rrId_1;
|
||||
let rrId_2;
|
||||
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
const created = dbConnection.manager.create(ReturnReason, {
|
||||
value: "too_big",
|
||||
label: "Too Big",
|
||||
value: "wrong_size",
|
||||
label: "Wrong size",
|
||||
});
|
||||
|
||||
const result = await dbConnection.manager.save(created);
|
||||
rrId = result.id;
|
||||
|
||||
const created_child = dbConnection.manager.create(ReturnReason, {
|
||||
value: "too_big",
|
||||
label: "Too Big",
|
||||
parent_return_reason_id: rrId
|
||||
});
|
||||
|
||||
const result_child = await dbConnection.manager.save(created_child);
|
||||
rrId_1 = result_child.id;
|
||||
|
||||
const created_2 = dbConnection.manager.create(ReturnReason, {
|
||||
value: "too_big_1",
|
||||
label: "Too Big 1",
|
||||
});
|
||||
|
||||
const result_2 = await dbConnection.manager.save(created_2);
|
||||
rrId_2 = result_2.id;
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
throw err;
|
||||
@@ -59,7 +78,15 @@ describe("/store/return-reasons", () => {
|
||||
expect(response.data.return_reasons).toEqual([
|
||||
expect.objectContaining({
|
||||
id: rrId,
|
||||
value: "too_big",
|
||||
value: "wrong_size",
|
||||
return_reason_children:[expect.objectContaining({
|
||||
id: rrId_1,
|
||||
value: "too_big",
|
||||
}),]
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: rrId_2,
|
||||
value: "too_big_1",
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -8,6 +8,7 @@ const {
|
||||
Product,
|
||||
ProductVariant,
|
||||
ShippingOption,
|
||||
FulfillmentProvider,
|
||||
LineItem,
|
||||
Discount,
|
||||
DiscountRule,
|
||||
@@ -37,6 +38,8 @@ describe("/store/carts", () => {
|
||||
|
||||
describe("POST /store/returns", () => {
|
||||
let rrId;
|
||||
let rrId_child;
|
||||
let rrResult;
|
||||
|
||||
beforeEach(async () => {
|
||||
const manager = dbConnection.manager;
|
||||
@@ -44,13 +47,17 @@ describe("/store/carts", () => {
|
||||
`ALTER SEQUENCE order_display_id_seq RESTART WITH 111`
|
||||
);
|
||||
|
||||
const defaultProfile = await manager.findOne(ShippingProfile, {
|
||||
type: "default",
|
||||
});
|
||||
|
||||
await manager.insert(Region, {
|
||||
id: "region",
|
||||
name: "Test Region",
|
||||
currency_code: "usd",
|
||||
tax_rate: 0,
|
||||
});
|
||||
|
||||
|
||||
await manager.insert(Customer, {
|
||||
id: "cus_1234",
|
||||
email: "test@email.com",
|
||||
@@ -98,10 +105,6 @@ describe("/store/carts", () => {
|
||||
|
||||
await manager.save(ord);
|
||||
|
||||
const defaultProfile = await manager.findOne(ShippingProfile, {
|
||||
type: "default",
|
||||
});
|
||||
|
||||
await manager.insert(Product, {
|
||||
id: "test-product",
|
||||
title: "test product",
|
||||
@@ -147,12 +150,23 @@ describe("/store/carts", () => {
|
||||
});
|
||||
|
||||
const created = dbConnection.manager.create(ReturnReason, {
|
||||
value: "too_big",
|
||||
label: "Too Big",
|
||||
value: "wrong_size",
|
||||
label: "Wrong Size",
|
||||
});
|
||||
const result = await dbConnection.manager.save(created);
|
||||
|
||||
rrResult = result
|
||||
rrId = result.id;
|
||||
|
||||
const created_1 = dbConnection.manager.create(ReturnReason, {
|
||||
value: "too_big",
|
||||
label: "Too Big",
|
||||
parent_return_reason_id: rrId,
|
||||
});
|
||||
|
||||
const result_1 = await dbConnection.manager.save(created_1);
|
||||
|
||||
rrId_child = result_1.id;
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
@@ -181,6 +195,59 @@ describe("/store/carts", () => {
|
||||
expect(response.data.return.refund_amount).toEqual(8000);
|
||||
});
|
||||
|
||||
it("failes to create a return with a reason category", async () => {
|
||||
const api = useApi();
|
||||
|
||||
const response = await api
|
||||
.post("/store/returns", {
|
||||
order_id: "order_test",
|
||||
items: [
|
||||
{
|
||||
reason_id: rrId,
|
||||
note: "TOO small",
|
||||
item_id: "test-item",
|
||||
quantity: 1,
|
||||
},
|
||||
],
|
||||
})
|
||||
.catch((err) => {
|
||||
return err.response;
|
||||
});
|
||||
|
||||
expect(response.status).toEqual(400);
|
||||
expect(response.data.message).toEqual('Cannot apply return reason category')
|
||||
|
||||
});
|
||||
|
||||
it("creates a return with reasons", async () => {
|
||||
const api = useApi();
|
||||
|
||||
const response = await api
|
||||
.post("/store/returns", {
|
||||
order_id: "order_test",
|
||||
items: [
|
||||
{
|
||||
reason_id: rrId_child,
|
||||
note: "TOO small",
|
||||
item_id: "test-item",
|
||||
quantity: 1,
|
||||
},
|
||||
],
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err.response)
|
||||
return err.response;
|
||||
});
|
||||
expect(response.status).toEqual(200);
|
||||
|
||||
expect(response.data.return.items).toEqual([
|
||||
expect.objectContaining({
|
||||
reason_id: rrId_child,
|
||||
note: "TOO small",
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
it("creates a return with discount and non-discountable item", async () => {
|
||||
const api = useApi();
|
||||
|
||||
@@ -234,32 +301,5 @@ describe("/store/carts", () => {
|
||||
expect(response.data.return.refund_amount).toEqual(7000);
|
||||
});
|
||||
|
||||
it("creates a return with reasons", async () => {
|
||||
const api = useApi();
|
||||
|
||||
const response = await api
|
||||
.post("/store/returns", {
|
||||
order_id: "order_test",
|
||||
items: [
|
||||
{
|
||||
reason_id: rrId,
|
||||
note: "TOO small",
|
||||
item_id: "test-item",
|
||||
quantity: 1,
|
||||
},
|
||||
],
|
||||
})
|
||||
.catch((err) => {
|
||||
return err.response;
|
||||
});
|
||||
expect(response.status).toEqual(200);
|
||||
|
||||
expect(response.data.return.items).toEqual([
|
||||
expect.objectContaining({
|
||||
reason_id: rrId,
|
||||
note: "TOO small",
|
||||
}),
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,11 +1,11 @@
|
||||
const Scrypt = require("scrypt-kdf");
|
||||
const { User } = require("@medusajs/medusa");
|
||||
const Scrypt = require("scrypt-kdf")
|
||||
const { User } = require("@medusajs/medusa")
|
||||
|
||||
module.exports = async (connection, data = {}) => {
|
||||
const manager = connection.manager;
|
||||
const manager = connection.manager
|
||||
|
||||
const buf = await Scrypt.kdf("secret_password", { logN: 1, r: 1, p: 1 });
|
||||
const password_hash = buf.toString("base64");
|
||||
const buf = await Scrypt.kdf("secret_password", { logN: 1, r: 1, p: 1 })
|
||||
const password_hash = buf.toString("base64")
|
||||
|
||||
await manager.insert(User, {
|
||||
id: "admin_user",
|
||||
@@ -13,5 +13,5 @@ module.exports = async (connection, data = {}) => {
|
||||
api_token: "test_token",
|
||||
password_hash,
|
||||
...data,
|
||||
});
|
||||
};
|
||||
})
|
||||
}
|
||||
@@ -17,6 +17,18 @@ const {
|
||||
} = require("@medusajs/medusa")
|
||||
|
||||
module.exports = async (connection, data = {}) => {
|
||||
const yesterday = ((today) => new Date(today.setDate(today.getDate() - 1)))(
|
||||
new Date()
|
||||
)
|
||||
const tomorrow = ((today) => new Date(today.setDate(today.getDate() + 1)))(
|
||||
new Date()
|
||||
)
|
||||
const tenDaysAgo = ((today) => new Date(today.setDate(today.getDate() - 10)))(
|
||||
new Date()
|
||||
)
|
||||
const tenDaysFromToday = ((today) =>
|
||||
new Date(today.setDate(today.getDate() + 10)))(new Date())
|
||||
|
||||
const manager = connection.manager
|
||||
|
||||
const defaultProfile = await manager.findOne(ShippingProfile, {
|
||||
@@ -39,6 +51,25 @@ module.exports = async (connection, data = {}) => {
|
||||
currency_code: "usd",
|
||||
tax_rate: 0,
|
||||
})
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
// Region with multiple countries
|
||||
const regionWithMultipleCoutries = manager.create(Region, {
|
||||
id: "test-region-multiple",
|
||||
name: "Test Region",
|
||||
currency_code: "eur",
|
||||
tax_rate: 0,
|
||||
})
|
||||
|
||||
await manager.save(regionWithMultipleCoutries)
|
||||
await manager.query(
|
||||
`UPDATE "country" SET region_id='test-region-multiple' WHERE iso_2 = 'no'`
|
||||
)
|
||||
await manager.query(
|
||||
`UPDATE "country" SET region_id='test-region-multiple' WHERE iso_2 = 'dk'`
|
||||
)
|
||||
>>>>>>> develop
|
||||
|
||||
const freeRule = manager.create(DiscountRule, {
|
||||
id: "free-shipping-rule",
|
||||
@@ -72,6 +103,11 @@ module.exports = async (connection, data = {}) => {
|
||||
code: "10PERCENT",
|
||||
is_dynamic: false,
|
||||
is_disabled: false,
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
starts_at: tenDaysAgo,
|
||||
ends_at: tenDaysFromToday,
|
||||
>>>>>>> develop
|
||||
})
|
||||
|
||||
tenPercent.regions = [r]
|
||||
@@ -92,11 +128,105 @@ module.exports = async (connection, data = {}) => {
|
||||
value: 10000,
|
||||
allocation: "total",
|
||||
})
|
||||
<<<<<<< HEAD
|
||||
|
||||
d.rule = dr
|
||||
d.regions = [r]
|
||||
|
||||
await manager.save(d)
|
||||
=======
|
||||
|
||||
d.rule = dr
|
||||
d.regions = [r]
|
||||
|
||||
await manager.save(d)
|
||||
|
||||
const expiredRule = manager.create(DiscountRule, {
|
||||
id: "expiredRule",
|
||||
description: "expired rule",
|
||||
type: "fixed",
|
||||
value: 100,
|
||||
allocation: "total",
|
||||
})
|
||||
|
||||
const expiredDisc = manager.create(Discount, {
|
||||
id: "expiredDisc",
|
||||
code: "EXP_DISC",
|
||||
is_dynamic: false,
|
||||
is_disabled: false,
|
||||
starts_at: tenDaysAgo,
|
||||
ends_at: yesterday,
|
||||
})
|
||||
|
||||
expiredDisc.regions = [r]
|
||||
expiredDisc.rule = expiredRule
|
||||
await manager.save(expiredDisc)
|
||||
|
||||
const prematureRule = manager.create(DiscountRule, {
|
||||
id: "prematureRule",
|
||||
description: "premature rule",
|
||||
type: "fixed",
|
||||
value: 100,
|
||||
allocation: "total",
|
||||
})
|
||||
|
||||
const prematureDiscount = manager.create(Discount, {
|
||||
id: "prematureDiscount",
|
||||
code: "PREM_DISC",
|
||||
is_dynamic: false,
|
||||
is_disabled: false,
|
||||
starts_at: tomorrow,
|
||||
ends_at: tenDaysFromToday,
|
||||
})
|
||||
|
||||
prematureDiscount.regions = [r]
|
||||
prematureDiscount.rule = prematureRule
|
||||
await manager.save(prematureDiscount)
|
||||
|
||||
const invalidDynamicRule = manager.create(DiscountRule, {
|
||||
id: "invalidDynamicRule",
|
||||
description: "invalidDynamic rule",
|
||||
type: "fixed",
|
||||
value: 100,
|
||||
allocation: "total",
|
||||
})
|
||||
|
||||
const invalidDynamicDiscount = manager.create(Discount, {
|
||||
id: "invalidDynamicDiscount",
|
||||
code: "INV_DYN_DISC",
|
||||
is_dynamic: true,
|
||||
is_disabled: false,
|
||||
starts_at: tenDaysAgo,
|
||||
ends_at: tenDaysFromToday,
|
||||
valid_duration: "P1D", // one day
|
||||
})
|
||||
|
||||
invalidDynamicDiscount.regions = [r]
|
||||
invalidDynamicDiscount.rule = invalidDynamicRule
|
||||
await manager.save(invalidDynamicDiscount)
|
||||
|
||||
const DynamicRule = manager.create(DiscountRule, {
|
||||
id: "DynamicRule",
|
||||
description: "Dynamic rule",
|
||||
type: "fixed",
|
||||
value: 10000,
|
||||
allocation: "total",
|
||||
})
|
||||
|
||||
const DynamicDiscount = manager.create(Discount, {
|
||||
id: "DynamicDiscount",
|
||||
code: "DYN_DISC",
|
||||
is_dynamic: true,
|
||||
is_disabled: false,
|
||||
starts_at: tenDaysAgo,
|
||||
ends_at: tenDaysFromToday,
|
||||
valid_duration: "P1M", //one month
|
||||
})
|
||||
|
||||
DynamicDiscount.regions = [r]
|
||||
DynamicDiscount.rule = DynamicRule
|
||||
await manager.save(DynamicDiscount)
|
||||
>>>>>>> develop
|
||||
|
||||
await manager.query(
|
||||
`UPDATE "country" SET region_id='test-region' WHERE iso_2 = 'us'`
|
||||
@@ -259,6 +389,28 @@ module.exports = async (connection, data = {}) => {
|
||||
completed_at: null,
|
||||
items: [],
|
||||
})
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
const swapCart = manager.create(Cart, {
|
||||
id: "swap-cart",
|
||||
type: "swap",
|
||||
customer_id: "some-customer",
|
||||
email: "some-customer@email.com",
|
||||
shipping_address: {
|
||||
id: "test-shipping-address",
|
||||
first_name: "lebron",
|
||||
country_code: "us",
|
||||
},
|
||||
region_id: "test-region",
|
||||
currency_code: "usd",
|
||||
completed_at: null,
|
||||
items: [],
|
||||
metadata: {
|
||||
swap_id: "test-swap",
|
||||
},
|
||||
})
|
||||
>>>>>>> develop
|
||||
|
||||
const pay = manager.create(Payment, {
|
||||
id: "test-payment",
|
||||
@@ -268,12 +420,38 @@ module.exports = async (connection, data = {}) => {
|
||||
provider_id: "test-pay",
|
||||
data: {},
|
||||
})
|
||||
<<<<<<< HEAD
|
||||
|
||||
await manager.save(pay)
|
||||
|
||||
cart2.payment = pay
|
||||
|
||||
await manager.save(cart2)
|
||||
=======
|
||||
|
||||
await manager.save(pay)
|
||||
|
||||
cart2.payment = pay
|
||||
|
||||
await manager.save(cart2)
|
||||
const swapPay = manager.create(Payment, {
|
||||
id: "test-swap-payment",
|
||||
amount: 10000,
|
||||
currency_code: "usd",
|
||||
amount_refunded: 0,
|
||||
provider_id: "test-pay",
|
||||
data: {},
|
||||
})
|
||||
|
||||
await manager.save(pay)
|
||||
await manager.save(swapPay)
|
||||
|
||||
cart2.payment = pay
|
||||
swapCart.payment = swapPay
|
||||
|
||||
await manager.save(cart2)
|
||||
await manager.save(swapCart)
|
||||
>>>>>>> develop
|
||||
|
||||
await manager.insert(PaymentSession, {
|
||||
id: "test-session",
|
||||
@@ -283,6 +461,18 @@ module.exports = async (connection, data = {}) => {
|
||||
data: {},
|
||||
status: "authorized",
|
||||
})
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
await manager.insert(PaymentSession, {
|
||||
id: "test-swap-session",
|
||||
cart_id: "swap-cart",
|
||||
provider_id: "test-pay",
|
||||
is_selected: true,
|
||||
data: {},
|
||||
status: "authorized",
|
||||
})
|
||||
>>>>>>> develop
|
||||
|
||||
await manager.insert(ShippingMethod, {
|
||||
id: "test-method",
|
||||
|
||||
@@ -1,27 +1,33 @@
|
||||
const { Customer, Address } = require("@medusajs/medusa");
|
||||
const { Customer, Address } = require("@medusajs/medusa")
|
||||
|
||||
module.exports = async (connection, data = {}) => {
|
||||
const manager = connection.manager;
|
||||
const manager = connection.manager
|
||||
|
||||
await manager.insert(Customer, {
|
||||
id: "test-customer-1",
|
||||
email: "test1@email.com",
|
||||
});
|
||||
})
|
||||
|
||||
await manager.insert(Customer, {
|
||||
id: "test-customer-2",
|
||||
email: "test2@email.com",
|
||||
});
|
||||
})
|
||||
|
||||
await manager.insert(Customer, {
|
||||
id: "test-customer-3",
|
||||
email: "test3@email.com",
|
||||
});
|
||||
})
|
||||
|
||||
await manager.insert(Customer, {
|
||||
id: "test-customer-has_account",
|
||||
email: "test4@email.com",
|
||||
has_account: true,
|
||||
})
|
||||
|
||||
await manager.insert(Address, {
|
||||
id: "test-address",
|
||||
first_name: "Lebron",
|
||||
last_name: "James",
|
||||
customer_id: "test-customer-1",
|
||||
});
|
||||
};
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
const {
|
||||
Region,
|
||||
ShippingProfile,
|
||||
ShippingOption,
|
||||
ShippingOptionRequirement,
|
||||
} = require("@medusajs/medusa")
|
||||
|
||||
module.exports = async (connection, data = {}) => {
|
||||
const manager = connection.manager
|
||||
|
||||
await manager.insert(Region, {
|
||||
id: "region",
|
||||
name: "Test Region",
|
||||
currency_code: "usd",
|
||||
tax_rate: 0,
|
||||
})
|
||||
|
||||
const defaultProfile = await manager.findOne(ShippingProfile, {
|
||||
type: "default",
|
||||
})
|
||||
|
||||
await manager.insert(ShippingOption, {
|
||||
id: "test-out",
|
||||
name: "Test out",
|
||||
profile_id: defaultProfile.id,
|
||||
region_id: "region",
|
||||
provider_id: "test-ful",
|
||||
data: {},
|
||||
price_type: "flat_rate",
|
||||
amount: 2000,
|
||||
is_return: false,
|
||||
})
|
||||
|
||||
await manager.insert(ShippingOption, {
|
||||
id: "test-option-req",
|
||||
name: "With req",
|
||||
profile_id: defaultProfile.id,
|
||||
region_id: "region",
|
||||
provider_id: "test-ful",
|
||||
data: {},
|
||||
price_type: "flat_rate",
|
||||
amount: 2000,
|
||||
is_return: false,
|
||||
})
|
||||
|
||||
await manager.insert(ShippingOptionRequirement, {
|
||||
id: "option-req",
|
||||
shipping_option_id: "test-option-req",
|
||||
type: "min_subtotal",
|
||||
amount: 5,
|
||||
})
|
||||
|
||||
await manager.insert(ShippingOptionRequirement, {
|
||||
id: "option-req-2",
|
||||
shipping_option_id: "test-option-req",
|
||||
type: "max_subtotal",
|
||||
amount: 10,
|
||||
})
|
||||
}
|
||||
@@ -14,7 +14,6 @@ const {
|
||||
Swap,
|
||||
Cart,
|
||||
Return,
|
||||
RMAShippingOption,
|
||||
} = require("@medusajs/medusa")
|
||||
|
||||
module.exports = async (connection, data = {}) => {
|
||||
@@ -56,7 +55,7 @@ module.exports = async (connection, data = {}) => {
|
||||
orderWithSwap = await manager.save(orderWithSwap)
|
||||
|
||||
const cart = manager.create(Cart, {
|
||||
id: "test-cart",
|
||||
id: "test-cart-w-swap",
|
||||
customer_id: "test-customer",
|
||||
email: "test-customer@email.com",
|
||||
shipping_address_id: "test-shipping-address",
|
||||
@@ -76,7 +75,7 @@ module.exports = async (connection, data = {}) => {
|
||||
order_id: "order-with-swap",
|
||||
payment_status: "captured",
|
||||
fulfillment_status: "fulfilled",
|
||||
cart_id: "test-cart",
|
||||
cart_id: "test-cart-w-swap",
|
||||
payment: {
|
||||
id: "test-payment-swap",
|
||||
amount: 10000,
|
||||
@@ -95,12 +94,13 @@ module.exports = async (connection, data = {}) => {
|
||||
unit_price: 9000,
|
||||
quantity: 1,
|
||||
variant_id: "test-variant-2",
|
||||
cart_id: "test-cart",
|
||||
cart_id: "test-cart-w-swap",
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
await manager.save(swap)
|
||||
<<<<<<< HEAD
|
||||
|
||||
const rmaCart = manager.create(Cart, {
|
||||
id: "test-cart-rma",
|
||||
@@ -154,6 +154,8 @@ module.exports = async (connection, data = {}) => {
|
||||
})
|
||||
|
||||
await manager.save(swapWithRMAMethod)
|
||||
=======
|
||||
>>>>>>> develop
|
||||
|
||||
const cartTemplate = async (cartId) => {
|
||||
const cart = manager.create(Cart, {
|
||||
@@ -253,7 +255,10 @@ module.exports = async (connection, data = {}) => {
|
||||
order_id: orderWithSwap.id,
|
||||
item_id: li.id,
|
||||
refund_amount: li.quantity * li.unit_price,
|
||||
<<<<<<< HEAD
|
||||
// shipping_method_id: ,
|
||||
=======
|
||||
>>>>>>> develop
|
||||
})
|
||||
|
||||
await manager.save(swapReturn)
|
||||
@@ -268,7 +273,7 @@ module.exports = async (connection, data = {}) => {
|
||||
await manager.insert(ShippingMethod, {
|
||||
id: "another-test-method",
|
||||
shipping_option_id: "test-option",
|
||||
cart_id: "test-cart",
|
||||
cart_id: "test-cart-w-swap",
|
||||
price: 1000,
|
||||
data: {},
|
||||
})
|
||||
|
||||
@@ -8,15 +8,15 @@
|
||||
"build": "babel src -d dist --extensions \".ts,.js\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/medusa": "1.1.41-dev-1632959007011",
|
||||
"medusa-interfaces": "1.1.23-dev-1632959007011",
|
||||
"@medusajs/medusa": "1.1.40-dev-1631630701835",
|
||||
"medusa-interfaces": "1.1.21-dev-1631630701835",
|
||||
"typeorm": "^0.2.31"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.12.10",
|
||||
"@babel/core": "^7.12.10",
|
||||
"@babel/node": "^7.12.10",
|
||||
"babel-preset-medusa-package": "1.1.15-dev-1632959007011",
|
||||
"babel-preset-medusa-package": "1.1.13-dev-1631630701835",
|
||||
"jest": "^26.6.3"
|
||||
}
|
||||
}
|
||||
@@ -1223,10 +1223,10 @@
|
||||
"@types/yargs" "^15.0.0"
|
||||
chalk "^4.0.0"
|
||||
|
||||
"@medusajs/medusa-cli@1.1.18-dev-1632959007011":
|
||||
version "1.1.18-dev-1632959007011"
|
||||
resolved "http://localhost:4873/@medusajs%2fmedusa-cli/-/medusa-cli-1.1.18-dev-1632959007011.tgz#015c1c783a66e6ce7304f38ccee45e805c828885"
|
||||
integrity sha512-6Aa9coormjBoAcQsymBCJXbtwHIF+IXovjq0C7CbwS58oytzJiReB+WJQmK1/tMq79femCIzH6TCLAqWkZCpWg==
|
||||
"@medusajs/medusa-cli@1.1.16-dev-1631630701835":
|
||||
version "1.1.16-dev-1631630701835"
|
||||
resolved "http://localhost:4873/@medusajs%2fmedusa-cli/-/medusa-cli-1.1.16-dev-1631630701835.tgz#7fcb95cb9a45e0367cc5becfff7f5d1533b46b5f"
|
||||
integrity sha512-UomtR8B1lBFDb3h1y060fOcWcZi812Jwt8Kgjxqtpn+aRj6Bu7+I3WJGHBVSx4VnUBINSYbtiQMpEwqVGTCKnw==
|
||||
dependencies:
|
||||
"@babel/polyfill" "^7.8.7"
|
||||
"@babel/runtime" "^7.9.6"
|
||||
@@ -1244,8 +1244,8 @@
|
||||
is-valid-path "^0.1.1"
|
||||
joi-objectid "^3.0.1"
|
||||
meant "^1.0.1"
|
||||
medusa-core-utils "1.1.22-dev-1632959007011"
|
||||
medusa-telemetry "0.0.5-dev-1632959007011"
|
||||
medusa-core-utils "1.1.20-dev-1631630701835"
|
||||
medusa-telemetry "0.0.3-dev-1631630701835"
|
||||
netrc-parser "^3.1.6"
|
||||
open "^8.0.6"
|
||||
ora "^5.4.1"
|
||||
@@ -1259,13 +1259,13 @@
|
||||
winston "^3.3.3"
|
||||
yargs "^15.3.1"
|
||||
|
||||
"@medusajs/medusa@1.1.41-dev-1632959007011":
|
||||
version "1.1.41-dev-1632959007011"
|
||||
resolved "http://localhost:4873/@medusajs%2fmedusa/-/medusa-1.1.41-dev-1632959007011.tgz#be73b1d7bc3af918130f7dff7883c6badda68a50"
|
||||
integrity sha512-IVmz2U329dUTvC79yhxiH4mwEejvaTlecpM68uGQfNlU0lfONJQDNAzrLoBeYsrVI1okmVWTuDVvg22UE4Mc3A==
|
||||
"@medusajs/medusa@1.1.40-dev-1631630701835":
|
||||
version "1.1.40-dev-1631630701835"
|
||||
resolved "http://localhost:4873/@medusajs%2fmedusa/-/medusa-1.1.40-dev-1631630701835.tgz#fa67ceda5887fd31196b3bcfd3115a9e02d68448"
|
||||
integrity sha512-svPsKonuBrwRgtYod7U7ho9bN84K7N/QorMJG9+wklEO4jp6zXG+U5DQcfVAKQ00cHHe50OcnfX1ZS0kVNovYw==
|
||||
dependencies:
|
||||
"@hapi/joi" "^16.1.8"
|
||||
"@medusajs/medusa-cli" "1.1.18-dev-1632959007011"
|
||||
"@medusajs/medusa-cli" "1.1.16-dev-1631630701835"
|
||||
"@types/lodash" "^4.14.168"
|
||||
awilix "^4.2.3"
|
||||
body-parser "^1.19.0"
|
||||
@@ -1286,8 +1286,8 @@
|
||||
joi "^17.3.0"
|
||||
joi-objectid "^3.0.1"
|
||||
jsonwebtoken "^8.5.1"
|
||||
medusa-core-utils "1.1.22-dev-1632959007011"
|
||||
medusa-test-utils "1.1.25-dev-1632959007011"
|
||||
medusa-core-utils "1.1.20-dev-1631630701835"
|
||||
medusa-test-utils "1.1.23-dev-1631630701835"
|
||||
morgan "^1.9.1"
|
||||
multer "^1.4.2"
|
||||
passport "^0.4.0"
|
||||
@@ -1933,10 +1933,10 @@ babel-preset-jest@^26.6.2:
|
||||
babel-plugin-jest-hoist "^26.6.2"
|
||||
babel-preset-current-node-syntax "^1.0.0"
|
||||
|
||||
babel-preset-medusa-package@1.1.15-dev-1632959007011:
|
||||
version "1.1.15-dev-1632959007011"
|
||||
resolved "http://localhost:4873/babel-preset-medusa-package/-/babel-preset-medusa-package-1.1.15-dev-1632959007011.tgz#fa8d0e46ab52761446c03452bbc00c0eed5ca1b8"
|
||||
integrity sha512-3E4NjDP/9OUS9DW5aCV6bcYwLYpa3xRIlR2q8WTZMaM+jsIxSuA7+HD1tbmDrxMpRB9ErYPhX6iyKZMzvHKw6w==
|
||||
babel-preset-medusa-package@1.1.13-dev-1631630701835:
|
||||
version "1.1.13-dev-1631630701835"
|
||||
resolved "http://localhost:4873/babel-preset-medusa-package/-/babel-preset-medusa-package-1.1.13-dev-1631630701835.tgz#5b66b3738e4904e31b2db30a6ea8e68eb0f8f641"
|
||||
integrity sha512-V7sXlktlvEON7FLhxe+Y3NVe8l8DQyB5oJTryG4Bhw8y1AaUFOiQ5Vat3XuoL3qRcUSVMGL4VHw0m0O78t0PuA==
|
||||
dependencies:
|
||||
"@babel/plugin-proposal-class-properties" "^7.12.1"
|
||||
"@babel/plugin-proposal-decorators" "^7.12.1"
|
||||
@@ -5105,25 +5105,25 @@ media-typer@0.3.0:
|
||||
resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748"
|
||||
integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=
|
||||
|
||||
medusa-core-utils@1.1.22-dev-1632959007011:
|
||||
version "1.1.22-dev-1632959007011"
|
||||
resolved "http://localhost:4873/medusa-core-utils/-/medusa-core-utils-1.1.22-dev-1632959007011.tgz#41209056f0a1a47503d8fc1d0c5e30e49811bdd9"
|
||||
integrity sha512-jRfRWMxiNDYwTQ6k9Lers7HWqTfI5ZjIihRKLIx+mGio/mOFVr243co7VIZXOUurL7BM3ddm2HP87nZTz68qBA==
|
||||
medusa-core-utils@1.1.20-dev-1631630701835:
|
||||
version "1.1.20-dev-1631630701835"
|
||||
resolved "http://localhost:4873/medusa-core-utils/-/medusa-core-utils-1.1.20-dev-1631630701835.tgz#1fa7ccd2551b7891127d4f07f708029c585f4ea8"
|
||||
integrity sha512-KKBo6W1QI47Ig3KMV4UXQnQN5JilMfjR6Cx7hDNj4frJoNiWa/YKDYqUr6SmY2+iJtKetnLkrKaPsDyyhZrxcw==
|
||||
dependencies:
|
||||
joi "^17.3.0"
|
||||
joi-objectid "^3.0.1"
|
||||
|
||||
medusa-interfaces@1.1.23-dev-1632959007011:
|
||||
version "1.1.23-dev-1632959007011"
|
||||
resolved "http://localhost:4873/medusa-interfaces/-/medusa-interfaces-1.1.23-dev-1632959007011.tgz#1e8cfc25d2c2363c370e3580b1f18bfa818b0569"
|
||||
integrity sha512-HyyY6FnUtvzw0w9/4H8dEfC6LcAkYNoxep9Rh0HZBwchrZUx/JaSUAmRWFSzHaaqjxk6txbZIVjerAj2t2YBRQ==
|
||||
medusa-interfaces@1.1.21-dev-1631630701835:
|
||||
version "1.1.21-dev-1631630701835"
|
||||
resolved "http://localhost:4873/medusa-interfaces/-/medusa-interfaces-1.1.21-dev-1631630701835.tgz#af29b2ef0c987bded1b2d295ac6cf39880af551e"
|
||||
integrity sha512-rTASRjOdcS3J9fP95p9vJzCpatMpUhTum5ddfAA0s42pZx2gsPlf1f+rUSNz5QfeC5RdIEzRfOmAGfvMpAbYGw==
|
||||
dependencies:
|
||||
medusa-core-utils "1.1.22-dev-1632959007011"
|
||||
medusa-core-utils "1.1.20-dev-1631630701835"
|
||||
|
||||
medusa-telemetry@0.0.5-dev-1632959007011:
|
||||
version "0.0.5-dev-1632959007011"
|
||||
resolved "http://localhost:4873/medusa-telemetry/-/medusa-telemetry-0.0.5-dev-1632959007011.tgz#b10a46693403140bf3d5963010d6c640340a3f33"
|
||||
integrity sha512-BqEb1MHz8ac1vMH0miIXNBbTkvvUvcy2WkoCVUnG4zzkL4cApXqUKitMUMT774kh2WO/glOnIccNNlKbAJgaZg==
|
||||
medusa-telemetry@0.0.3-dev-1631630701835:
|
||||
version "0.0.3-dev-1631630701835"
|
||||
resolved "http://localhost:4873/medusa-telemetry/-/medusa-telemetry-0.0.3-dev-1631630701835.tgz#d56c01d261fa30ccedc6d9976971b9744b9d8c0f"
|
||||
integrity sha512-FS1L1DOIOSdRZgeIQWaM5nhFG5NtbnC/Pntfac51vQxLkzFuHy7ZEtg11CXKE+x6NWlqT1rqqgxq0EabFzEZzw==
|
||||
dependencies:
|
||||
axios "^0.21.1"
|
||||
axios-retry "^3.1.9"
|
||||
@@ -5135,13 +5135,13 @@ medusa-telemetry@0.0.5-dev-1632959007011:
|
||||
remove-trailing-slash "^0.1.1"
|
||||
uuid "^8.3.2"
|
||||
|
||||
medusa-test-utils@1.1.25-dev-1632959007011:
|
||||
version "1.1.25-dev-1632959007011"
|
||||
resolved "http://localhost:4873/medusa-test-utils/-/medusa-test-utils-1.1.25-dev-1632959007011.tgz#c3d971e89d52d35898ab7d95c2a449846ce1cd38"
|
||||
integrity sha512-wCKlIugeRlgJIaoyYN5K9KtJaBd66rdmg1yD5Vxq+Fd5rftJUOP2wiN5nIV0BK5v13mMH56iSY7aOK12Um287Q==
|
||||
medusa-test-utils@1.1.23-dev-1631630701835:
|
||||
version "1.1.23-dev-1631630701835"
|
||||
resolved "http://localhost:4873/medusa-test-utils/-/medusa-test-utils-1.1.23-dev-1631630701835.tgz#8995d636caf2dea9ebb184f1e15b0c364c4d1b93"
|
||||
integrity sha512-A8xRL+sZS22qXZSHpVfdV8f/egZxXs4iExRO2xUkTP6I/OgMhFBSg6nEd/DXVdVfpsHZCDEv8PA3ewaeAkoYhQ==
|
||||
dependencies:
|
||||
"@babel/plugin-transform-classes" "^7.9.5"
|
||||
medusa-core-utils "1.1.22-dev-1632959007011"
|
||||
medusa-core-utils "1.1.20-dev-1631630701835"
|
||||
randomatic "^3.1.1"
|
||||
|
||||
merge-descriptors@1.0.1:
|
||||
|
||||
Reference in new issue
Block a user