feat(medusa): Prevent default channel from being deleted (#1835)
**What** Prevent the default channel from being deleted Fixes CORE-317
This commit is contained in:
committed by
GitHub
parent
e539bdc620
commit
4e375c2203
@@ -188,6 +188,15 @@ describe("sales channels", () => {
|
||||
name: "test name",
|
||||
description: "test description",
|
||||
})
|
||||
|
||||
await simpleSalesChannelFactory(dbConnection, {
|
||||
name: "Default channel",
|
||||
id: "test-channel",
|
||||
})
|
||||
|
||||
await dbConnection.manager.query(
|
||||
`UPDATE store SET default_sales_channel_id = 'test-channel'`
|
||||
)
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
@@ -197,6 +206,7 @@ describe("sales channels", () => {
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("should delete the requested sales channel", async () => {
|
||||
const api = useApi()
|
||||
|
||||
@@ -286,6 +296,20 @@ describe("sales channels", () => {
|
||||
expect(deletedSalesChannel.id).toEqual(salesChannel.id)
|
||||
expect(deletedSalesChannel.deleted_at).not.toEqual(null)
|
||||
})
|
||||
|
||||
it("should throw if we attempt to delete default channel", async () => {
|
||||
const api = useApi()
|
||||
expect.assertions(2)
|
||||
|
||||
const res = await api
|
||||
.delete(`/admin/sales-channels/test-channel`, adminReqConfig)
|
||||
.catch((err) => err)
|
||||
|
||||
expect(res.response.status).toEqual(400)
|
||||
expect(res.response.data.message).toEqual(
|
||||
"You cannot delete the default sales channel"
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe("GET /admin/orders/:id", () => {
|
||||
|
||||
Reference in New Issue
Block a user