feat(medusa, medusa-js, medusa-react): Implement Sales Channel update (#1797)
This commit is contained in:
@@ -11,3 +11,15 @@ Object {
|
||||
"updated_at": Any<String>,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`sales channels POST /admin/sales-channels/:id updates sales channel properties 1`] = `
|
||||
Object {
|
||||
"created_at": Any<String>,
|
||||
"deleted_at": null,
|
||||
"description": "updated description",
|
||||
"id": Any<String>,
|
||||
"is_disabled": true,
|
||||
"name": "updated name",
|
||||
"updated_at": Any<String>,
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -4,7 +4,7 @@ const { useApi } = require("../../../helpers/use-api")
|
||||
const { useDb } = require("../../../helpers/use-db")
|
||||
|
||||
const adminSeeder = require("../../helpers/admin-seeder")
|
||||
const { simpleSalesChannelFactory, } = require("../../factories")
|
||||
const { simpleSalesChannelFactory } = require("../../factories")
|
||||
|
||||
const startServerWithEnvironment =
|
||||
require("../../../helpers/start-server-with-environment").default
|
||||
@@ -49,7 +49,7 @@ describe("sales channels", () => {
|
||||
describe("GET /admin/sales-channels/:id", () => {
|
||||
let salesChannel
|
||||
|
||||
beforeEach(async() => {
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection)
|
||||
salesChannel = await simpleSalesChannelFactory(dbConnection, {
|
||||
@@ -61,12 +61,12 @@ describe("sales channels", () => {
|
||||
}
|
||||
})
|
||||
|
||||
afterEach(async() => {
|
||||
afterEach(async () => {
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("should retrieve the requested sales channel", async() => {
|
||||
it("should retrieve the requested sales channel", async () => {
|
||||
const api = useApi()
|
||||
const response = await api.get(
|
||||
`/admin/sales-channels/${salesChannel.id}`,
|
||||
@@ -85,6 +85,56 @@ describe("sales channels", () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe("POST /admin/sales-channels/:id", () => {})
|
||||
describe("POST /admin/sales-channels/:id", () => {
|
||||
let sc
|
||||
|
||||
beforeEach(async () => {
|
||||
try {
|
||||
await adminSeeder(dbConnection)
|
||||
sc = await simpleSalesChannelFactory(dbConnection, {
|
||||
name: "test name",
|
||||
description: "test description",
|
||||
})
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("updates sales channel properties", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const payload = {
|
||||
name: "updated name",
|
||||
description: "updated description",
|
||||
is_disabled: true,
|
||||
}
|
||||
|
||||
const response = await api.post(
|
||||
`/admin/sales-channels/${sc.id}`,
|
||||
payload,
|
||||
{
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.sales_channel).toMatchSnapshot({
|
||||
id: expect.any(String),
|
||||
name: payload.name,
|
||||
description: payload.description,
|
||||
is_disabled: payload.is_disabled,
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("DELETE /admin/sales-channels/:id", () => {})
|
||||
})
|
||||
|
||||
@@ -28,4 +28,4 @@ export const simpleSalesChannelFactory = async (
|
||||
})
|
||||
|
||||
return await manager.save(salesChannel)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user