Files
medusa-store/integration-tests/http/__tests__/fulfillment/admin/fulfillment-provider.spec.ts
Frane Polić 0c49470066 feat(core-flows): calculate SO price on cart ops (#10563)
**What**
- calculate the shipping option price when creating a shipping method
- calculate the shipping option price when refreshing cart
- add testing for calculated SO flow
- fix validation on calculated SO creation
- add manual fulfillment provider for testing
- add `from_location` to calculation context

---

RESOLVES CMRC-778
RESOLVES CMRC-602
RESOLVES SUP-136
2024-12-16 22:28:30 +00:00

79 lines
2.3 KiB
TypeScript

import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
import {
adminHeaders,
createAdminUser,
} from "../../../../helpers/create-admin-user"
jest.setTimeout(50000)
medusaIntegrationTestRunner({
testSuite: ({ dbConnection, getContainer, api }) => {
describe("Admin: Fulfillment Provider API", () => {
let location
beforeEach(async () => {
await createAdminUser(dbConnection, adminHeaders, getContainer())
location = (
await api.post(
`/admin/stock-locations`,
{ name: "Test location" },
adminHeaders
)
).data.stock_location
})
describe("GET /admin/fulfillment-providers", () => {
it("should list all fulfillment providers successfully", async () => {
const response = await api.get(
`/admin/fulfillment-providers`,
adminHeaders
)
expect(response.status).toEqual(200)
expect(response.data.fulfillment_providers).toEqual(
expect.arrayContaining([
expect.objectContaining({
id: "manual_test-provider",
is_enabled: true,
}),
expect.objectContaining({
id: "manual-calculated_test-provider-calculated",
is_enabled: true,
}),
])
)
})
it("should list all fulfillment providers scoped by stock location", async () => {
let response = await api.get(
`/admin/fulfillment-providers?stock_location_id=${location.id}`,
adminHeaders
)
expect(response.status).toEqual(200)
expect(response.data.fulfillment_providers).toEqual([])
await api.post(
`/admin/stock-locations/${location.id}/fulfillment-providers`,
{ add: ["manual_test-provider"] },
adminHeaders
)
response = await api.get(
`/admin/fulfillment-providers?stock_location_id=${location.id}`,
adminHeaders
)
expect(response.data.fulfillment_providers).toEqual([
expect.objectContaining({
id: "manual_test-provider",
is_enabled: true,
}),
])
})
})
})
},
})