chore: merge release
This commit is contained in:
@@ -0,0 +1,204 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`/admin/collections /admin/collections creates a collection 1`] = `
|
||||
Object {
|
||||
"collection": Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"handle": "test-handle-creation",
|
||||
"id": StringMatching /\\^pcol_\\*/,
|
||||
"metadata": null,
|
||||
"title": "test collection creation",
|
||||
"updated_at": Any<String>,
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`/admin/collections /admin/collections lists collections 1`] = `
|
||||
Object {
|
||||
"collections": Array [
|
||||
Object {
|
||||
"handle": "test-collection",
|
||||
"id": "test-collection",
|
||||
"products": Array [
|
||||
Object {
|
||||
"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": "test-product",
|
||||
"is_giftcard": false,
|
||||
"length": null,
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"origin_country": null,
|
||||
"profile_id": StringMatching /\\^sp_\\*/,
|
||||
"status": "draft",
|
||||
"subtitle": null,
|
||||
"thumbnail": null,
|
||||
"title": "Test product",
|
||||
"type_id": "test-type",
|
||||
"updated_at": Any<String>,
|
||||
"weight": null,
|
||||
"width": null,
|
||||
},
|
||||
Object {
|
||||
"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": "test-product1",
|
||||
"is_giftcard": false,
|
||||
"length": null,
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"origin_country": null,
|
||||
"profile_id": StringMatching /\\^sp_\\*/,
|
||||
"status": "draft",
|
||||
"subtitle": null,
|
||||
"thumbnail": null,
|
||||
"title": "Test product1",
|
||||
"type_id": "test-type",
|
||||
"updated_at": Any<String>,
|
||||
"weight": null,
|
||||
"width": null,
|
||||
},
|
||||
],
|
||||
"title": "Test collection",
|
||||
},
|
||||
Object {
|
||||
"handle": "test-collection1",
|
||||
"id": "test-collection1",
|
||||
"products": Array [
|
||||
Object {
|
||||
"collection_id": "test-collection1",
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"description": "test-product-description",
|
||||
"discountable": true,
|
||||
"handle": "test-product_filtering_1",
|
||||
"height": null,
|
||||
"hs_code": null,
|
||||
"id": "test-product_filtering_1",
|
||||
"is_giftcard": false,
|
||||
"length": null,
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"origin_country": null,
|
||||
"profile_id": StringMatching /\\^sp_\\*/,
|
||||
"status": "proposed",
|
||||
"subtitle": null,
|
||||
"thumbnail": null,
|
||||
"title": "Test product filtering 1",
|
||||
"type_id": "test-type",
|
||||
"updated_at": Any<String>,
|
||||
"weight": null,
|
||||
"width": null,
|
||||
},
|
||||
Object {
|
||||
"collection_id": "test-collection1",
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"description": "test-product-description",
|
||||
"discountable": true,
|
||||
"handle": "test-product_filtering_3",
|
||||
"height": null,
|
||||
"hs_code": null,
|
||||
"id": "test-product_filtering_3",
|
||||
"is_giftcard": false,
|
||||
"length": null,
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"origin_country": null,
|
||||
"profile_id": StringMatching /\\^sp_\\*/,
|
||||
"status": "draft",
|
||||
"subtitle": null,
|
||||
"thumbnail": null,
|
||||
"title": "Test product filtering 3",
|
||||
"type_id": "test-type",
|
||||
"updated_at": Any<String>,
|
||||
"weight": null,
|
||||
"width": null,
|
||||
},
|
||||
],
|
||||
"title": "Test collection 1",
|
||||
},
|
||||
Object {
|
||||
"handle": "test-collection2",
|
||||
"id": "test-collection2",
|
||||
"products": Array [
|
||||
Object {
|
||||
"collection_id": "test-collection2",
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"description": "test-product-description",
|
||||
"discountable": true,
|
||||
"handle": "test-product_filtering_2",
|
||||
"height": null,
|
||||
"hs_code": null,
|
||||
"id": "test-product_filtering_2",
|
||||
"is_giftcard": false,
|
||||
"length": null,
|
||||
"material": null,
|
||||
"metadata": null,
|
||||
"mid_code": null,
|
||||
"origin_country": null,
|
||||
"profile_id": StringMatching /\\^sp_\\*/,
|
||||
"status": "published",
|
||||
"subtitle": null,
|
||||
"thumbnail": null,
|
||||
"title": "Test product filtering 2",
|
||||
"type_id": "test-type",
|
||||
"updated_at": Any<String>,
|
||||
"weight": null,
|
||||
"width": null,
|
||||
},
|
||||
],
|
||||
"title": "Test collection 2",
|
||||
},
|
||||
],
|
||||
"count": 3,
|
||||
"limit": 10,
|
||||
"offset": 0,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`/admin/collections /admin/collections/:id gets collection 1`] = `
|
||||
Object {
|
||||
"collection": Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"handle": "test-collection",
|
||||
"id": "test-collection",
|
||||
"metadata": null,
|
||||
"title": "Test collection",
|
||||
"updated_at": Any<String>,
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`/admin/collections /admin/collections/:id updates a collection 1`] = `
|
||||
Object {
|
||||
"collection": Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"handle": "test-handle-creation",
|
||||
"id": StringMatching /\\^pcol_\\*/,
|
||||
"metadata": null,
|
||||
"title": "test collection creation",
|
||||
"updated_at": Any<String>,
|
||||
},
|
||||
}
|
||||
`;
|
||||
@@ -0,0 +1,22 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`/admin/orders POST /admin/orders/:id updates a shipping adress 1`] = `
|
||||
Object {
|
||||
"address_1": "Some Street",
|
||||
"address_2": "",
|
||||
"city": "losangeles",
|
||||
"company": null,
|
||||
"country_code": "us",
|
||||
"created_at": Any<String>,
|
||||
"customer_id": null,
|
||||
"deleted_at": null,
|
||||
"first_name": "lebron",
|
||||
"id": Any<String>,
|
||||
"last_name": null,
|
||||
"metadata": null,
|
||||
"phone": null,
|
||||
"postal_code": "1235",
|
||||
"province": "",
|
||||
"updated_at": Any<String>,
|
||||
}
|
||||
`;
|
||||
@@ -479,7 +479,7 @@ Array [
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`/admin/products GET /admin/products returns a list of products with giftcard in list 1`] = `
|
||||
exports[`/admin/products GET /admin/products returns a list of products with only giftcard in list 1`] = `
|
||||
Array [
|
||||
Object {
|
||||
"collection": null,
|
||||
|
||||
220
integration-tests/api/__tests__/admin/colllections.js
Normal file
220
integration-tests/api/__tests__/admin/colllections.js
Normal file
@@ -0,0 +1,220 @@
|
||||
const path = require("path")
|
||||
const setupServer = require("../../../helpers/setup-server")
|
||||
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("/admin/collections", () => {
|
||||
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("/admin/collections/:id", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection)
|
||||
await productSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("updates a collection", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const creationResponse = await api.post(
|
||||
"/admin/collections",
|
||||
{
|
||||
title: "test",
|
||||
},
|
||||
{ headers: { Authorization: "Bearer test_token" } }
|
||||
)
|
||||
|
||||
const response = await api.post(
|
||||
`/admin/collections/${creationResponse.data.collection.id}`,
|
||||
{
|
||||
title: "test collection creation",
|
||||
handle: "test-handle-creation",
|
||||
},
|
||||
{ headers: { Authorization: "Bearer test_token" } }
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data).toMatchSnapshot({
|
||||
collection: {
|
||||
id: expect.stringMatching(/^pcol_*/),
|
||||
title: "test collection creation",
|
||||
handle: "test-handle-creation",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
it("deletes a collection", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const creationResponse = await api.post(
|
||||
"/admin/collections",
|
||||
{
|
||||
title: "test",
|
||||
},
|
||||
{ headers: { Authorization: "Bearer test_token" } }
|
||||
)
|
||||
|
||||
const response = await api.delete(
|
||||
`/admin/collections/${creationResponse.data.collection.id}`,
|
||||
{ headers: { Authorization: "Bearer test_token" } }
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data).toEqual({
|
||||
id: creationResponse.data.collection.id,
|
||||
object: "product-collection",
|
||||
deleted: true,
|
||||
})
|
||||
})
|
||||
|
||||
it("gets collection", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api.get("/admin/collections/test-collection", {
|
||||
headers: { Authorization: "Bearer test_token" },
|
||||
})
|
||||
|
||||
expect(response.data).toMatchSnapshot({
|
||||
collection: {
|
||||
id: "test-collection",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("/admin/collections", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection)
|
||||
await productSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
throw err
|
||||
}
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("creates a collection", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api.post(
|
||||
"/admin/collections",
|
||||
{
|
||||
title: "test collection creation",
|
||||
handle: "test-handle-creation",
|
||||
},
|
||||
{ headers: { Authorization: "Bearer test_token" } }
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data).toMatchSnapshot({
|
||||
collection: {
|
||||
id: expect.stringMatching(/^pcol_*/),
|
||||
title: "test collection creation",
|
||||
handle: "test-handle-creation",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
it("lists collections", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api.get("/admin/collections", {
|
||||
headers: { Authorization: "Bearer test_token" },
|
||||
})
|
||||
|
||||
expect(response.data).toMatchSnapshot({
|
||||
collections: [
|
||||
{
|
||||
id: "test-collection",
|
||||
handle: "test-collection",
|
||||
title: "Test collection",
|
||||
products: [
|
||||
{
|
||||
collection_id: "test-collection",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
profile_id: expect.stringMatching(/^sp_*/),
|
||||
},
|
||||
{
|
||||
collection_id: "test-collection",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
profile_id: expect.stringMatching(/^sp_*/),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "test-collection1",
|
||||
handle: "test-collection1",
|
||||
title: "Test collection 1",
|
||||
products: [
|
||||
{
|
||||
collection_id: "test-collection1",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
profile_id: expect.stringMatching(/^sp_*/),
|
||||
},
|
||||
{
|
||||
collection_id: "test-collection1",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
profile_id: expect.stringMatching(/^sp_*/),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "test-collection2",
|
||||
handle: "test-collection2",
|
||||
title: "Test collection 2",
|
||||
products: [
|
||||
{
|
||||
collection_id: "test-collection2",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
profile_id: expect.stringMatching(/^sp_*/),
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
count: 3,
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,4 +1,3 @@
|
||||
const { dropDatabase } = require("pg-god")
|
||||
const path = require("path")
|
||||
|
||||
const setupServer = require("../../../helpers/setup-server")
|
||||
@@ -158,6 +157,7 @@ describe("/admin/customers", () => {
|
||||
first_name: "newf",
|
||||
last_name: "newl",
|
||||
email: "new@email.com",
|
||||
metadata: { foo: "bar" },
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
@@ -175,6 +175,7 @@ describe("/admin/customers", () => {
|
||||
first_name: "newf",
|
||||
last_name: "newl",
|
||||
email: "new@email.com",
|
||||
metadata: { foo: "bar" },
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
@@ -5,6 +5,8 @@ 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 discountSeeder = require("../../helpers/discount-seeder")
|
||||
const { exportAllDeclaration } = require("@babel/types")
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
@@ -27,32 +29,42 @@ describe("/admin/discounts", () => {
|
||||
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
|
||||
}
|
||||
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,
|
||||
})
|
||||
await manager.insert(Discount, {
|
||||
id: "dynamic-discount",
|
||||
code: "Dyn100",
|
||||
rule_id: "test-discount-rule",
|
||||
is_dynamic: true,
|
||||
is_disabled: false,
|
||||
})
|
||||
await manager.insert(Discount, {
|
||||
id: "disabled-discount",
|
||||
code: "Dis100",
|
||||
rule_id: "test-discount-rule",
|
||||
is_dynamic: false,
|
||||
is_disabled: true,
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
@@ -83,12 +95,57 @@ describe("/admin/discounts", () => {
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
it("lists dynamic discounts ", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.get("/admin/discounts?is_dynamic=true", {
|
||||
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.objectContaining({
|
||||
id: "dynamic-discount",
|
||||
code: "Dyn100",
|
||||
}),
|
||||
])
|
||||
})
|
||||
|
||||
it("lists disabled discounts ", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.get("/admin/discounts?is_disabled=true", {
|
||||
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.objectContaining({
|
||||
id: "disabled-discount",
|
||||
code: "Dis100",
|
||||
}),
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
describe("POST /admin/discounts", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection)
|
||||
await discountSeeder(dbConnection)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
throw err
|
||||
@@ -100,6 +157,60 @@ describe("/admin/discounts", () => {
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("creates a discount with a rule", 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,
|
||||
},
|
||||
{
|
||||
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,
|
||||
})
|
||||
)
|
||||
|
||||
const test = await api.get(
|
||||
`/admin/discounts/${response.data.discount.id}`,
|
||||
{ headers: { Authorization: "Bearer test_token" } }
|
||||
)
|
||||
|
||||
expect(test.status).toEqual(200)
|
||||
expect(test.data.discount).toEqual(
|
||||
expect.objectContaining({
|
||||
code: "HELLOWORLD",
|
||||
usage_limit: 10,
|
||||
rule: expect.objectContaining({
|
||||
value: 10,
|
||||
type: "percentage",
|
||||
description: "test",
|
||||
allocation: "total",
|
||||
}),
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it("creates a discount and updates it", async () => {
|
||||
const api = useApi()
|
||||
|
||||
@@ -159,6 +270,256 @@ describe("/admin/discounts", () => {
|
||||
)
|
||||
})
|
||||
|
||||
it("automatically sets the code to an uppercase string on update", 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,
|
||||
},
|
||||
{
|
||||
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,
|
||||
})
|
||||
)
|
||||
|
||||
const updated = await api
|
||||
.post(
|
||||
`/admin/discounts/${response.data.discount.id}`,
|
||||
{
|
||||
code: "HELLOWORLD_test",
|
||||
usage_limit: 20,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(updated.status).toEqual(200)
|
||||
expect(updated.data.discount).toEqual(
|
||||
expect.objectContaining({
|
||||
code: "HELLOWORLD_TEST",
|
||||
usage_limit: 20,
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it("creates a dynamic discount and updates it", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.post(
|
||||
"/admin/discounts",
|
||||
{
|
||||
code: "HELLOWORLD_DYNAMIC",
|
||||
is_dynamic: true,
|
||||
rule: {
|
||||
description: "test",
|
||||
type: "percentage",
|
||||
value: 10,
|
||||
allocation: "total",
|
||||
},
|
||||
usage_limit: 10,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.discount).toEqual(
|
||||
expect.objectContaining({
|
||||
code: "HELLOWORLD_DYNAMIC",
|
||||
usage_limit: 10,
|
||||
is_dynamic: true,
|
||||
})
|
||||
)
|
||||
|
||||
const updated = await api
|
||||
.post(
|
||||
`/admin/discounts/${response.data.discount.id}`,
|
||||
{
|
||||
usage_limit: 20,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(updated.status).toEqual(200)
|
||||
expect(updated.data.discount).toEqual(
|
||||
expect.objectContaining({
|
||||
code: "HELLOWORLD_DYNAMIC",
|
||||
usage_limit: 20,
|
||||
is_dynamic: true,
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it("fails to create a fixed discount with multiple regions", async () => {
|
||||
expect.assertions(2)
|
||||
const api = useApi()
|
||||
|
||||
await api
|
||||
.post(
|
||||
"/admin/discounts",
|
||||
{
|
||||
code: "HELLOWORLD",
|
||||
is_dynamic: true,
|
||||
rule: {
|
||||
description: "test",
|
||||
type: "fixed",
|
||||
value: 10,
|
||||
allocation: "total",
|
||||
},
|
||||
usage_limit: 10,
|
||||
regions: ["test-region", "test-region-2"],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
expect(err.response.status).toEqual(400)
|
||||
expect(err.response.data.message).toEqual(
|
||||
`Fixed discounts can have one region`
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
it("fails to update a fixed discount with multiple regions", async () => {
|
||||
expect.assertions(2)
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.post(
|
||||
"/admin/discounts",
|
||||
{
|
||||
code: "HELLOWORLD",
|
||||
rule: {
|
||||
description: "test",
|
||||
type: "fixed",
|
||||
value: 10,
|
||||
allocation: "total",
|
||||
},
|
||||
usage_limit: 10,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
await api
|
||||
.post(
|
||||
`/admin/discounts/${response.data.discount.id}`,
|
||||
{
|
||||
regions: ["test-region", "test-region-2"],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
.catch((err) => {
|
||||
expect(err.response.status).toEqual(400)
|
||||
expect(err.response.data.message).toEqual(
|
||||
`Fixed discounts can have one region`
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
it("fails to add a region to a fixed discount with an existing region", async () => {
|
||||
expect.assertions(2)
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.post(
|
||||
"/admin/discounts",
|
||||
{
|
||||
code: "HELLOWORLD",
|
||||
rule: {
|
||||
description: "test",
|
||||
type: "fixed",
|
||||
value: 10,
|
||||
allocation: "total",
|
||||
},
|
||||
usage_limit: 10,
|
||||
regions: ["test-region"],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
await api
|
||||
.post(
|
||||
`/admin/discounts/${response.data.discount.id}/regions/test-region-2`,
|
||||
{},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
.catch((err) => {
|
||||
expect(err.response.status).toEqual(400)
|
||||
expect(err.response.data.message).toEqual(
|
||||
`Fixed discounts can have one region`
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
it("creates a discount with start and end dates", async () => {
|
||||
const api = useApi()
|
||||
|
||||
@@ -338,11 +699,11 @@ describe("/admin/discounts", () => {
|
||||
)
|
||||
.catch((err) => {
|
||||
expect(err.response.status).toEqual(400)
|
||||
expect(err.response.data.message).toEqual([
|
||||
expect(err.response.data).toEqual(
|
||||
expect.objectContaining({
|
||||
message: `"ends_at" must be greater than "ref:starts_at"`,
|
||||
}),
|
||||
])
|
||||
message: `"ends_at" must be greater than "starts_at"`,
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -351,25 +712,21 @@ describe("/admin/discounts", () => {
|
||||
let manager
|
||||
beforeEach(async () => {
|
||||
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,
|
||||
})
|
||||
} catch (err) {
|
||||
throw err
|
||||
}
|
||||
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,
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
|
||||
@@ -158,12 +158,15 @@ describe("/admin/gift-cards", () => {
|
||||
it("creates a gift card", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const dateString = new Date().toISOString()
|
||||
|
||||
const response = await api
|
||||
.post(
|
||||
"/admin/gift-cards",
|
||||
{
|
||||
value: 1000,
|
||||
region_id: "region",
|
||||
ends_at: dateString,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
|
||||
@@ -3,7 +3,6 @@ const {
|
||||
ReturnReason,
|
||||
Order,
|
||||
LineItem,
|
||||
ProductVariant,
|
||||
CustomShippingOption,
|
||||
} = require("@medusajs/medusa")
|
||||
|
||||
@@ -74,6 +73,59 @@ describe("/admin/orders", () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe("POST /admin/orders/:id", () => {
|
||||
beforeEach(async () => {
|
||||
await adminSeeder(dbConnection)
|
||||
await orderSeeder(dbConnection)
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("updates a shipping adress", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.post(
|
||||
"/admin/orders/test-order",
|
||||
{
|
||||
email: "test@test.com",
|
||||
shipping_address: {
|
||||
address_1: "Some Street",
|
||||
address_2: "",
|
||||
province: "",
|
||||
postal_code: "1235",
|
||||
city: "losangeles",
|
||||
country_code: "us",
|
||||
},
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log(err.response.data)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.order.shipping_address).toMatchSnapshot({
|
||||
id: expect.any(String),
|
||||
address_1: "Some Street",
|
||||
address_2: "",
|
||||
province: "",
|
||||
postal_code: "1235",
|
||||
city: "losangeles",
|
||||
country_code: "us",
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("GET /admin/orders", () => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
@@ -163,7 +215,6 @@ describe("/admin/orders", () => {
|
||||
|
||||
it("cancels an order and increments inventory_quantity", async () => {
|
||||
const api = useApi()
|
||||
const manager = dbConnection.manager
|
||||
|
||||
const initialInventoryRes = await api.get("/store/variants/test-variant")
|
||||
|
||||
@@ -1086,7 +1137,7 @@ describe("/admin/orders", () => {
|
||||
}
|
||||
)
|
||||
|
||||
//Find variant that should have its inventory_quantity updated
|
||||
// Find variant that should have its inventory_quantity updated
|
||||
const toTest = returned.data.order.items.find((i) => i.id === "test-item")
|
||||
|
||||
expect(returned.status).toEqual(200)
|
||||
@@ -1119,7 +1170,7 @@ describe("/admin/orders", () => {
|
||||
}
|
||||
)
|
||||
|
||||
//Find variant that should have its inventory_quantity updated
|
||||
// Find variant that should have its inventory_quantity updated
|
||||
const toTest = returned.data.order.items.find((i) => i.id === "test-item")
|
||||
|
||||
expect(returned.status).toEqual(200)
|
||||
@@ -1178,6 +1229,44 @@ describe("/admin/orders", () => {
|
||||
])
|
||||
})
|
||||
|
||||
it("lists all orders with a fulfillment status = fulfilled", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.get("/admin/orders?fulfillment_status[]=fulfilled", {
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => console.log(err))
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.orders).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-order",
|
||||
}),
|
||||
])
|
||||
})
|
||||
|
||||
it("fails to lists all orders with an invalid status", async () => {
|
||||
expect.assertions(3)
|
||||
const api = useApi()
|
||||
|
||||
await api
|
||||
.get("/admin/orders?status[]=test", {
|
||||
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(
|
||||
"each value in status must be a valid enum value"
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
it("list all orders with matching order email", async () => {
|
||||
const api = useApi()
|
||||
|
||||
@@ -1671,7 +1760,7 @@ describe("/admin/orders", () => {
|
||||
|
||||
expect(returnOnOrder.status).toEqual(200)
|
||||
|
||||
const captured = await api.post(
|
||||
await api.post(
|
||||
"/admin/orders/test-order/capture",
|
||||
{},
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@ const { initDb, useDb } = require("../../../helpers/use-db")
|
||||
|
||||
const adminSeeder = require("../../helpers/admin-seeder")
|
||||
const productSeeder = require("../../helpers/product-seeder")
|
||||
const { ProductVariant } = require("@medusajs/medusa")
|
||||
|
||||
jest.setTimeout(50000)
|
||||
|
||||
@@ -105,7 +106,7 @@ describe("/admin/products", () => {
|
||||
status: "proposed",
|
||||
}
|
||||
|
||||
//update test-product status to proposed
|
||||
// update test-product status to proposed
|
||||
await api
|
||||
.post("/admin/products/test-product", payload, {
|
||||
headers: {
|
||||
@@ -143,6 +144,9 @@ describe("/admin/products", () => {
|
||||
const notExpected = [
|
||||
expect.objectContaining({ status: "draft" }),
|
||||
expect.objectContaining({ status: "rejected" }),
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_4",
|
||||
}),
|
||||
]
|
||||
|
||||
const response = await api
|
||||
@@ -174,6 +178,48 @@ describe("/admin/products", () => {
|
||||
}
|
||||
})
|
||||
|
||||
it("returns a list of deleted products with free text query", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.get("/admin/products?deleted_at[gt]=01-26-1990&q=test", {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.products).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_4",
|
||||
}),
|
||||
])
|
||||
})
|
||||
|
||||
it("returns a list of deleted products", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.get("/admin/products?deleted_at[gt]=01-26-1990", {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.products).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "test-product_filtering_4",
|
||||
}),
|
||||
])
|
||||
})
|
||||
|
||||
it("returns a list of products in collection", async () => {
|
||||
const api = useApi()
|
||||
|
||||
@@ -294,7 +340,7 @@ describe("/admin/products", () => {
|
||||
}
|
||||
})
|
||||
|
||||
it("returns a list of products with giftcard in list", async () => {
|
||||
it("returns a list of products with only giftcard in list", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
@@ -423,7 +469,7 @@ describe("/admin/products", () => {
|
||||
],
|
||||
variants: [
|
||||
{
|
||||
id: "test-variant", //expect.stringMatching(/^test-variant*/),
|
||||
id: "test-variant", // expect.stringMatching(/^test-variant*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
product_id: expect.stringMatching(/^test-*/),
|
||||
@@ -446,7 +492,7 @@ describe("/admin/products", () => {
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "test-variant_2", //expect.stringMatching(/^test-variant*/),
|
||||
id: "test-variant_2", // expect.stringMatching(/^test-variant*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
product_id: expect.stringMatching(/^test-*/),
|
||||
@@ -519,7 +565,7 @@ describe("/admin/products", () => {
|
||||
options: [],
|
||||
variants: [
|
||||
{
|
||||
id: "test-variant_4", //expect.stringMatching(/^test-variant*/),
|
||||
id: "test-variant_4", // expect.stringMatching(/^test-variant*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
product_id: expect.stringMatching(/^test-*/),
|
||||
@@ -542,7 +588,7 @@ describe("/admin/products", () => {
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "test-variant_3", //expect.stringMatching(/^test-variant*/),
|
||||
id: "test-variant_3", // expect.stringMatching(/^test-variant*/),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
product_id: expect.stringMatching(/^test-*/),
|
||||
@@ -595,7 +641,6 @@ describe("/admin/products", () => {
|
||||
options: expect.any(Array),
|
||||
tags: expect.any(Array),
|
||||
variants: expect.any(Array),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
{
|
||||
@@ -607,7 +652,6 @@ describe("/admin/products", () => {
|
||||
options: expect.any(Array),
|
||||
tags: expect.any(Array),
|
||||
variants: expect.any(Array),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
{
|
||||
@@ -619,7 +663,6 @@ describe("/admin/products", () => {
|
||||
options: expect.any(Array),
|
||||
tags: expect.any(Array),
|
||||
variants: expect.any(Array),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
},
|
||||
])
|
||||
@@ -736,6 +779,46 @@ describe("/admin/products", () => {
|
||||
)
|
||||
})
|
||||
|
||||
it("creates a product that is not discountable", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
title: "Test",
|
||||
discountable: false,
|
||||
description: "test-product-description",
|
||||
type: { value: "test-type" },
|
||||
images: ["test-image.png", "test-image-2.png"],
|
||||
collection_id: "test-collection",
|
||||
tags: [{ value: "123" }, { value: "456" }],
|
||||
options: [{ title: "size" }, { title: "color" }],
|
||||
variants: [
|
||||
{
|
||||
title: "Test variant",
|
||||
inventory_quantity: 10,
|
||||
prices: [{ currency_code: "usd", amount: 100 }],
|
||||
options: [{ value: "large" }, { value: "green" }],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
const response = await api
|
||||
.post("/admin/products", payload, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.product).toEqual(
|
||||
expect.objectContaining({
|
||||
discountable: false,
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it("Sets variant ranks when creating a product", async () => {
|
||||
const api = useApi()
|
||||
|
||||
@@ -844,7 +927,6 @@ describe("/admin/products", () => {
|
||||
|
||||
const payload = {
|
||||
collection_id: null,
|
||||
type: null,
|
||||
variants: [
|
||||
{
|
||||
id: "test-variant",
|
||||
@@ -898,7 +980,6 @@ describe("/admin/products", () => {
|
||||
],
|
||||
}),
|
||||
],
|
||||
type: null,
|
||||
status: "published",
|
||||
collection: null,
|
||||
type: expect.objectContaining({
|
||||
@@ -1074,6 +1155,41 @@ describe("/admin/products", () => {
|
||||
)
|
||||
})
|
||||
|
||||
it("successfully deletes a product and variants", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const variantPre = await dbConnection.manager.findOne(ProductVariant, {
|
||||
id: "test-variant",
|
||||
})
|
||||
|
||||
expect(variantPre).not.toEqual(undefined)
|
||||
|
||||
const response = await api
|
||||
.delete("/admin/products/test-product", {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
expect(response.data).toEqual(
|
||||
expect.objectContaining({
|
||||
id: "test-product",
|
||||
deleted: true,
|
||||
})
|
||||
)
|
||||
|
||||
const variant = await dbConnection.manager.findOne(ProductVariant, {
|
||||
id: "test-variant",
|
||||
})
|
||||
|
||||
expect(variant).toEqual(undefined)
|
||||
})
|
||||
|
||||
it("successfully creates product with soft-deleted product handle and deletes it again", async () => {
|
||||
const api = useApi()
|
||||
|
||||
|
||||
78
integration-tests/api/__tests__/admin/region.js
Normal file
78
integration-tests/api/__tests__/admin/region.js
Normal file
@@ -0,0 +1,78 @@
|
||||
const path = require("path")
|
||||
const { Region, FulfillmentProvider } = 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)
|
||||
|
||||
describe("/admin/discounts", () => {
|
||||
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("DELETE /admin/regions/:id", () => {
|
||||
beforeEach(async () => {
|
||||
const manager = dbConnection.manager
|
||||
await adminSeeder(dbConnection)
|
||||
await manager.insert(Region, {
|
||||
id: "test-region",
|
||||
name: "Test Region",
|
||||
currency_code: "usd",
|
||||
tax_rate: 0,
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("successfully deletes a region with a fulfillment provider", async () => {
|
||||
const api = useApi()
|
||||
|
||||
// add fulfillment provider to the region
|
||||
await api.post(
|
||||
"/admin/regions/test-region",
|
||||
{
|
||||
fulfillment_providers: ["test-ful"],
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
const response = await api
|
||||
.delete(`/admin/regions/test-region`, {
|
||||
headers: {
|
||||
Authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
expect(response.data).toEqual({
|
||||
id: "test-region",
|
||||
object: "region",
|
||||
deleted: true,
|
||||
})
|
||||
expect(response.status).toEqual(200)
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user