feat(dashboard): shipping management (#6995)

**What**
- shipping flow
- shipping profile pages
- delete fulfillment set endpoint
- delete shipping profile endpoint
This commit is contained in:
Frane Polić
2024-04-16 15:42:56 +02:00
committed by GitHub
parent c3260a2c5a
commit 0a9b9b073d
62 changed files with 2501 additions and 12 deletions

View File

@@ -1,5 +1,8 @@
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
import { IFulfillmentModuleService } from "@medusajs/types"
import {
IFulfillmentModuleService,
IStockLocationServiceNext,
} from "@medusajs/types"
import {
adminHeaders,
createAdminUser,
@@ -15,7 +18,7 @@ medusaIntegrationTestRunner({
},
testSuite: ({ dbConnection, getContainer, api }) => {
let appContainer
let service: IFulfillmentModuleService
let service: IStockLocationServiceNext
beforeEach(async () => {
appContainer = getContainer()
@@ -25,6 +28,29 @@ medusaIntegrationTestRunner({
service = appContainer.resolve(ModuleRegistrationName.STOCK_LOCATION)
})
describe("POST /admin/fulfillment-sets/:id", () => {
it("should delete a fulfillment set", async () => {
const fulfillmentService: IFulfillmentModuleService =
appContainer.resolve(ModuleRegistrationName.FULFILLMENT)
const set = await fulfillmentService.create({
name: "Test fulfillment set",
type: "pickup",
})
const deleteResponse = await api.delete(
`/admin/fulfillment-sets/${set.id}`,
adminHeaders
)
expect(deleteResponse.data).toEqual({
id: set.id,
object: "fulfillment_set",
deleted: true,
})
})
})
describe("POST /admin/fulfillment-sets/:id/service-zones", () => {
it("should create, update, and delete a service zone for a fulfillment set", async () => {
const stockLocationResponse = await api.post(

View File

@@ -35,7 +35,7 @@ medusaIntegrationTestRunner({
})
describe("Admin - Shipping Profiles", () => {
// TODO: Missing update and delete tests
// TODO: Missing update tests
it("should test the entire lifecycle of a shipping profile", async () => {
const payload = {
name: "test-profile-2023",
@@ -84,6 +84,23 @@ medusaIntegrationTestRunner({
created_at: expect.any(String),
})
)
const { data } = await api.delete(
`/admin/shipping-profiles/${shipping_profile.id}`,
adminHeaders
)
expect(data).toEqual({
id: retrievedProfile.id,
object: "shipping_profile",
deleted: true,
})
await api
.get(`/admin/shipping-profiles/${shipping_profile.id}`, adminHeaders)
.catch((err) => {
expect(err.response.status).toEqual(404)
})
})
})
@@ -205,7 +222,6 @@ medusaIntegrationTestRunner({
})
describe("DELETE /admin/shipping-profiles", () => {
// TODO: Delete is not added yet
it("deletes a shipping profile", async () => {
expect.assertions(2)