Feat(link-module, core-flows, medusa): Add sales channel location management (#6905)
* add locations with sales channels * init, not working location based management * working adding sales channel stock locations * remote sales channels from location * remove console log * rm allowedFields * redo errorhandler * make validation take an array * add changeset * fix build * Update packages/core-flows/src/sales-channel/workflows/remove-locations-from-sales-channel.ts Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com> * add default cases to return early * cleanup * add sc test and remove associations --------- Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
co-authored by
Oli Juhl
parent
27f4f0d724
commit
edafe7db47
@@ -1,6 +1,9 @@
|
||||
const { ModuleRegistrationName, Modules } = require("@medusajs/modules-sdk")
|
||||
const { medusaIntegrationTestRunner } = require("medusa-test-utils")
|
||||
const { createAdminUser } = require("../../../helpers/create-admin-user")
|
||||
const {
|
||||
createAdminUser,
|
||||
adminHeaders,
|
||||
} = require("../../../helpers/create-admin-user")
|
||||
const { breaking } = require("../../../helpers/breaking")
|
||||
const { ContainerRegistrationKeys } = require("@medusajs/utils")
|
||||
|
||||
@@ -345,7 +348,7 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should delete the requested sales channel", async () => {
|
||||
let toDelete = await breaking(
|
||||
const toDelete = await breaking(
|
||||
async () => {
|
||||
return await dbConnection.manager.findOne(SalesChannel, {
|
||||
where: { id: salesChannel.id },
|
||||
@@ -403,6 +406,48 @@ medusaIntegrationTestRunner({
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
it("should successfully delete channel associations", async () => {
|
||||
await breaking(null, async () => {
|
||||
const remoteLink = container.resolve(
|
||||
ContainerRegistrationKeys.REMOTE_LINK
|
||||
)
|
||||
|
||||
console.warn("testing")
|
||||
await remoteLink.create([
|
||||
{
|
||||
[Modules.SALES_CHANNEL]: {
|
||||
sales_channel_id: "test-channel",
|
||||
},
|
||||
[Modules.STOCK_LOCATION]: {
|
||||
stock_location_id: "test-location",
|
||||
},
|
||||
},
|
||||
{
|
||||
[Modules.SALES_CHANNEL]: {
|
||||
sales_channel_id: "test-channel-default",
|
||||
},
|
||||
[Modules.STOCK_LOCATION]: {
|
||||
stock_location_id: "test-location",
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
await api
|
||||
.delete(`/admin/sales-channels/test-channel`, adminReqConfig)
|
||||
.catch(console.log)
|
||||
|
||||
const linkService = remoteLink.getLinkModule(
|
||||
Modules.SALES_CHANNEL,
|
||||
"sales_channel_id",
|
||||
Modules.STOCK_LOCATION,
|
||||
"stock_location_id"
|
||||
)
|
||||
|
||||
const channelLinks = await linkService.list()
|
||||
expect(channelLinks).toHaveLength(1)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("GET /admin/orders/:id", () => {
|
||||
|
||||
Reference in New Issue
Block a user